/* ************************************************************************** */
/*                                                                            */
/*                                                        ::::::::            */
/*   parse_config_line.c                                :+:    :+:            */
/*                                                     +:+                    */
/*   By: whaffman <whaffman@student.codam.nl>         +#+                     */
/*                                                   +#+                      */
/*   Created: 2025/04/22 13:10:06 by whaffman      #+#    #+#                 */
/*   Updated: 2025/05/07 11:48:16 by whaffman      ########   odam.nl         */
/*                                                                            */
/* ************************************************************************** */

#include "cub3d.h"

int	parse_config_line(const char *line, t_map *map)
{
	char	**tokens;

	tokens = ft_split(line, ' ');
	if (!tokens || !tokens[0] || !tokens[1] || tokens[2])
		return (FAILURE);
	if (ft_strncmp(tokens[0], "NO", 2) == 0)
		map->NO_texture = ft_strdup(tokens[1]);
	else if (ft_strncmp(tokens[0], "SO", 2) == 0)
		map->SO_texture = ft_strdup(tokens[1]);
	else if (ft_strncmp(tokens[0], "WE", 2) == 0)
		map->WE_texture = ft_strdup(tokens[1]);
	else if (ft_strncmp(tokens[0], "EA", 2) == 0)
		map->EA_texture = ft_strdup(tokens[1]);
	else if (ft_strncmp(tokens[0], "F", 1) == 0)
		map->floor_color = parse_color(tokens[1]);
	else if (ft_strncmp(tokens[0], "C", 1) == 0)
		map->ceiling_color = parse_color(tokens[1]);
	else
	{
		ft_free_arr(tokens);
		return (FAILURE);
	}
	ft_free_arr(tokens);
	return (SUCCESS);
}
