Added wall check in the parser. Now doing the flood fill

This commit is contained in:
Theo Champion 2025-06-20 15:24:05 +02:00
parent 9a39668872
commit 1206ef2f3d
2 changed files with 21 additions and 7 deletions

View file

@ -6,7 +6,7 @@
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
/* Updated: 2025/06/20 12:43:33 by tchampio ### ########.fr */
/* Updated: 2025/06/20 15:23:32 by tchampio ### ########.fr */
/* */
/* ************************************************************************** */
@ -209,11 +209,25 @@ void populate_maps(t_mapdata *map, int fd)
bool check_walls(t_mapdata *map)
{
int i;
int j;
int line_length;
i = 0;
while (i < map->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);