42_cube3D/map/parsing_header3.c

57 lines
1.6 KiB
C
Raw Normal View History

2023-05-16 13:12:54 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing_header3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/16 16:41:51 by cchauvet #+# #+# */
/* Updated: 2023/05/16 19:07:12 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "./parsing_private.h"
static int set_header_data(char ***header, size_t i, t_map *map)
{
int token;
token = get_token(header[i][0]);
if (token > 0 && token < 5)
{
if (set_texture(map, token, header[i][0], header[i][1]))
return (1);
}
else if (token == 5)
{
if (set_color(&map->color_bot,
header[i][0], header[i][1]))
return (1);
}
else if (token == 6)
{
if (set_color(&map->color_top,
header[i][0], header[i][1]))
return (1);
}
return (0);
}
int header_is_valid(char ***header, t_map *map)
{
size_t i;
if (header == NULL)
return (1);
map->color_bot = -1;
map->color_top = -1;
i = 0;
while (i < ft_tablen((const void **) header))
{
if (set_header_data(header, i, map))
return (1);
i++;
}
return (check_header_is_complete(map));
}