aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'map.c')
-rw-r--r--map.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/map.c b/map.c
index 85cc073..11f9eb6 100644
--- a/map.c
+++ b/map.c
@@ -659,6 +659,7 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
* [a] - Toggle pathfinding
*
* [d] - Switch algorithms (A* or Dijsktra's)
+ * [4] - Switch amount of directions (4 or 8)
*
* [r] - Reverse path
*
@@ -719,6 +720,15 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
case 'd':
if (path_func == astar_path) { set_message("Dijkstra's"); path_func = &dijkstra_path; }
else { set_message("A*"); path_func = &astar_path; };
+
+ path_free(path, *height);
+ if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
+ break;
+
+ case '4':
+ if (dirs == 4) { set_message("8 directions"); dirs = 8; }
+ else { set_message("4 directions"); dirs = 4; };
+
path_free(path, *height);
if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
break;