From c4d953acb53b6f69af13a45f4e42bc2366acbcab Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Thu, 4 May 2023 11:17:55 +0000 Subject: [PATCH] fix: add verif when map body doesn't contain only regulare char --- map/parsing_body.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/map/parsing_body.c b/map/parsing_body.c index 787ab13..c2ef3c8 100644 --- a/map/parsing_body.c +++ b/map/parsing_body.c @@ -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); }