diff options
| -rw-r--r-- | config.h | 3 | ||||
| -rw-r--r-- | main.c | 7 | ||||
| -rw-r--r-- | map.c | 7 | ||||
| -rw-r--r-- | path.c | 1 | ||||
| -rw-r--r-- | path.h | 2 |
5 files changed, 14 insertions, 6 deletions
@@ -76,6 +76,9 @@ /* --- End of keybindings --- */ +#define ASTAR_STRING "A*" +#define DIJKSTRA_STRING "Dijkstra's" + #define MESSAGE_MAX_SIZE 256 #define FILENAME_BUF_SIZE 128 @@ -269,8 +269,9 @@ int main(int argc, char **argv) { break; case KEYBINDING_ALGO: - if (path_func == astar_path) { set_message("Dijkstra's"); path_func = &dijkstra_path; } - else { set_message("A*"); path_func = &astar_path; }; + if (path_func == astar_path) { path_func_string = DIJKSTRA_STRING; path_func = &dijkstra_path; } + else { path_func_string = ASTAR_STRING; path_func = &astar_path; }; + set_message("%s", path_func_string); path_free(path, height); path = path_func(dirs, map, cell_costs, width, height, start_pos, end_pos, visited, anim); /* TODO: print time */ @@ -383,7 +384,7 @@ int main(int argc, char **argv) { } break; case KEYBINDING_PATH_TIME: - set_message("%f seconds", path_time); print_message(height); + set_message("%f seconds (%s)", path_time, path_func_string); print_message(height); break; case KEYBINDING_LOAD_COSTS: /* Load a cost file */ @@ -727,8 +727,9 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi break; case KEYBINDING_ALGO: - if (path_func == astar_path) { set_message("Dijkstra's"); path_func = &dijkstra_path; } - else { set_message("A*"); path_func = &astar_path; }; + if (path_func == astar_path) { path_func_string = DIJKSTRA_STRING; path_func = &dijkstra_path; } + else { path_func_string = ASTAR_STRING; path_func = &astar_path; }; + set_message("%s", path_func_string); path_free(path, *height); if (should_pathfind) path = path_func(dirs, *map, NULL, *width, *height, *start, *goal, visited, 0); @@ -769,7 +770,7 @@ void map_editor(Map *map, size_t *width, size_t *height, Position *start, Positi break; case KEYBINDING_PATH_TIME: - set_message("%f seconds", path_time); print_message(*height); + set_message("%f seconds (%s)", path_time, path_func_string); print_message(*height); break; case KEYBINDING_SAVE_MAP: @@ -13,6 +13,7 @@ #include "config.h" Path (*path_func)(int, Map, size_t **, size_t, size_t, Position, Position, char **, char) = &astar_path; +char *path_func_string = ASTAR_STRING; double path_time = 0; char wraparound_enabled = 0; @@ -6,6 +6,8 @@ /* The currently chosen path func */ extern Path (*path_func)(int, Map, size_t **, size_t, size_t, Position, Position, char **, char); +/* The string that represents the current algo */ +extern char *path_func_string; /* Time it took to calculate a path */ extern double path_time; |
