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 /* Return 16-bit number pseudo-randomly generated via Linear Congruential
18 * Generator algorithm with some proven constants. Use instead of rand() to
19 * ensure portability of the same pseudo-randomness across systems.
21 extern uint16_t rrand();
23 /* Wrappers to malloc(), calloc() from function "f"; exit_trouble() on error. */
24 extern void * try_malloc(size_t size, char * f);
25 extern void * try_calloc(size_t nmemb, size_t size, char * f);
27 /* If one and only one of files at "p1", "p2" exists, fail with explanation. */
28 extern void check_files_xor(char * p1, char * p2);
30 /* Check if tempfile "path" exists, and if so, exit with explanation that. */
31 extern void check_tempfile(char * path);
33 /* Save / load / unload (free) / reload interface configuration data. */
34 extern void save_interface_conf();
35 extern void load_interface_conf();
36 extern void unload_interface_conf();
37 extern void reload_interface_conf();
39 /* Append "text" to game log, or a "." if "text" is the same as the last one. */
40 extern void update_log(char * text);
42 /* Return offset nto center map of "mapsize" on "position" in "framesize". */
43 extern uint16_t center_offset(uint16_t position,
44 uint16_t mapsize, uint16_t framesize);
46 /* Record "action" in record file, do all movements until player's next turn. */
47 extern void turn_over(char action);
49 /* Save or load current game data to / from file "savefile". */
50 extern void save_game();
51 extern void load_game();
53 /* Return random passable (as by is_passable()) position on "map". */
54 extern struct yx_uint16 find_passable_pos(struct Map * map);
56 /* Move world.inventory_sel up ("dir"="u") or down (else) as far as possible. */
57 extern void nav_inventory(char dir);