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 <stdint.h> /* for uint16_t, uint32_t */
13 #include <stdio.h> /* for FILE typedef */
14 #include "yx_uint16.h" /* for yx_uint16 coordinates */
22 /* Reset terminal (end ncurses), clean up memory and exit. */
23 extern void exit_game(struct World * world, struct Map * map);
27 /* Learn from "file" the largest line length (pointed to by "linemax_p") and
28 * (pointed to by "n_lines_p" if it is not set to NULL) the number of lines.
30 extern void textfile_sizes(FILE * file, uint16_t * linemax_p,
31 uint16_t * n_lines_p);
35 /* Pseudo-random number generator using a Linear Congruential Generator
36 * algorithm with some proven constants. Used instead of rand() to ensure
37 * portable pseudo-randomness predictability. Set "use_seed" to !0 to seed it
40 * TODO: Write a wrapper for all non-seeding uses that demands no input.
42 extern uint16_t rrand(char use_seed, uint32_t new_seed);
46 /* Update game log by appending "text", or by appending a "." if "text" is the
47 * same as the last one passed.
49 extern void update_log(struct World * world, char * text);
53 /* Return the offset necessary to center "map" on position "pos" in a frame of
56 extern uint16_t center_offset(uint16_t pos, uint16_t mapsize,
61 /* Record last player "action" in game record file "record, increment the game
62 * turn and trigger enemy movement.
64 extern void turn_over(struct World * world, char action);
68 /* Save current game data to file "savefile". */
69 extern void save_game(struct World * world);
73 /* Toggle display of a window "win". */
74 extern void toggle_window(struct WinMeta * win_meta, struct Win * win);
78 /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
79 * subject to the limitations provided by the window manager via
82 extern void scroll_pad(struct WinMeta * win_meta, char dir);
86 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
87 * vertically ("change = "+"/"-") by one cell size, subject to the limitations
88 * provided by the window manager via resize_active_win().
90 extern void growshrink_active_window(struct WinMeta * win_meta, char change);
94 /* Return a random position on the map "map" that is passable (as determined by
97 extern struct yx_uint16 find_passable_pos(struct Map * map);
101 /* Call some meta game / window management actions dependent on key. If the
102 * "quit" action is called, return 1 only instead of doing anything directly.
104 extern unsigned char meta_keys(int key, struct World * world,
105 struct WinMeta * win_meta,
106 struct Win * win_keys,
107 struct Win * win_map,
108 struct Win * win_info,
109 struct Win * win_log);