home · contact · privacy
Moved pseudo-random generator into its own library, simplified its interface and...
[plomrogue] / src / misc.h
1 /* misc.h
2  *
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.
5  */
6
7 #ifndef MISC_H
8 #define MISC_H
9
10
11
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 */
15 struct World;
16 struct WinMeta;
17 struct Win;
18 struct Map;
19
20
21
22 /* Reset terminal (end ncurses), clean up memory and exit. */
23 extern void exit_game(struct World * world, struct Map * map);
24
25
26
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.
29  */
30 extern void textfile_sizes(FILE * file, uint16_t * linemax_p,
31                            uint16_t * n_lines_p);
32
33
34
35 /* Update game log by appending "text", or by appending a "." if "text" is the
36  * same as the last one passed.
37  */
38 extern void update_log(struct World * world, char * text);
39
40
41
42 /* Return the offset necessary to center "map" on position "pos" in a frame of
43  * "framesize.
44  */
45 extern uint16_t center_offset(uint16_t pos, uint16_t mapsize,
46                               uint16_t framesize);
47
48
49
50 /* Record last player "action" in game record file "record, increment the game
51  * turn and trigger enemy movement.
52  */
53 extern void turn_over(struct World * world, char action);
54
55
56
57 /* Save current game data to file "savefile". */
58 extern void save_game(struct World * world);
59
60
61
62 /* Toggle display of a window "win". */
63 extern void toggle_window(struct WinMeta * win_meta, struct Win * win);
64
65
66
67 /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"),
68  * subject to the limitations provided by the window manager via
69  * reset_pad_offset().
70  */
71 extern void scroll_pad(struct WinMeta * win_meta, char dir);
72
73
74
75 /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or
76  * vertically ("change = "+"/"-") by one cell size, subject to the limitations
77  * provided by the window manager via resize_active_win().
78  */
79 extern void growshrink_active_window(struct WinMeta * win_meta, char change);
80
81
82
83 /* Return a random position on the map "map" that is passable (as determined by
84  * is_passable().
85  */
86 extern struct yx_uint16 find_passable_pos(struct Map * map);
87
88
89
90 /* Call some meta game / window management actions dependent on key. If the
91  * "quit" action is called, return 1 only instead of doing anything directly.
92  */
93 extern unsigned char meta_keys(int key, struct World * world,
94                                struct WinMeta * win_meta,
95                                struct Win * win_keys,
96                                struct Win * win_map,
97                                struct Win * win_info,
98                                struct Win * win_log);
99
100
101
102 #endif