OpenTTD Source: src/track_type.h Source File

OpenTTD Source 14.0-RC3

track_type.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #ifndef TRACK_TYPE_H
11 #define TRACK_TYPE_H
12
13 #include "core/enum_type.hpp"
14
19 enum Track : byte {
20 TRACK_BEGIN = 0,
21 TRACK_X = 0,
22 TRACK_Y = 1,
23 TRACK_UPPER = 2,
24 TRACK_LOWER = 3,
25 TRACK_LEFT = 4,
26 TRACK_RIGHT = 5,
27 TRACK_END,
28 INVALID_TRACK = 0xFF,
29 };
30
32 DECLARE_POSTFIX_INCREMENT(Track)
33
34
35 enum TrackBits : byte {
36 TRACK_BIT_NONE = 0U,
37 TRACK_BIT_X = 1U << TRACK_X,
38 TRACK_BIT_Y = 1U << TRACK_Y,
39 TRACK_BIT_UPPER = 1U << TRACK_UPPER,
40 TRACK_BIT_LOWER = 1U << TRACK_LOWER,
41 TRACK_BIT_LEFT = 1U << TRACK_LEFT,
42 TRACK_BIT_RIGHT = 1U << TRACK_RIGHT,
43 TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y,
44 TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER,
45 TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT,
46 TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,
47 TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,
48 TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT,
49 TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT,
50 TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT,
51 TRACK_BIT_MASK = 0x3FU,
52 TRACK_BIT_WORMHOLE = 0x40U,
53 TRACK_BIT_DEPOT = 0x80U,
54 INVALID_TRACK_BIT = 0xFF,
55 };
56 DECLARE_ENUM_AS_BIT_SET(TrackBits)
57
58
67 enum Trackdir : byte {
68 TRACKDIR_BEGIN = 0,
69 TRACKDIR_X_NE = 0,
70 TRACKDIR_Y_SE = 1,
71 TRACKDIR_UPPER_E = 2,
72 TRACKDIR_LOWER_E = 3,
73 TRACKDIR_LEFT_S = 4,
74 TRACKDIR_RIGHT_S = 5,
75 TRACKDIR_RVREV_NE = 6,
76 TRACKDIR_RVREV_SE = 7,
77 TRACKDIR_X_SW = 8,
78 TRACKDIR_Y_NW = 9,
79 TRACKDIR_UPPER_W = 10,
80 TRACKDIR_LOWER_W = 11,
81 TRACKDIR_LEFT_N = 12,
82 TRACKDIR_RIGHT_N = 13,
83 TRACKDIR_RVREV_SW = 14,
84 TRACKDIR_RVREV_NW = 15,
85 TRACKDIR_END,
86 INVALID_TRACKDIR = 0xFF,
87 };
88
90 DECLARE_POSTFIX_INCREMENT(Trackdir)
91
92
98 enum TrackdirBits : uint16_t {
99 TRACKDIR_BIT_NONE = 0U,
100 TRACKDIR_BIT_X_NE = 1U << TRACKDIR_X_NE,
101 TRACKDIR_BIT_Y_SE = 1U << TRACKDIR_Y_SE,
102 TRACKDIR_BIT_UPPER_E = 1U << TRACKDIR_UPPER_E,
103 TRACKDIR_BIT_LOWER_E = 1U << TRACKDIR_LOWER_E,
104 TRACKDIR_BIT_LEFT_S = 1U << TRACKDIR_LEFT_S,
105 TRACKDIR_BIT_RIGHT_S = 1U << TRACKDIR_RIGHT_S,
106 /* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
107 TRACKDIR_BIT_X_SW = 1U << TRACKDIR_X_SW,
108 TRACKDIR_BIT_Y_NW = 1U << TRACKDIR_Y_NW,
109 TRACKDIR_BIT_UPPER_W = 1U << TRACKDIR_UPPER_W,
110 TRACKDIR_BIT_LOWER_W = 1U << TRACKDIR_LOWER_W,
111 TRACKDIR_BIT_LEFT_N = 1U << TRACKDIR_LEFT_N,
112 TRACKDIR_BIT_RIGHT_N = 1U << TRACKDIR_RIGHT_N,
113 TRACKDIR_BIT_MASK = 0x3F3F,
114 INVALID_TRACKDIR_BIT = 0xFFFF,
115 };
116 DECLARE_ENUM_AS_BIT_SET(TrackdirBits)
117
118 typedef uint32_t TrackStatus;
119
120 #endif /* TRACK_TYPE_H */
TRACKDIR_RVREV_SW
@ TRACKDIR_RVREV_SW
(Road vehicle) reverse direction south-west
Definition: track_type.h:83
TRACK_BIT_MASK
@ TRACK_BIT_MASK
Bitmask for the first 6 bits.
Definition: track_type.h:51
TRACK_BIT_WORMHOLE
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
Definition: track_type.h:52
TRACK_BIT_NONE
@ TRACK_BIT_NONE
No track.
Definition: track_type.h:36
TRACK_BIT_3WAY_SW
@ TRACK_BIT_3WAY_SW
"Arrow" to the south-west
Definition: track_type.h:48
TRACKDIR_LOWER_E
@ TRACKDIR_LOWER_E
Lower track and direction to east.
Definition: track_type.h:72
TRACKDIR_RIGHT_S
@ TRACKDIR_RIGHT_S
Right track and direction to south.
Definition: track_type.h:74
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition: track_type.h:24
TRACK_BEGIN
@ TRACK_BEGIN
Used for iterations.
Definition: track_type.h:20
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition: track_type.h:21
TRACKDIR_LOWER_W
@ TRACKDIR_LOWER_W
Lower track and direction to west.
Definition: track_type.h:80
TRACKDIR_BIT_LEFT_N
@ TRACKDIR_BIT_LEFT_N
Track left, direction north.
Definition: track_type.h:111
TRACKDIR_RVREV_NW
@ TRACKDIR_RVREV_NW
(Road vehicle) reverse direction north-west
Definition: track_type.h:84
TRACKDIR_BIT_Y_NW
@ TRACKDIR_BIT_Y_NW
Track y-axis, direction north-west.
Definition: track_type.h:108
TRACKDIR_UPPER_E
@ TRACKDIR_UPPER_E
Upper track and direction to east.
Definition: track_type.h:71
TRACKDIR_RVREV_SE
@ TRACKDIR_RVREV_SE
(Road vehicle) reverse direction south-east
Definition: track_type.h:76
TRACKDIR_Y_SE
@ TRACKDIR_Y_SE
Y-axis and direction to south-east.
Definition: track_type.h:70
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition: track_type.h:26
TRACK_BIT_UPPER
@ TRACK_BIT_UPPER
Upper track.
Definition: track_type.h:39
TRACK_BIT_RIGHT
@ TRACK_BIT_RIGHT
Right track.
Definition: track_type.h:42
TRACKDIR_LEFT_N
@ TRACKDIR_LEFT_N
Left track and direction to north.
Definition: track_type.h:81
TRACK_BIT_CROSS
@ TRACK_BIT_CROSS
X-Y-axis cross.
Definition: track_type.h:43
DECLARE_POSTFIX_INCREMENT
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
TRACK_BIT_VERT
@ TRACK_BIT_VERT
Left and right track.
Definition: track_type.h:45
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition: track_type.h:22
TRACKDIR_BIT_NONE
@ TRACKDIR_BIT_NONE
No track build.
Definition: track_type.h:99
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition: track_type.h:23
TRACKDIR_BIT_LOWER_W
@ TRACKDIR_BIT_LOWER_W
Track lower, direction west.
Definition: track_type.h:110
TRACKDIR_BIT_UPPER_E
@ TRACKDIR_BIT_UPPER_E
Track upper, direction east.
Definition: track_type.h:102
TRACKDIR_BIT_LEFT_S
@ TRACKDIR_BIT_LEFT_S
Track left, direction south.
Definition: track_type.h:104
TRACK_BIT_X
@ TRACK_BIT_X
X-axis track.
Definition: track_type.h:37
TRACKDIR_BIT_RIGHT_S
@ TRACKDIR_BIT_RIGHT_S
Track right, direction south.
Definition: track_type.h:105
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition: track_type.h:25
INVALID_TRACKDIR
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition: track_type.h:86
TRACKDIR_X_NE
@ TRACKDIR_X_NE
X-axis and direction to north-east.
Definition: track_type.h:69
TRACK_BIT_ALL
@ TRACK_BIT_ALL
All possible tracks.
Definition: track_type.h:50
TRACKDIR_UPPER_W
@ TRACKDIR_UPPER_W
Upper track and direction to west.
Definition: track_type.h:79
TRACK_BIT_LOWER
@ TRACK_BIT_LOWER
Lower track.
Definition: track_type.h:40
INVALID_TRACK_BIT
@ INVALID_TRACK_BIT
Flag for an invalid trackbits value.
Definition: track_type.h:54
TRACK_BIT_DEPOT
@ TRACK_BIT_DEPOT
Bitflag for a depot.
Definition: track_type.h:53
TRACK_END
@ TRACK_END
Used for iterations.
Definition: track_type.h:27
TRACKDIR_BIT_X_NE
@ TRACKDIR_BIT_X_NE
Track x-axis, direction north-east.
Definition: track_type.h:100
TRACK_BIT_HORZ
@ TRACK_BIT_HORZ
Upper and lower track.
Definition: track_type.h:44
TRACKDIR_BIT_MASK
@ TRACKDIR_BIT_MASK
Bitmask for bit-operations.
Definition: track_type.h:113
TRACK_BIT_LEFT
@ TRACK_BIT_LEFT
Left track.
Definition: track_type.h:41
TRACK_BIT_3WAY_NE
@ TRACK_BIT_3WAY_NE
"Arrow" to the north-east
Definition: track_type.h:46
TRACKDIR_BIT_LOWER_E
@ TRACKDIR_BIT_LOWER_E
Track lower, direction east.
Definition: track_type.h:103
TRACKDIR_Y_NW
@ TRACKDIR_Y_NW
Y-axis and direction to north-west.
Definition: track_type.h:78
TRACK_BIT_3WAY_SE
@ TRACK_BIT_3WAY_SE
"Arrow" to the south-east
Definition: track_type.h:47
TRACKDIR_END
@ TRACKDIR_END
Used for iterations.
Definition: track_type.h:85
enum_type.hpp
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
TrackBits
TrackBits
Allow incrementing of Track variables.
Definition: track_type.h:35
TRACKDIR_BIT_Y_SE
@ TRACKDIR_BIT_Y_SE
Track y-axis, direction south-east.
Definition: track_type.h:101
TRACKDIR_BIT_RIGHT_N
@ TRACKDIR_BIT_RIGHT_N
Track right, direction north.
Definition: track_type.h:112
TRACKDIR_RVREV_NE
@ TRACKDIR_RVREV_NE
(Road vehicle) reverse direction north-east
Definition: track_type.h:75
TRACK_BIT_Y
@ TRACK_BIT_Y
Y-axis track.
Definition: track_type.h:38
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:67
TRACKDIR_LEFT_S
@ TRACKDIR_LEFT_S
Left track and direction to south.
Definition: track_type.h:73
TrackdirBits
TrackdirBits
Allow incrementing of Trackdir variables.
Definition: track_type.h:98
TRACKDIR_X_SW
@ TRACKDIR_X_SW
X-axis and direction to south-west.
Definition: track_type.h:77
Track
Track
These are used to specify a single track.
Definition: track_type.h:19
TRACK_BIT_3WAY_NW
@ TRACK_BIT_3WAY_NW
"Arrow" to the north-west
Definition: track_type.h:49
TRACKDIR_RIGHT_N
@ TRACKDIR_RIGHT_N
Right track and direction to north.
Definition: track_type.h:82
TRACKDIR_BIT_UPPER_W
@ TRACKDIR_BIT_UPPER_W
Track upper, direction west.
Definition: track_type.h:109
INVALID_TRACKDIR_BIT
@ INVALID_TRACKDIR_BIT
Flag for an invalid trackdirbit value.
Definition: track_type.h:114
TRACKDIR_BEGIN
@ TRACKDIR_BEGIN
Used for iterations.
Definition: track_type.h:68
TRACKDIR_BIT_X_SW
@ TRACKDIR_BIT_X_SW
Track x-axis, direction south-west.
Definition: track_type.h:107
INVALID_TRACK
@ INVALID_TRACK
Flag for an invalid track.
Definition: track_type.h:28