home · contact · privacy
Server: Refactor yx_uint8 moving; handle actors hitting the map edge.
[plomrogue] / src / server / yx_uint8.h
1 /* src/server/yx_uint8.h
2  *
3  * Routines for comparison and movement with yx_uint8 structs.
4  */
5
6 #ifndef YX_UINT8_H_SERVER
7 #define YX_UINT8_H_SERVER
8
9 #include <stdint.h> /* uint8_t */
10 #include "../common/yx_uint8.h" /* yx_uint8 */
11
12
13
14 /* Return 1 if two yx_uint8 coordinates at "a" and "b" are equal, else 0. */
15 extern uint8_t yx_uint8_cmp(struct yx_uint8 * a, struct yx_uint8 * b);
16
17 /* Move "yx" into hex direction "d". If this moves "yx" beyond the minimal (0)
18  * or maximal (UINT8_MAX) column or row, it wraps to the opposite side. Such
19  * wrapping is returned as a wraps enum value and stored, so that further calls
20  * to move "yx" back into the opposite direction may unwrap it again. Pass an
21  * "unwrap" of !0 to re-set the internal wrap memory to 0.
22  * Hex direction values for "d": 'e' (north-east), 'd' (east), 'c' (south-east),
23  * 'x' (south-west), 's' (west), 'w' (north-west)
24  */
25 extern uint8_t mv_yx_in_dir_wrap(char d, struct yx_uint8 * yx, uint8_t unwrap);
26
27
28
29 #endif