From 5bdc48340d77bc0e7350595c697224a3f37cc9c9 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Fri, 5 May 2023 15:32:29 +0000 Subject: [PATCH] fix: leak && 1x1 map not surround --- map/parsing.c | 2 -- map/parsing_body.c | 14 ++++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/map/parsing.c b/map/parsing.c index d9af107..8fa4962 100644 --- a/map/parsing.c +++ b/map/parsing.c @@ -95,7 +95,5 @@ int map_parsing(const char *path, t_map *map) ft_freer_tab_ultimate(1, file_content); if (body_is_valid(map) == 0) 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); } diff --git a/map/parsing_body.c b/map/parsing_body.c index f568507..1fb4fce 100644 --- a/map/parsing_body.c +++ b/map/parsing_body.c @@ -157,12 +157,8 @@ int body_is_valid(t_map *map) ft_eprintf("map: spawn position: not define"); return (0); } - error = map_surround((const char **)map->map); - if (error) - { - ft_eprintf("map: not surrounded"); - return (0); - } + 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'; error = map_is_in_one_part((const char **)map->map); if (error) { @@ -171,6 +167,12 @@ int body_is_valid(t_map *map) } if (body_contain_normal_char((const char **)map->map) == 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); return (1); }