fix: add verif when map body doesn't contain only regulare char

This commit is contained in:
Camille Chauvet 2023-05-04 11:17:55 +00:00
parent a301809bea
commit c4d953acb5

View File

@ -126,6 +126,29 @@ static int map_surround(const char **body, t_map *map)
return (0);
}
static int body_contain_normal_char(const char **body)
{
unsigned int y;
unsigned int x;
y = 0;
while (body[y] != NULL)
{
x = 0;
while (body[y][x] != '\0')
{
if (!ft_is_in(" 01NEWS", body[y][x]))
{
ft_eprintf("map: %c: invalid character at rows=%u, colums=%u", body[y][x], y, x);
return (0);
}
x++;
}
y++;
}
return (1);
}
int body_is_valid(const char **body, t_map *map)
{
int error;
@ -155,5 +178,7 @@ int body_is_valid(const char **body, t_map *map)
ft_eprintf("map: splitted");
return (0);
}
if (body_contain_normal_char(body) == 0)
return (0);
return (1);
}