Invalid element in map fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
NO assets/textures/backRoom3.png
|
||||
SO assets/textures/backRoom3.png
|
||||
WE assets/textures/backRoom3.png
|
||||
EA assets/textures/backRoom3.png
|
||||
EAS assets/textures/backRoom3.png
|
||||
|
||||
C 164,157,79
|
||||
F 30,55,55
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/04 09:28:05 by aortigos #+# #+# */
|
||||
/* Updated: 2026/01/11 16:04:46 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 11:02:56 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -78,16 +78,23 @@ int read_map_(t_data *map, int count)
|
||||
void process_map(t_data *map, int *count)
|
||||
{
|
||||
char *tmp;
|
||||
int res;
|
||||
|
||||
while (map->line && map->line[0] != '1' && map->line[0] != 32)
|
||||
{
|
||||
if (check_color_textures(map->line))
|
||||
res = check_color_textures(map->line);
|
||||
if (res == 1)
|
||||
{
|
||||
tmp = ft_strjoin(map->ture, map->line);
|
||||
ft_memfree(map->ture);
|
||||
map->ture = ft_strdup(tmp);
|
||||
ft_memfree(tmp);
|
||||
(*count)++;
|
||||
} else if (res == -1)
|
||||
{
|
||||
ft_putstr_fd("Error: Invalid element in map\n", 2);
|
||||
freetl(map->ture, map->line, map->fd);
|
||||
exit(1);
|
||||
}
|
||||
ft_memfree(map->line);
|
||||
map->line = get_next_line(map->fd);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/12/05 15:42:28 by aortigos #+# #+# */
|
||||
/* Updated: 2026/01/11 16:05:24 by aortigos ### ########.fr */
|
||||
/* Updated: 2026/01/25 10:57:39 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -59,9 +59,17 @@ int check_color_textures(char *line)
|
||||
{
|
||||
while (ft_isspace(*line))
|
||||
line++;
|
||||
return ((!ft_strncmp(line, "EA", 2) || !ft_strncmp(line, "NO", 2)
|
||||
if ((!ft_strncmp(line, "EA", 2) || !ft_strncmp(line, "NO", 2)
|
||||
|| !ft_strncmp(line, "SO", 2) || !ft_strncmp(line, "WE", 2))
|
||||
|| (!ft_strncmp(line, "F", 1) || !ft_strncmp(line, "C", 1)));
|
||||
&& ft_isspace(line[2]))
|
||||
return (1);
|
||||
else if ((!ft_strncmp(line, "F", 1) || !ft_strncmp(line, "C", 1))
|
||||
&& ft_isspace(line[1]))
|
||||
return (1);
|
||||
else if (*line == '\n' || *line == '\0')
|
||||
return (0);
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int check_count_textures(t_data *m, int count)
|
||||
|
||||
Reference in New Issue
Block a user