4 #include <stdlib.h> /* for exit(), free(), defines EXIT_SUCESS, EXIT_FAILURE */
5 #include <stdio.h> /* for printf(), perror() */
6 #include <stdint.h> /* for uint8_t */
7 #include <ncurses.h> /* for endwin() */
8 #include "main.h" /* for World struct */
9 #include "map.h" /* for Map struct */
10 #include "keybindings.h" /* for KeysWinData, KeyBinding structs */
13 /* The clean-up routine and the flag resource by which it decides what to do. */
14 static uint8_t cleanup_flags = 0x00;
15 static void cleanup(struct World * world);
19 static void cleanup(struct World * world)
21 if (cleanup_flags & CLEANUP_NCURSES)
25 if (cleanup_flags & CLEANUP_MAP)
27 free(world->map->cells);
29 if (cleanup_flags & CLEANUP_KEYBINDINGS)
32 for (key = 0; key <= world->keyswindata->max; key++)
34 free(world->keybindings[key].name);
36 free(world->keybindings);
37 free(world->keyswindata);
39 if (cleanup_flags & CLEANUP_LOG)
47 extern void set_cleanup_flag(enum cleanup_flag flag)
49 cleanup_flags = cleanup_flags | flag;
54 extern void exit_game(struct World * world)
62 extern void exit_err(uint8_t err, struct World * world, char * msg)
71 msg = "Some error encountered. Aborted.";
74 perror("errno states");