else
quit_called = meta_keys(key, &world, &win_meta, &win_keys, &win_map, &win_info, &win_log);
if (1 == quit_called)
- break; } }
+ exit_game(&world, &map); } }
// Interactive mode.
else {
else
quit_called = meta_keys(key, &world, &win_meta, &win_keys, &win_map, &win_info, &win_log);
if (1 == quit_called)
- break; } }
-
- // Clean up and exit.
- free(map.cells);
- for (key = 0; key <= world.keyswindata->max; key++)
- free(world.keybindings[key].name);
- free(world.keybindings);
- free(world.keyswindata);
- free(world.log);
- endwin();
- exit (EXIT_SUCCESS); }
+ exit_game(&world, &map); } } }
#include "main.h"
#include "yx_uint16.h"
+extern void exit_game(struct World * world, struct Map * map) {
+// Clean up and exit.
+ 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) {
// Learn largest line length (linemax_p) and (n_lines_p if not set to NULL) number of lines.
uint16_t n_lines = 0;
struct Win;
struct Map;
+extern void exit_game(struct World *, struct Map *);
extern void textfile_sizes (FILE *, uint16_t *, uint16_t *);
extern uint16_t rrand(char, uint32_t);
extern void update_log (struct World *, char *);