author | truebrain |
Thu, 12 Jun 2008 21:07:25 +0000 | |
branch | noai |
changeset 10943 | 5f5a5dd407d8 |
parent 9732 | f8eb3e208514 |
permissions | -rw-r--r-- |
9723 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file track_type.h All types related to tracks */ |
|
4 |
||
5 |
#ifndef TRACK_TYPE_H |
|
6 |
#define TRACK_TYPE_H |
|
7 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
8 |
#include "core/enum_type.hpp" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
9 |
|
9723 | 10 |
/** |
11 |
* These are used to specify a single track. |
|
12 |
* Can be translated to a trackbit with TrackToTrackbit |
|
13 |
*/ |
|
14 |
enum Track { |
|
15 |
TRACK_BEGIN = 0, ///< Used for iterations |
|
16 |
TRACK_X = 0, ///< Track along the x-axis (north-east to south-west) |
|
17 |
TRACK_Y = 1, ///< Track along the y-axis (north-west to south-east) |
|
18 |
TRACK_UPPER = 2, ///< Track in the upper corner of the tile (north) |
|
19 |
TRACK_LOWER = 3, ///< Track in the lower corner of the tile (south) |
|
20 |
TRACK_LEFT = 4, ///< Track in the left corner of the tile (west) |
|
21 |
TRACK_RIGHT = 5, ///< Track in the right corner of the tile (east) |
|
22 |
TRACK_END, ///< Used for iterations |
|
23 |
INVALID_TRACK = 0xFF ///< Flag for an invalid track |
|
24 |
}; |
|
25 |
||
26 |
/** Allow incrementing of Track variables */ |
|
27 |
DECLARE_POSTFIX_INCREMENT(Track); |
|
28 |
/** Define basic enum properties */ |
|
29 |
template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK> {}; |
|
30 |
typedef TinyEnumT<Track> TrackByte; |
|
31 |
||
32 |
||
33 |
/** Bitfield corresponding to Track */ |
|
34 |
enum TrackBits { |
|
35 |
TRACK_BIT_NONE = 0U, ///< No track |
|
36 |
TRACK_BIT_X = 1U << TRACK_X, ///< X-axis track |
|
37 |
TRACK_BIT_Y = 1U << TRACK_Y, ///< Y-axis track |
|
38 |
TRACK_BIT_UPPER = 1U << TRACK_UPPER, ///< Upper track |
|
39 |
TRACK_BIT_LOWER = 1U << TRACK_LOWER, ///< Lower track |
|
40 |
TRACK_BIT_LEFT = 1U << TRACK_LEFT, ///< Left track |
|
41 |
TRACK_BIT_RIGHT = 1U << TRACK_RIGHT, ///< Right track |
|
42 |
TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y, ///< X-Y-axis cross |
|
43 |
TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER, ///< Upper and lower track |
|
44 |
TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT, ///< Left and right track |
|
45 |
TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,///< "Arrow" to the north-east |
|
46 |
TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,///< "Arrow" to the south-east |
|
47 |
TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT, ///< "Arrow" to the south-west |
|
48 |
TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT, ///< "Arrow" to the north-west |
|
49 |
TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT, ///< All possible tracks |
|
50 |
TRACK_BIT_MASK = 0x3FU, ///< Bitmask for the first 6 bits |
|
51 |
TRACK_BIT_WORMHOLE = 0x40U, ///< Bitflag for a wormhole (used for tunnels) |
|
52 |
TRACK_BIT_DEPOT = 0x80U, ///< Bitflag for a depot |
|
53 |
INVALID_TRACK_BIT = 0xFF ///< Flag for an invalid trackbits value |
|
54 |
}; |
|
55 |
||
56 |
/** Define basic enum properties */ |
|
57 |
template <> struct EnumPropsT<TrackBits> : MakeEnumPropsT<TrackBits, byte, TRACK_BIT_NONE, TRACK_BIT_ALL, INVALID_TRACK_BIT> {}; |
|
58 |
typedef TinyEnumT<TrackBits> TrackBitsByte; |
|
59 |
||
60 |
DECLARE_ENUM_AS_BIT_SET(TrackBits); |
|
61 |
||
62 |
/** |
|
63 |
* Enumeration for tracks and directions. |
|
64 |
* |
|
65 |
* These are a combination of tracks and directions. Values are 0-5 in one |
|
66 |
* direction (corresponding to the Track enum) and 8-13 in the other direction. |
|
67 |
* 6, 7, 14 and 15 are used to encode the reversing of road vehicles. Those |
|
68 |
* reversing track dirs are not considered to be 'valid' except in a small |
|
69 |
* corner in the road vehicle controller. |
|
70 |
*/ |
|
71 |
enum Trackdir { |
|
72 |
TRACKDIR_BEGIN = 0, ///< Used for iterations |
|
73 |
TRACKDIR_X_NE = 0, ///< X-axis and direction to north-east |
|
74 |
TRACKDIR_Y_SE = 1, ///< Y-axis and direction to south-east |
|
75 |
TRACKDIR_UPPER_E = 2, ///< Upper track and direction to east |
|
76 |
TRACKDIR_LOWER_E = 3, ///< Lower track and direction to east |
|
77 |
TRACKDIR_LEFT_S = 4, ///< Left track and direction to south |
|
78 |
TRACKDIR_RIGHT_S = 5, ///< Right track and direction to south |
|
79 |
TRACKDIR_RVREV_NE = 6, ///< (Road vehicle) reverse direction north-east |
|
80 |
TRACKDIR_RVREV_SE = 7, ///< (Road vehicle) reverse direction south-east |
|
81 |
TRACKDIR_X_SW = 8, ///< X-axis and direction to south-west |
|
82 |
TRACKDIR_Y_NW = 9, ///< Y-axis and direction to north-west |
|
83 |
TRACKDIR_UPPER_W = 10, ///< Upper track and direction to west |
|
84 |
TRACKDIR_LOWER_W = 11, ///< Lower track and direction to west |
|
85 |
TRACKDIR_LEFT_N = 12, ///< Left track and direction to north |
|
86 |
TRACKDIR_RIGHT_N = 13, ///< Right track and direction to north |
|
87 |
TRACKDIR_RVREV_SW = 14, ///< (Road vehicle) reverse direction south-west |
|
88 |
TRACKDIR_RVREV_NW = 15, ///< (Road vehicle) reverse direction north-west |
|
89 |
TRACKDIR_END, ///< Used for iterations |
|
90 |
INVALID_TRACKDIR = 0xFF, ///< Flag for an invalid trackdir |
|
91 |
}; |
|
92 |
||
93 |
/** Define basic enum properties */ |
|
94 |
template <> struct EnumPropsT<Trackdir> : MakeEnumPropsT<Trackdir, byte, TRACKDIR_BEGIN, TRACKDIR_END, INVALID_TRACKDIR> {}; |
|
95 |
typedef TinyEnumT<Trackdir> TrackdirByte; |
|
96 |
||
97 |
/** |
|
98 |
* Enumeration of bitmasks for the TrackDirs |
|
99 |
* |
|
100 |
* These are a combination of tracks and directions. Values are 0-5 in one |
|
101 |
* direction (corresponding to the Track enum) and 8-13 in the other direction. |
|
102 |
*/ |
|
103 |
enum TrackdirBits { |
|
104 |
TRACKDIR_BIT_NONE = 0x0000, ///< No track build |
|
105 |
TRACKDIR_BIT_X_NE = 0x0001, ///< Track x-axis, direction north-east |
|
106 |
TRACKDIR_BIT_Y_SE = 0x0002, ///< Track y-axis, direction south-east |
|
107 |
TRACKDIR_BIT_UPPER_E = 0x0004, ///< Track upper, direction east |
|
108 |
TRACKDIR_BIT_LOWER_E = 0x0008, ///< Track lower, direction east |
|
109 |
TRACKDIR_BIT_LEFT_S = 0x0010, ///< Track left, direction south |
|
110 |
TRACKDIR_BIT_RIGHT_S = 0x0020, ///< Track right, direction south |
|
111 |
/* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */ |
|
112 |
TRACKDIR_BIT_X_SW = 0x0100, ///< Track x-axis, direction south-west |
|
113 |
TRACKDIR_BIT_Y_NW = 0x0200, ///< Track y-axis, direction north-west |
|
114 |
TRACKDIR_BIT_UPPER_W = 0x0400, ///< Track upper, direction west |
|
115 |
TRACKDIR_BIT_LOWER_W = 0x0800, ///< Track lower, direction west |
|
116 |
TRACKDIR_BIT_LEFT_N = 0x1000, ///< Track left, direction north |
|
117 |
TRACKDIR_BIT_RIGHT_N = 0x2000, ///< Track right, direction north |
|
118 |
TRACKDIR_BIT_MASK = 0x3F3F, ///< Bitmask for bit-operations |
|
119 |
INVALID_TRACKDIR_BIT = 0xFFFF, ///< Flag for an invalid trackdirbit value |
|
120 |
}; |
|
121 |
||
122 |
/** Define basic enum properties */ |
|
123 |
template <> struct EnumPropsT<TrackdirBits> : MakeEnumPropsT<TrackdirBits, uint16, TRACKDIR_BIT_NONE, TRACKDIR_BIT_MASK, INVALID_TRACKDIR_BIT> {}; |
|
124 |
typedef TinyEnumT<TrackdirBits> TrackdirBitsShort; |
|
125 |
DECLARE_ENUM_AS_BIT_SET(TrackdirBits); |
|
126 |
||
9732 | 127 |
typedef uint32 TrackStatus; |
128 |
||
9723 | 129 |
#endif /* TRACK_TYPE_H */ |