3 * Miscellaneous routines that have not yet found a proper parent module. Having
4 * LOTS of stuff in here is a sure sign that better modularization is in order.
10 #include <stdlib.h> /* for size_t */
11 #include <stdint.h> /* for uint16_t */
12 #include "yx_uint16.h" /* for yx_uint16 coordinates */
17 /* Returns message: "Trouble in ".parent." with ".child."." (try_*() helper) */
18 extern char * trouble_msg(char * parent, char * child);
20 /* Wrappers to malloc(), calloc() from function called "f" calling exit_err()
21 * with trouble_msg() error message if necessary.
23 extern void * try_malloc(size_t size, char * f);
24 extern void * try_calloc(size_t nmemb, size_t size, char * f);
28 /* Check if tempfile "path" exists, and if so, exit with explanation that. */
29 extern void check_tempfile(char * path);
31 /* If one and only one of files at "p1", "p2" exists, fail with explanation. */
32 extern void check_files_xor(char * p1, char * p2);
36 /* Save / load / unload (free) / reload interface configuration data. */
37 extern void save_interface_conf();
38 extern void load_interface_conf();
39 extern void unload_interface_conf();
40 extern void reload_interface_conf();
44 /* Update game log by appending "text", or by appending a "." if "text" is the
45 * same as the last one passed.
47 extern void update_log(char * text);
51 /* Return the offset necessary to center a map of "mapsize" on position "pos" in
52 * a frame of "framesize.
54 extern uint16_t center_offset(uint16_t pos,
55 uint16_t mapsize, uint16_t framesize);
59 /* Record last player "action" in game record file "record, increment the game
60 * turn and trigger enemy movement.
62 extern void turn_over(char action);
66 /* Save or load current game data to / from file "savefile". */
67 extern void save_game();
68 extern void load_game();
72 /* Return a random position on the map "map" that is passable (as determined by
75 extern struct yx_uint16 find_passable_pos(struct Map * map);
79 /* Navigate (as far as possible) up (dir=='u') or (else) down in player's
80 * inventory selection.
82 extern void nav_inventory(char dir);