home · contact · privacy
ee337eb1d69636d4d95e764c685a94cc02d5e99b
[plomrogue] / src / server / field_of_view.h
1 /* src/server/field_of_view.h
2  *
3  * Generate field of view maps.
4  */
5
6
7
8 #ifndef FIELD_OF_VIEW_H
9 #define FIELD_OF_VIEW_H
10
11 #include <stdint.h> /* uint8_t */
12 struct MapObj;
13
14
15
16 /* States that cells in the fov map may be in. */
17 enum fov_cell_states {
18     VISIBLE      = 0x01,
19     HIDDEN       = 0x02,
20     SHADOW_LEFT  = 0x04,
21     SHADOW_RIGHT = 0x08,
22     LIMIT        = 0x10,
23     HIDE_LATER   = 0x20
24 };
25
26 /* Return overlay of world map wherein all cell positions visible from player's
27  * positions have flag VISIBLE set.
28  *
29  * This is achieved by spiraling out clock-wise from the player position,
30  * flagging cells as VISIBLE unless they're already marked as HIDDEN, and, on
31  * running into obstacles for view that are not HIDDEN, casting shadows from
32  * these, i.e. drawing cells as HIDDEN that would be hidden by said obstacle,
33  * before continuing the original spiraling path.
34  *
35  * Shadowcasting during spiraling is initially lazy, flagging only the shadows'
36  * interior cells as HIDDEN and their border cells as HIDE_LATER. Only at the
37  * end are all cells flagged HIDE_LATER flagged as HIDDEN. This is to handle
38  * cases where obstacles to view sit right at the border of pre-estabilshed
39  * shadows, therefore might be ignored if HIDDEN and not cast shadows on their
40  * own that may slightly extend beyond the pre-established shadows they border.
41  */
42 extern uint8_t * build_fov_map(struct MapObj * eye);
43
44
45
46 #endif