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 /* Update game log by appending "text", or by appending a "." if "text" is the
41 * same as the last one passed.
43 extern void update_log(struct World * world, char * text);
47 /* Return the offset necessary to center "map" on position "pos" in a frame of
50 extern uint16_t center_offset(uint16_t pos, uint16_t mapsize,
55 /* Record last player "action" in game record file "record, increment the game
56 * turn and trigger enemy movement.
58 extern void turn_over(struct World * world, char action);
62 /* Save current game data to file "savefile". */
63 extern void save_game(struct World * world);
67 /* Return a random position on the map "map" that is passable (as determined by
70 extern struct yx_uint16 find_passable_pos(struct Map * map);