home · contact · privacy
Add "look" mode to query things on any cell via new THINGS_HERE command.
[plomrogue] / src / client / cleanup.c
1 /* src/client/cleanup.c
2  *
3  * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
4  * or any later version. For details on its copyright, license, and warranties,
5  * see the file NOTICE in the root directory of the PlomRogue source package.
6  */
7
8 #include "cleanup.h"
9 #include <ncurses.h> /* for endwin() */
10 #include <stdint.h> /* uint32_t */
11 #include <stdlib.h> /* free() */
12 #include "../common/readwrite.h" /* try_fclose() */
13 #include "command_db.h" /* free_command_db() */
14 #include "interface_conf.h" /* unload_interface_conf() */
15 #include "world.h" /* world global */
16
17
18
19 /* The clean-up flags set by set_cleanup_flag(). */
20 static uint32_t cleanup_flags = 0x0000;
21
22
23
24 extern void cleanup()
25 {
26     free(world.map.cells);
27     free(world.mem_map);
28     free(world.log);
29     free(world.things_here);
30     free(world.queue);
31     free(world.player_inventory);
32     if (cleanup_flags & CLEANUP_INTERFACE)
33     {
34         unload_interface_conf();
35     }
36     if (cleanup_flags & CLEANUP_NCURSES)
37     {
38         endwin();
39     }
40     if (cleanup_flags & CLEANUP_COMMANDS)
41     {
42         free_command_db();
43     }
44     if (cleanup_flags & CLEANUP_SERVER_IN)
45     {
46         try_fclose(world.file_server_in, __func__);
47     }
48     if (cleanup_flags & CLEANUP_SERVER_OUT)
49     {
50         try_fclose(world.file_server_out, __func__);
51     }
52 }
53
54
55 extern void set_cleanup_flag(enum cleanup_flag flag)
56 {
57     cleanup_flags = cleanup_flags | flag;
58 }