fix regression: enemy soldiers fired in wrong direction
[rofl0r-openDOW.git] / direction.h
blobf6a874b8b8a00d0355d84e6592db096f60600a07
1 #ifndef DIRECTION_H
2 #define DIRECTION_H
4 enum __attribute__ ((__packed__)) direction {
5 DIR_N = 0,
6 DIR_NW,
7 DIR_W,
8 DIR_SW,
9 DIR_S,
10 DIR_SO,
11 DIR_O,
12 DIR_NO,
13 DIR_MAX,
14 DIR_INVALID = DIR_MAX
17 static inline const char* dir_name(enum direction dir) {
18 #define DIRNAME(a) [ a ] = #a
19 static const char* dir_names[] = {
20 DIRNAME(DIR_N),
21 DIRNAME(DIR_NW),
22 DIRNAME(DIR_W),
23 DIRNAME(DIR_SW),
24 DIRNAME(DIR_S),
25 DIRNAME(DIR_SO),
26 DIRNAME(DIR_O),
27 DIRNAME(DIR_NO),
29 #undef DIRNAME
30 return dir_names[dir];
33 enum __attribute__ ((__packed__)) direction_bits {
34 DIRB_INVALID = 0,
35 DIRB_N = 1 << 0,
36 DIRB_S = 1 << 1,
37 DIRB_O = 1 << 2,
38 DIRB_W = 1 << 3,
39 DIRB_NW = DIRB_N | DIRB_W,
40 DIRB_SW = DIRB_S | DIRB_W,
41 DIRB_SO = DIRB_S | DIRB_O,
42 DIRB_NO = DIRB_N | DIRB_O,
45 extern const enum direction_bits direction_directionbit_lut[];
46 extern const enum direction directionbit_direction_lut[];
47 #define direction_to_directionbit(dir) direction_directionbit_lut[dir]
48 #define directionbit_to_direction(db) direction_directionbit_lut[db]
50 enum __attribute__ ((__packed__)) direction16 {
51 DIR16_N = 0,
52 DIR16_NNW,
53 DIR16_NW,
54 DIR16_WNW,
55 DIR16_W,
56 DIR16_WSW,
57 DIR16_SW,
58 DIR16_SSW,
59 DIR16_S,
60 DIR16_SSO,
61 DIR16_SO,
62 DIR16_OSO,
63 DIR16_O,
64 DIR16_ONO,
65 DIR16_NO,
66 DIR16_NNO,
67 DIR16_MAX,
68 DIR16_INVALID = DIR16_MAX
71 //RcB: DEP "direction.c"
73 #endif