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); }