aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.c b/main.c
index b77d554..937db12 100644
--- a/main.c
+++ b/main.c
@@ -176,7 +176,15 @@ int main(int argc, char **argv) {
}
break;
- case 'a': anim = !anim; break;
+ case 'a':
+ /* Only animate if there was already a path, otherwise just calculate one */
+ if (path == NULL) anim = 0;
+ else anim = 1;
+
+ path_free(path, height);
+ path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim);
+ clear_message();
+ break;
case 'd':
if (path_func == astar_path) { set_message("Dijkstra"); path_func = &dijkstra_path; }