home · contact · privacy
MAJOR re-write. Split plomrogue into a server and a client. Re-wrote large parts
[plomrogue] / src / client / cleanup.c
1 /* src/client/cleanup.c */
2
3 #include "cleanup.h"
4 #include <stdint.h> /* uint32_t */
5 #include <stdlib.h> /* free() */
6 #include "command_db.h" /* free_command_db() */
7 #include "misc.h" /* unload_interface_conf() */
8 #include "windows.h" /* free_winmeta_and_endwin() */
9 #include "world.h" /* world global */
10
11
12
13 /* The clean-up flags set by set_cleanup_flag(). */
14 static uint32_t cleanup_flags = 0x0000;
15
16
17
18 extern void cleanup()
19 {
20     free(world.map.cells);
21     free(world.log);
22     free(world.player_inventory);
23     if (cleanup_flags & CLEANUP_INTERFACE)/* Must come pre ncurses cleanup,   */
24     {                                     /* for by closing all windows it    */
25         unload_interface_conf();          /* relies on world.wmeta data freed */
26     }                                     /* by free_winmeta_and_endwin().    */
27     if (cleanup_flags & CLEANUP_NCURSES)
28     {
29         free_winmeta_and_endwin();
30     }
31     if (cleanup_flags & CLEANUP_COMMANDS)
32     {
33         free_command_db();
34     }
35 }
36
37
38 extern void set_cleanup_flag(enum cleanup_flag flag)
39 {
40     cleanup_flags = cleanup_flags | flag;
41 }