aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'map.c')
-rw-r--r--map.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/map.c b/map.c
index a5e528c..03e69f5 100644
--- a/map.c
+++ b/map.c
@@ -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);
}
}