home · contact · privacy
Made game exiting and cleaning up more flexible. Provided so far unused exit-on-error...
[plomrogue] / src / misc.c
index b3240585e2c6dab2ffc81c77192afc8e0e711347..0bb50a76fa4c7831ccfece4f41bab471c30b46ae 100644 (file)
@@ -1,9 +1,8 @@
 /* misc.c */
 
 #include "misc.h"
-#include <stdlib.h> /* for exit(), EXIT_SUCCESS define, calloc(), free() */
+#include <stdlib.h> /* for calloc(), free() */
 #include <string.h> /* for strlen(), strcmp(), memcpy() */
-#include <ncurses.h> /* for endwin() */
 #include "windows.h" /* for suspend_win(), append_win(), reset_pad_offset(),
                       * resize_active_win(), cycle_active_win(),
                       * shift_active_win(), struct Win, struct WinMeta
@@ -13,9 +12,7 @@
                           */
 #include "readwrite.h" /* for write_uint16_bigendian(), write_uint32_bigendian()
                         */
-#include "map_objects.h" /* for struct Monster, write_map_objects(),
-                          * write_map_objects_monsterdata()
-                          */
+#include "map_objects.h" /* for struct Monster, write_map_objects(), */
 #include "map_object_actions.h" /* for is_passable(), move_monster() */
 #include "map.h" /* for map_scroll(),map_center_player(), Map struct,dir enum */
 #include "main.h" /* for World struct */
 
 
 
-extern void exit_game(struct World * world, struct Map * map)
-{
-    endwin();
-    free(map->cells);
-    uint16_t key;
-    for (key = 0; key <= world->keyswindata->max; key++)
-    {
-        free(world->keybindings[key].name);
-    }
-    free(world->keybindings);
-    free(world->keyswindata);
-    free(world->log);
-    exit (EXIT_SUCCESS);
-}
-
-
-
 extern void textfile_sizes(FILE * file, uint16_t * linemax_p,
                            uint16_t * n_lines_p)
 {
@@ -159,8 +139,8 @@ extern void save_game(struct World * world)
     write_uint16_bigendian(world->player->pos.y + 1, file);
     write_uint16_bigendian(world->player->pos.x + 1, file);
     fputc(world->player->hitpoints, file);
-    write_map_objects (world->monster, file, write_map_objects_monsterdata);
-    write_map_objects (world->item, file, NULL);
+    write_map_objects(world, world->monster, file);
+    write_map_objects(world, world->item, file);
     fclose(file);
 }