aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-04-24 17:04:44 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-04-24 17:04:44 +0300
commitdd5d7ac0430f0663a03955c0ff677da27745b498 (patch)
tree22746d5b4e7942a701cc602cae70ba6a56f7b19c
parent90277d19beafa72ef455666c150291ab3fa834c0 (diff)
downloadastar-dd5d7ac0430f0663a03955c0ff677da27745b498.tar.xz
Add wraparound keybinding in map_editor()
-rw-r--r--map.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/map.c b/map.c
index b067475..6f89b19 100644
--- a/map.c
+++ b/map.c
@@ -660,6 +660,8 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
* [d] - Switch algorithms (A* or Dijsktra's)
* [4] - Switch amount of directions (4 or 8)
*
+ * [f] - Toggle wraparound
+ *
* [r] - Reverse path
*
* [s] - Save the map to a plaintext file
@@ -732,6 +734,19 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi
if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
break;
+ case 'f':
+ wraparound_enabled = !wraparound_enabled;
+ if (wraparound_enabled)
+ set_message("Enabled wraparound, only works on Dijkstra's")
+ else
+ set_message("Disabled wraparound");
+
+ if (path_func == dijkstra_path && should_pathfind) {
+ path_free(path, *height);
+ path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0);
+ }
+ break;
+
case 'r':
path_reverse(&path, *width, *height, start, goal);
break;