1 /* src/server/cleanup.c */
4 #include <stdint.h> /* uint32_t */
5 #include <stdlib.h> /* free() */
6 #include <unistd.h> /* unlink() */
7 #include "map_object_actions.h" /* free_map_object_actions() */
8 #include "map_objects.h" /* free_map_objects(), free_map_object_defs() */
9 #include "world.h" /* global world */
13 /* The clean-up flags set by set_cleanup_flag(). */
14 static uint32_t cleanup_flags = 0x0000;
22 free(world.map.cells);
23 if (cleanup_flags & CLEANUP_OUTFILE)
25 unlink(world.path_out);
27 if (cleanup_flags & CLEANUP_MAP_OBJECTS)
29 free_map_objects(world.map_objs);
31 if (cleanup_flags & CLEANUP_MAP_OBJECT_DEFS)
33 free_map_object_defs(world.map_obj_defs);
35 if (cleanup_flags & CLEANUP_MAP_OBJECT_ACTS)
37 free_map_object_actions(world.map_obj_acts);
39 if (cleanup_flags & CLEANUP_FIFO) /* Fifo also serves as lockfile that */
40 { /* affirms the running of a server */
41 unlink(world.path_in); /* instance. Therefore it should be */
42 } /* the last thing to be deleted. */
46 extern void set_cleanup_flag(enum cleanup_flag flag)
48 cleanup_flags = cleanup_flags | flag;