fix: leak && 1x1 map not surround

This commit is contained in:
Camille Chauvet 2023-05-05 15:32:29 +00:00
parent fbb9864ef4
commit 5bdc48340d
2 changed files with 8 additions and 8 deletions

View File

@ -95,7 +95,5 @@ int map_parsing(const char *path, t_map *map)
ft_freer_tab_ultimate(1, file_content); ft_freer_tab_ultimate(1, file_content);
if (body_is_valid(map) == 0) if (body_is_valid(map) == 0)
return (1); return (1);
map->direction = map->map[(size_t) map->ply_y][(size_t) map->ply_x];
map->map[(size_t) map->ply_y][(size_t) map->ply_x] = '0';
return (0); return (0);
} }

View File

@ -157,12 +157,8 @@ int body_is_valid(t_map *map)
ft_eprintf("map: spawn position: not define"); ft_eprintf("map: spawn position: not define");
return (0); return (0);
} }
error = map_surround((const char **)map->map); map->direction = map->map[(size_t) map->ply_y][(size_t) map->ply_x];
if (error) map->map[(size_t) map->ply_y][(size_t) map->ply_x] = '0';
{
ft_eprintf("map: not surrounded");
return (0);
}
error = map_is_in_one_part((const char **)map->map); error = map_is_in_one_part((const char **)map->map);
if (error) if (error)
{ {
@ -171,6 +167,12 @@ int body_is_valid(t_map *map)
} }
if (body_contain_normal_char((const char **)map->map) == 0) if (body_contain_normal_char((const char **)map->map) == 0)
return (0); return (0);
error = map_surround((const char **)map->map);
if (error)
{
ft_eprintf("map: not surrounded");
return (0);
}
get_size((const char **)map->map, map); get_size((const char **)map->map, map);
return (1); return (1);
} }