Remove second template parameter from class GUIList
[openttd/fttd.git] / src / track_type.h
blobedf75a06c1201d24cd4c23b2a3cf1b9ad0dcfc23
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file track_type.h All types related to tracks */
12 #ifndef TRACK_TYPE_H
13 #define TRACK_TYPE_H
15 #include "core/enum_type.hpp"
17 /**
18 * These are used to specify a single track.
19 * Can be translated to a trackbit with TrackToTrackbit
21 enum Track {
22 TRACK_BEGIN = 0, ///< Used for iterations
23 TRACK_X = 0, ///< Track along the x-axis (north-east to south-west)
24 TRACK_Y = 1, ///< Track along the y-axis (north-west to south-east)
25 TRACK_UPPER = 2, ///< Track in the upper corner of the tile (north)
26 TRACK_LOWER = 3, ///< Track in the lower corner of the tile (south)
27 TRACK_LEFT = 4, ///< Track in the left corner of the tile (west)
28 TRACK_RIGHT = 5, ///< Track in the right corner of the tile (east)
29 TRACK_END, ///< Used for iterations
30 INVALID_TRACK = 0xFF, ///< Flag for an invalid track
33 /** Allow incrementing of Track variables */
34 DECLARE_POSTFIX_INCREMENT(Track)
35 /** Define basic enum properties */
36 template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK, 3> {};
37 typedef TinyEnumT<Track> TrackByte;
40 /** Bitfield corresponding to Track */
41 enum TrackBits {
42 TRACK_BIT_NONE = 0U, ///< No track
43 TRACK_BIT_X = 1U << TRACK_X, ///< X-axis track
44 TRACK_BIT_Y = 1U << TRACK_Y, ///< Y-axis track
45 TRACK_BIT_UPPER = 1U << TRACK_UPPER, ///< Upper track
46 TRACK_BIT_LOWER = 1U << TRACK_LOWER, ///< Lower track
47 TRACK_BIT_LEFT = 1U << TRACK_LEFT, ///< Left track
48 TRACK_BIT_RIGHT = 1U << TRACK_RIGHT, ///< Right track
49 TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y, ///< X-Y-axis cross
50 TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER, ///< Upper and lower track
51 TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT, ///< Left and right track
52 TRACK_BIT_LOWER_RIGHT = TRACK_BIT_LOWER | TRACK_BIT_RIGHT, ///< Lower and right track
53 TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,///< "Arrow" to the north-east
54 TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,///< "Arrow" to the south-east
55 TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT, ///< "Arrow" to the south-west
56 TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT, ///< "Arrow" to the north-west
57 TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT, ///< All possible tracks
58 TRACK_BIT_MASK = 0x3FU, ///< Bitmask for the first 6 bits
59 INVALID_TRACK_BIT = 0xFF, ///< Flag for an invalid trackbits value
61 DECLARE_ENUM_AS_BIT_SET(TrackBits)
62 typedef SimpleTinyEnumT<TrackBits, byte> TrackBitsByte;
64 /**
65 * Enumeration for tracks and directions.
67 * These are a combination of tracks and directions. Values are 0-5 in one
68 * direction (corresponding to the Track enum) and 8-13 in the other direction.
69 * 6, 7, 14 and 15 are used to encode the reversing of road vehicles. Those
70 * reversing track dirs are not considered to be 'valid' except in a small
71 * corner in the road vehicle controller.
73 enum Trackdir {
74 TRACKDIR_BEGIN = 0, ///< Used for iterations
75 TRACKDIR_X_NE = 0, ///< X-axis and direction to north-east
76 TRACKDIR_Y_SE = 1, ///< Y-axis and direction to south-east
77 TRACKDIR_UPPER_E = 2, ///< Upper track and direction to east
78 TRACKDIR_LOWER_E = 3, ///< Lower track and direction to east
79 TRACKDIR_LEFT_S = 4, ///< Left track and direction to south
80 TRACKDIR_RIGHT_S = 5, ///< Right track and direction to south
81 TRACKDIR_RVREV_NE = 6, ///< (Road vehicle) reverse direction north-east
82 TRACKDIR_RVREV_SE = 7, ///< (Road vehicle) reverse direction south-east
83 TRACKDIR_X_SW = 8, ///< X-axis and direction to south-west
84 TRACKDIR_Y_NW = 9, ///< Y-axis and direction to north-west
85 TRACKDIR_UPPER_W = 10, ///< Upper track and direction to west
86 TRACKDIR_LOWER_W = 11, ///< Lower track and direction to west
87 TRACKDIR_LEFT_N = 12, ///< Left track and direction to north
88 TRACKDIR_RIGHT_N = 13, ///< Right track and direction to north
89 TRACKDIR_RVREV_SW = 14, ///< (Road vehicle) reverse direction south-west
90 TRACKDIR_RVREV_NW = 15, ///< (Road vehicle) reverse direction north-west
91 TRACKDIR_END, ///< Used for iterations
92 TRACKDIR_WORMHOLE = 0x40U, ///< (Train, Ship) in a wormhole
93 TRACKDIR_DEPOT = 0x80U, ///< (Train, Ship) in a depot
94 INVALID_TRACKDIR = 0xFF, ///< Flag for an invalid trackdir
97 /** Define basic enum properties */
98 template <> struct EnumPropsT<Trackdir> : MakeEnumPropsT<Trackdir, byte, TRACKDIR_BEGIN, TRACKDIR_END, INVALID_TRACKDIR, 4> {};
99 typedef TinyEnumT<Trackdir> TrackdirByte;
102 * Enumeration of bitmasks for the TrackDirs
104 * These are a combination of tracks and directions. Values are 0-5 in one
105 * direction (corresponding to the Track enum) and 8-13 in the other direction.
107 enum TrackdirBits {
108 TRACKDIR_BIT_NONE = 0x0000, ///< No track build
109 TRACKDIR_BIT_X_NE = 0x0001, ///< Track x-axis, direction north-east
110 TRACKDIR_BIT_Y_SE = 0x0002, ///< Track y-axis, direction south-east
111 TRACKDIR_BIT_UPPER_E = 0x0004, ///< Track upper, direction east
112 TRACKDIR_BIT_LOWER_E = 0x0008, ///< Track lower, direction east
113 TRACKDIR_BIT_LEFT_S = 0x0010, ///< Track left, direction south
114 TRACKDIR_BIT_RIGHT_S = 0x0020, ///< Track right, direction south
115 /* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
116 TRACKDIR_BIT_X_SW = 0x0100, ///< Track x-axis, direction south-west
117 TRACKDIR_BIT_Y_NW = 0x0200, ///< Track y-axis, direction north-west
118 TRACKDIR_BIT_UPPER_W = 0x0400, ///< Track upper, direction west
119 TRACKDIR_BIT_LOWER_W = 0x0800, ///< Track lower, direction west
120 TRACKDIR_BIT_LEFT_N = 0x1000, ///< Track left, direction north
121 TRACKDIR_BIT_RIGHT_N = 0x2000, ///< Track right, direction north
122 TRACKDIR_BIT_MASK = 0x3F3F, ///< Bitmask for bit-operations
123 INVALID_TRACKDIR_BIT = 0xFFFF, ///< Flag for an invalid trackdirbit value
125 DECLARE_ENUM_AS_BIT_SET(TrackdirBits)
126 typedef SimpleTinyEnumT<TrackdirBits, uint16> TrackdirBitsShort;
128 typedef uint32 TrackStatus;
130 #endif /* TRACK_TYPE_H */