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