1 /* src/server/field_of_view.h
3 * Generate field of view maps.
8 #ifndef FIELD_OF_VIEW_H
9 #define FIELD_OF_VIEW_H
11 #include <stdint.h> /* uint8_t */
16 /* States that cells in the fov map may be in. */
17 enum fov_cell_states {
26 /* Return overlay of world map wherein all cell positions visible from player's
27 * positions have flag VISIBLE set.
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.
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.
42 extern uint8_t * build_fov_map(struct Thing * eye);