diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-23 14:29:15 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-04-23 14:29:15 +0300 |
| commit | 6834ffa31842ca249514854bac8bae0f0022f104 (patch) | |
| tree | e3b2c68ee6951727b65910b5bfe7876646c756bd /path.c | |
| parent | fbde58b3509184a687759bc822b5567e9a13d2bc (diff) | |
| download | astar-6834ffa31842ca249514854bac8bae0f0022f104.tar.xz | |
Make wraparound toggleable with a keybind
Diffstat (limited to 'path.c')
| -rw-r--r-- | path.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -16,6 +16,8 @@ Path (*path_func)(int, Map, size_t **, size_t, size_t, Position, Position, char **, char) = &astar_path; double path_time = 0; +char wraparound_enabled = 0; + char anim_automatic = 0; /* TODO: make it move the map maybe to show the path */ @@ -134,8 +136,12 @@ Path dijkstra_path(int dirs, Map map, size_t **cell_costs, size_t width, size_t unsigned int (*neighbours)(Position[], size_t[], Position, size_t, size_t, char**, size_t**) = NULL; switch (dirs) { - case 4: neighbours = &neighbours_4dir; break; - case 8: neighbours = &neighbours_8dir; break; + case 4: if (wraparound_enabled) neighbours = &neighbours_4dir_wraparound; + else neighbours = &neighbours_4dir; + break; + case 8: if (wraparound_enabled) neighbours = &neighbours_8dir_wraparound; + else neighbours = &neighbours_8dir; + break; default: error("Tried to call dijkstra_path with wrong direction amount\n"); } |
