1 /* src/server/yx_uint8.c */
4 #include <stdint.h> /* uint8_t, int8_t */
5 #include <string.h> /* strchr() */
6 #include "../common/yx_uint8.h" /* yx_uint8 */
10 /* Move "yx" into hex direction "d". */
11 static void mv_yx_in_hex_dir(char d, struct yx_uint8 * yx);
15 static void mv_yx_in_hex_dir(char d, struct yx_uint8 * yx)
19 yx->x = yx->x + (yx->y % 2);
28 yx->x = yx->x + (yx->y % 2);
33 yx->x = yx->x - !(yx->y % 2);
42 yx->x = yx->x - !(yx->y % 2);
49 extern uint8_t mv_yx_in_dir_wrap(char d, struct yx_uint8 * yx, uint8_t unwrap)
51 static int8_t wrap_west_east = 0;
52 static int8_t wrap_north_south = 0;
55 wrap_west_east = wrap_north_south = 0;
58 struct yx_uint8 original;
61 mv_yx_in_hex_dir(d, yx);
62 if (strchr("edc", d) && yx->x < original.x)
66 else if (strchr("xsw", d) && yx->x > original.x)
70 if (strchr("we", d) && yx->y > original.y)
74 else if (strchr("xc", d) && yx->y < original.y)
78 return (wrap_west_east != 0) + (wrap_north_south != 0);