OpenTTD Source 20260621-master-g720d10536d
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef TRACK_TYPE_H
11#define TRACK_TYPE_H
12
13#include "core/enum_type.hpp"
14
19enum class Track : uint8_t {
20 Begin = 0,
21 X = 0,
22 Y = 1,
23 Upper = 2,
24 Lower = 3,
25 Left = 4,
26 Right = 5,
28
30 Depot = 7,
31
32 Invalid = 0xFF,
33};
34
39template <typename T>
41
44
53
63enum class Trackdir : uint8_t {
64 X_NE = 0,
65 Y_SE = 1,
66 Upper_E = 2,
67 Lower_E = 3,
68 Left_S = 4,
69 Right_S = 5,
72 X_SW = 8,
73 Y_NW = 9,
74 Upper_W = 10,
75 Lower_W = 11,
76 Left_N = 12,
77 Right_N = 13,
78 RvRev_SW = 14,
79 RvRev_NW = 15,
80
82 Invalid = 0xFF,
83};
84
89template <typename T>
91
94
100
102static constexpr TrackdirBits INVALID_TRACKDIR_BIT{UINT16_MAX};
103
109
110#endif /* TRACK_TYPE_H */
Enum-as-bit-set wrapper.
#define Y
Climate toyland.
Definition engines.h:97
Type (helpers) for enums.
EnumClassIndexContainer< std::array< T, to_underlying(N)>, Index > EnumIndexArray
A typedef for EnumClassIndexContainer using std::array as the backing container type.
Track status of a tile.
Definition track_type.h:105
TrackdirBits signals
Red signals on the tile.
Definition track_type.h:107
TrackdirBits trackdirs
Trackdirs present on the tile.
Definition track_type.h:106
static constexpr TrackBits TRACK_BIT_3WAY_NE
"Arrow" to the north-east
Definition track_type.h:48
EnumIndexArray< T, Track, Track::End > TrackIndexArray
Array with Track as index.
Definition track_type.h:40
static constexpr TrackBits TRACK_BIT_HORZ
Upper and lower track.
Definition track_type.h:46
EnumBitSet< Trackdir, uint16_t > TrackdirBits
Bitset of Trackdir elements.
Definition track_type.h:93
EnumBitSet< Track, uint8_t > TrackBits
Bitset of Track elements.
Definition track_type.h:43
static constexpr TrackBits TRACK_BIT_ALL
All possible tracks.
Definition track_type.h:52
static constexpr TrackdirBits INVALID_TRACKDIR_BIT
Marker for an invalid TrackdirBits value.
Definition track_type.h:102
Trackdir
Enumeration for tracks and directions.
Definition track_type.h:63
@ Right_N
Right track and direction to north.
Definition track_type.h:77
@ X_NE
X-axis and direction to north-east.
Definition track_type.h:64
@ Right_S
Right track and direction to south.
Definition track_type.h:69
@ Left_S
Left track and direction to south.
Definition track_type.h:68
@ Lower_E
Lower track and direction to east.
Definition track_type.h:67
@ X_SW
X-axis and direction to south-west.
Definition track_type.h:72
@ Y_SE
Y-axis and direction to south-east.
Definition track_type.h:65
@ RvRev_NW
(Road vehicle) reverse direction north-west
Definition track_type.h:79
@ Y_NW
Y-axis and direction to north-west.
Definition track_type.h:73
@ Upper_W
Upper track and direction to west.
Definition track_type.h:74
@ RvRev_NE
(Road vehicle) reverse direction north-east
Definition track_type.h:70
@ Upper_E
Upper track and direction to east.
Definition track_type.h:66
@ RvRev_SW
(Road vehicle) reverse direction south-west
Definition track_type.h:78
@ Left_N
Left track and direction to north.
Definition track_type.h:76
@ Lower_W
Lower track and direction to west.
Definition track_type.h:75
@ RvRev_SE
(Road vehicle) reverse direction south-east
Definition track_type.h:71
static constexpr TrackBits TRACK_BIT_VERT
Left and right track.
Definition track_type.h:47
static constexpr TrackBits TRACK_BIT_CROSS
X-Y-axis cross.
Definition track_type.h:45
static constexpr TrackdirBits TRACKDIR_BIT_MASK
Bitset of valid non-road vehicle trackdirs/.
Definition track_type.h:96
static constexpr TrackBits TRACK_BIT_3WAY_SW
"Arrow" to the south-west
Definition track_type.h:50
static constexpr TrackBits TRACK_BIT_3WAY_SE
"Arrow" to the south-east
Definition track_type.h:49
EnumIndexArray< T, Trackdir, Trackdir::End > TrackdirIndexArray
Array with Trackdir as index.
Definition track_type.h:90
static constexpr TrackBits TRACK_BIT_3WAY_NW
"Arrow" to the north-west
Definition track_type.h:51
Track
These are used to specify a single track.
Definition track_type.h:19
@ X
Track along the x-axis (north-east to south-west).
Definition track_type.h:21
@ Upper
Track in the upper corner of the tile (north).
Definition track_type.h:23
@ Begin
Used for iterations.
Definition track_type.h:20
@ Invalid
Flag for an invalid track.
Definition track_type.h:32
@ Y
Track along the y-axis (north-west to south-east).
Definition track_type.h:22
@ End
End marker (of regular track bits).
Definition track_type.h:27
@ Right
Track in the right corner of the tile (east).
Definition track_type.h:26
@ Left
Track in the left corner of the tile (west).
Definition track_type.h:25
@ Lower
Track in the lower corner of the tile (south).
Definition track_type.h:24
@ Wormhole
Special flag indicating vehicle is inside a bridge or tunnel.
Definition track_type.h:29