fix: missing key
This commit is contained in:
parent
4c31d80a72
commit
7f2a0b4a0e
@ -75,9 +75,9 @@ int map_parsing(const char *path, t_map *map)
|
|||||||
char ***header;
|
char ***header;
|
||||||
size_t header_size;
|
size_t header_size;
|
||||||
|
|
||||||
|
ft_bzero(map, sizeof(t_map));
|
||||||
if (parsing_meta(path))
|
if (parsing_meta(path))
|
||||||
return (1);
|
return (1);
|
||||||
ft_bzero(map, sizeof(t_map));
|
|
||||||
file_content = read_map(path);
|
file_content = read_map(path);
|
||||||
if (file_content == NULL)
|
if (file_content == NULL)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ int body_is_valid(t_map *map)
|
|||||||
}
|
}
|
||||||
else if (error == 2)
|
else if (error == 2)
|
||||||
{
|
{
|
||||||
ft_eprintf("map: spawn position: not define");
|
ft_eprintf("map: spawn position: not defined");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
map->direction = map->map[(int) map->ply_y][(int) map->ply_x];
|
map->direction = map->map[(int) map->ply_y][(int) map->ply_x];
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "./parsing_private.h"
|
#include "./parsing_private.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
static int set_texture(t_map *map, int token, const char *key, char *value)
|
static int set_texture(t_map *map, int token, const char *key, char *value)
|
||||||
{
|
{
|
||||||
@ -66,6 +67,25 @@ static int set_color(long long *color, const char *key, char *value)
|
|||||||
return (*color == -1);
|
return (*color == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int check_header_is_complete(t_map *map)
|
||||||
|
{
|
||||||
|
if (map->img_path[0] == NULL)
|
||||||
|
ft_eprintf("map: incomplete: Nord texture is missing");
|
||||||
|
else if (map->img_path[0] == NULL)
|
||||||
|
ft_eprintf("map: incomplete: WEST texture is missing");
|
||||||
|
else if (map->img_path[0] == NULL)
|
||||||
|
ft_eprintf("map: incomplete: SOUTH texture is missing");
|
||||||
|
else if (map->img_path[0] == NULL)
|
||||||
|
ft_eprintf("map: incomplete: EAST texture is missing");
|
||||||
|
else if (map->color_bot == -1)
|
||||||
|
ft_eprintf("map: incomplete: floor color is missing");
|
||||||
|
else if (map->color_top == -1)
|
||||||
|
ft_eprintf("map: incomplete: roof color is missing");
|
||||||
|
else
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
int header_is_valid(char ***header, t_map *map)
|
int header_is_valid(char ***header, t_map *map)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -80,15 +100,24 @@ int header_is_valid(char ***header, t_map *map)
|
|||||||
while (i < ft_tablen((const void **) header))
|
while (i < ft_tablen((const void **) header))
|
||||||
{
|
{
|
||||||
token = get_token(header[i][0]);
|
token = get_token(header[i][0]);
|
||||||
if (token > 0 && token < 5
|
if (token > 0 && token < 5)
|
||||||
&& set_texture(map, token, header[i][0], header[i][1]))
|
{
|
||||||
return (0);
|
if (set_texture(map, token, header[i][0], header[i][1]))
|
||||||
else if ((token == 5 && set_color(&map->color_bot,
|
return (1);
|
||||||
|
}
|
||||||
|
else if (token == 5)
|
||||||
|
{
|
||||||
|
if (set_color(&map->color_bot,
|
||||||
header[i][0], header[i][1]))
|
header[i][0], header[i][1]))
|
||||||
|| (token == 6 && set_color(&map->color_top,
|
return (1);
|
||||||
header[i][0], header[i][1])))
|
}
|
||||||
return (0);
|
else if (token == 6)
|
||||||
|
{
|
||||||
|
if (set_color(&map->color_top,
|
||||||
|
header[i][0], header[i][1]))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return (!map->img_path[0] || !map->img_path[1] || !map->img_path[2]|| !map->img_path[3] || map->color_top == -1 || map->color_bot == -1);
|
return (check_header_is_complete(map));
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ static int name_check(const char *path)
|
|||||||
if (len < 4
|
if (len < 4
|
||||||
|| (ft_strcmp(".cub", path + len - 4) != 0))
|
|| (ft_strcmp(".cub", path + len - 4) != 0))
|
||||||
{
|
{
|
||||||
ft_eprintf("map: name doesn't finished by .cub");
|
ft_eprintf("map: name doesn't finish by .cub");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user