diff options
| -rw-r--r-- | map.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -819,7 +819,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi if (row < *height && col < *width && (*map)[row][col] != WALL && (col != goal->x || row != goal->y)) { start->x = col; start->y = row; - if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + if (should_pathfind) { + path_free(path, *height); + path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + } draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL); } } @@ -830,7 +833,10 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi if (row < *height && col < *width && (*map)[row][col] != WALL && (col != start->x || row != start->y)) { goal->x = col; goal->y = row; - if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + if (should_pathfind) { + path_free(path, *height); + path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); + } draw_map(*map, NULL, *width, *height, *start, *goal, NULL, path, visited, NULL); } } |
