world.monster = 0;
world.item = 0;
init_map_object_defs(&world, "config/defs");
+ set_cleanup_flag(CLEANUP_MAP_OBJECT_DEFS);
+ exit_err(1, &world, NULL);
/* For interactive mode, try to load world state from savefile. */
char * err_o = "Trouble loading game (fopen() in main()) / "
+extern void free_item_defs(struct ItemDef * id_start)
+{
+ if (0 != id_start->map_obj_def.next)
+ {
+ free_item_defs((struct ItemDef *) id_start->map_obj_def.next);
+ }
+ free(id_start->map_obj_def.desc);
+ free(id_start);
+}
+
+
+
+
+extern void free_monster_defs(struct MonsterDef * md_start)
+{
+ if (0 != md_start->map_obj_def.next)
+ {
+ free_monster_defs((struct MonsterDef *) md_start->map_obj_def.next);
+ }
+ free(md_start->map_obj_def.desc);
+ free(md_start);
+}
+
+
+
extern uint8_t write_map_objects(struct World * world, void * start,
FILE * file)
{
+/* Free item / monster definitions in map object chain starting at "md_start" /
+ * "id_start".
+ */
+extern void free_item_defs(struct ItemDef * id_start);
+extern void free_monster_defs(struct MonsterDef * md_start);
+
+
+
/* Build into memory starting at "start" chain of "n" map objects of type
* "def_id".
*/
#include "keybindings.h" /* for KeysWinData, KeyBinding structs */
#include "command_db.h" /* for free_command_db() */
#include "windows.h" /* for Win struct, free_win() */
+#include "map_objects.h" /* for free_item_defs(), free_monster_defs() */
{
free_win(world->wins.keys);
}
+ if (cleanup_flags & CLEANUP_MAP_OBJECT_DEFS)
+ {
+ free_item_defs(world->item_def);
+ free_monster_defs(world->monster_def);
+ }
}
*/
enum cleanup_flag
{
- CLEANUP_NCURSES = 0x0001,
- CLEANUP_MAP = 0x0002,
- CLEANUP_KEYBINDINGS = 0x0004,
- CLEANUP_LOG = 0x0008,
- CLEANUP_COMMAND_DB = 0x0010,
- CLEANUP_WIN_INFO = 0x0020,
- CLEANUP_WIN_LOG = 0x0040,
- CLEANUP_WIN_MAP = 0x0080,
- CLEANUP_WIN_KEYS = 0x0100
+ CLEANUP_NCURSES = 0x0001,
+ CLEANUP_MAP = 0x0002,
+ CLEANUP_KEYBINDINGS = 0x0004,
+ CLEANUP_LOG = 0x0008,
+ CLEANUP_COMMAND_DB = 0x0010,
+ CLEANUP_MAP_OBJECT_DEFS = 0x0020,
+ CLEANUP_WIN_INFO = 0x0040,
+ CLEANUP_WIN_LOG = 0x0080,
+ CLEANUP_WIN_MAP = 0x0100,
+ CLEANUP_WIN_KEYS = 0x0200
};
extern void set_cleanup_flag(enum cleanup_flag flag);