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.
12 #include <stdlib.h> /* for size_t */
13 #include <stdint.h> /* for uint16_t */
14 #include "yx_uint16.h" /* for yx_uint16 coordinates */
20 /* Returns message: "Trouble in ".parent." with ".child."." (try_*() helper) */
21 extern char * trouble_msg(struct World * w, char * parent, char * child);
23 /* Wrappers to malloc(), calloc() from function called "f" calling exit_err()
24 * with trouble_msg() error message if necessary.
26 extern void * try_malloc(size_t size, struct World * w, char * f);
27 extern void * try_calloc(size_t nmemb, size_t size,
28 struct World * w, char * f);
32 /* Check if tempfile "path" exists, and if so, exit with explanation that. */
33 extern void check_tempfile(char * path, struct World * f);
35 /* If one and only one of files at "p1", "p2" exists, fail with explanation. */
36 extern void check_files_xor(char * p1, char * p2, struct World * w);
40 /* Save / load / unload (free) interface configuration data. */
41 extern void save_interface_conf(struct World * world);
42 extern void load_interface_conf(struct World * world);
43 extern void unload_interface_conf(struct World * world);
47 /* Update game log by appending "text", or by appending a "." if "text" is the
48 * same as the last one passed.
50 extern void update_log(struct World * world, char * text);
54 /* Return the offset necessary to center a map of "mapsize" on position "pos" in
55 * a frame of "framesize.
57 extern uint16_t center_offset(uint16_t pos,
58 uint16_t mapsize, uint16_t framesize);
62 /* Record last player "action" in game record file "record, increment the game
63 * turn and trigger enemy movement.
65 extern void turn_over(struct World * world, char action);
69 /* Save or load current game data to / from file "savefile". */
70 extern void save_game(struct World * world);
71 extern void load_game(struct World * world);
75 /* Return a random position on the map "map" that is passable (as determined by
78 extern struct yx_uint16 find_passable_pos(struct Map * map);