From 1206ef2f3d0234a4491b86a0fb2461788b07446c Mon Sep 17 00:00:00 2001 From: Theo Champion Date: Fri, 20 Jun 2025 15:24:05 +0200 Subject: [PATCH] Added wall check in the parser. Now doing the flood fill --- ressources/wrongmap_invalid_colors.cub | 8 ++++---- src/map/map_checker.c | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ressources/wrongmap_invalid_colors.cub b/ressources/wrongmap_invalid_colors.cub index 6cf7a29..d1bef8b 100644 --- a/ressources/wrongmap_invalid_colors.cub +++ b/ressources/wrongmap_invalid_colors.cub @@ -6,10 +6,10 @@ EA ./path_to_the_east_texture F 256,100,0 C 225,30,0 -1111111111111111111111111 -1000000000110000000000001 -1011000001110000000000001 -1001000000000000000000001 + 1111111111111111111111111 + 1000000000110000000000001 + 1011000001110000000000001 + 1001000000000000000000001 111111111011000001110000000000001 100000000011000001110111111111111 11110111111111011100000010001 diff --git a/src/map/map_checker.c b/src/map/map_checker.c index 67f3f48..dcdc477 100644 --- a/src/map/map_checker.c +++ b/src/map/map_checker.c @@ -6,7 +6,7 @@ /* By: tchampio mapheight) { - ft_printf("line: %s", map->map[i]); + j = 0; + line_length = ft_strlen(map->map[i]); + while (map->map[i][j] == ' ') + j++; + if (map->map[i][j] != '1' && map->map[i][line_length - 1] != '1') + return (false); + if (i == 0 || i == map->mapheight - 1) + { + while (map->map[i][j] == '1' || map->map[i][j] == ' ' || map->map[i][j] == '\n') + j++; + if (ft_strlen(map->map[i]) != (unsigned int)j) + return (false); + } i++; } return (true);