home · contact · privacy
Improved error handling, more error catching, error messages.
[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 uint8_t, uint16_t */
13 #include <stdio.h>     /* for FILE typedef */
14 #include "yx_uint16.h" /* for yx_uint16 coordinates */
15 struct World;
16 struct Map;
17
18
19
20 /* Learn from "file" the largest line length (pointed to by "linemax_p") and
21  * (pointed to by "n_lines_p" if it is not set to NULL) the number of lines.
22  *
23  * Returns 0 on success, 1 on fseek() error.
24  */
25 extern uint8_t textfile_sizes(FILE * file, uint16_t * linemax_p,
26                               uint16_t * n_lines_p);
27
28
29
30 /* Update game log by appending "text", or by appending a "." if "text" is the
31  * same as the last one passed.
32  */
33 extern void update_log(struct World * world, char * text);
34
35
36
37 /* Return the offset necessary to center "map" on position "pos" in a frame of
38  * "framesize.
39  */
40 extern uint16_t center_offset(uint16_t pos, uint16_t mapsize,
41                               uint16_t framesize);
42
43
44
45 /* Record last player "action" in game record file "record, increment the game
46  * turn and trigger enemy movement.
47  */
48 extern void turn_over(struct World * world, char action);
49
50
51
52 /* Save current game data to file "savefile". */
53 extern void save_game(struct World * world);
54
55
56
57 /* Return a random position on the map "map" that is passable (as determined by
58  * is_passable().
59  */
60 extern struct yx_uint16 find_passable_pos(struct Map * map);
61
62
63
64 #endif