mirror of
https://codeberg.org/ACME-Corporation/cub3d.git
synced 2025-12-06 01:48:08 +01:00
added character checker and started the flood filling
This commit is contained in:
parent
1206ef2f3d
commit
63d4eb28ef
1 changed files with 37 additions and 4 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
/* By: tchampio <tchampio@student.42lehavre. +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
/* Created: 2025/06/06 17:54:42 by tchampio #+# #+# */
|
||||||
/* Updated: 2025/06/20 15:23:32 by tchampio ### ########.fr */
|
/* Updated: 2025/06/20 15:40:20 by tchampio ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -206,6 +206,23 @@ void populate_maps(t_mapdata *map, int fd)
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_forbidden_characters(char *line)
|
||||||
|
{
|
||||||
|
static const char *allowedchars = "10NSEW";
|
||||||
|
size_t strsize;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
strsize = ft_strlen(line);
|
||||||
|
i = 0;
|
||||||
|
while (i < strsize)
|
||||||
|
{
|
||||||
|
if (!ft_strchr(allowedchars, line[i]))
|
||||||
|
return (true);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
bool check_walls(t_mapdata *map)
|
bool check_walls(t_mapdata *map)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -228,11 +245,25 @@ bool check_walls(t_mapdata *map)
|
||||||
if (ft_strlen(map->map[i]) != (unsigned int)j)
|
if (ft_strlen(map->map[i]) != (unsigned int)j)
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
if (has_forbidden_characters(map->map[i]))
|
||||||
|
return (true);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool check_bare_minimum(char **map)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool flood_fill(char **mapflood)
|
||||||
|
{
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
void print_map(char **map)
|
void print_map(char **map)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -264,8 +295,10 @@ bool check_cubfile(char *file, t_mapdata *map)
|
||||||
if (!check_walls(map))
|
if (!check_walls(map))
|
||||||
return (close(fd), ft_strlcpy(map->error,
|
return (close(fd), ft_strlcpy(map->error,
|
||||||
"Map is malformed (invalid chars or missing walls)", 51), false);
|
"Map is malformed (invalid chars or missing walls)", 51), false);
|
||||||
//if (!flood_fill(map->mapflood))
|
if (!check_bare_minimum(map->map))
|
||||||
// return (close(fd), ft_strlcpy(map->error,
|
return (close(fd), false);
|
||||||
// "Map is not possible (flood fill failed)", 41), false);
|
if (!flood_fill(map->mapflood))
|
||||||
|
return (close(fd), ft_strlcpy(map->error,
|
||||||
|
"Map is not possible (flood fill failed)", 41), false);
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue