OpenTTD
track_type.h
Go to the documentation of this file.
1 /* $Id: track_type.h 27833 2017-03-28 21:44:40Z peter1138 $ */
2 
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  */
9 
12 #ifndef TRACK_TYPE_H
13 #define TRACK_TYPE_H
14 
15 #include "core/enum_type.hpp"
16 
21 enum Track {
23  TRACK_X = 0,
24  TRACK_Y = 1,
27  TRACK_LEFT = 4,
30  INVALID_TRACK = 0xFF,
31 };
32 
36 template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK, 3> {};
38 
39 
41 enum TrackBits {
43  TRACK_BIT_X = 1U << TRACK_X,
44  TRACK_BIT_Y = 1U << TRACK_Y,
57  TRACK_BIT_MASK = 0x3FU,
59  TRACK_BIT_DEPOT = 0x80U,
61 };
64 
74 enum Trackdir {
94 };
95 
97 template <> struct EnumPropsT<Trackdir> : MakeEnumPropsT<Trackdir, byte, TRACKDIR_BEGIN, TRACKDIR_END, INVALID_TRACKDIR, 4> {};
99 
114  /* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
121  TRACKDIR_BIT_MASK = 0x3F3F,
123 };
126 
127 typedef uint32 TrackStatus;
128 
129 #endif /* TRACK_TYPE_H */
Helper template class that makes basic properties of given enumeration type visible from outsize...
Definition: enum_type.hpp:66
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Used for iterations.
Definition: track_type.h:22
Bitmask for the first 6 bits.
Definition: track_type.h:57
"Arrow" to the south-west
Definition: track_type.h:54
Y-axis and direction to north-west.
Definition: track_type.h:85
Used for iterations.
Definition: track_type.h:75
Used for iterations.
Definition: track_type.h:92
Flag for an invalid trackdirbit value.
Definition: track_type.h:122
Track
These are used to specify a single track.
Definition: track_type.h:21
Right track and direction to north.
Definition: track_type.h:89
Track right, direction south.
Definition: track_type.h:113
X-axis and direction to south-west.
Definition: track_type.h:84
Track in the left corner of the tile (west)
Definition: track_type.h:27
Type (helpers) for enums.
"Arrow" to the north-west
Definition: track_type.h:55
Used for iterations.
Definition: track_type.h:29
Track upper, direction east.
Definition: track_type.h:110
Right track.
Definition: track_type.h:48
Track right, direction north.
Definition: track_type.h:120
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:41
Track x-axis, direction north-east.
Definition: track_type.h:108
Left and right track.
Definition: track_type.h:51
(Road vehicle) reverse direction north-east
Definition: track_type.h:82
Flag for an invalid trackbits value.
Definition: track_type.h:60
All possible tracks.
Definition: track_type.h:56
Track along the y-axis (north-west to south-east)
Definition: track_type.h:24
Track upper, direction west.
Definition: track_type.h:117
Track lower, direction west.
Definition: track_type.h:118
X-axis track.
Definition: track_type.h:43
Track in the right corner of the tile (east)
Definition: track_type.h:28
"Arrow" to the north-east
Definition: track_type.h:52
Track in the lower corner of the tile (south)
Definition: track_type.h:26
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:52
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:74
(Road vehicle) reverse direction south-west
Definition: track_type.h:90
Bitmask for bit-operations.
Definition: track_type.h:121
In some cases we use byte or uint16 to store values that are defined as enum.
Definition: enum_type.hpp:86
(Road vehicle) reverse direction south-east
Definition: track_type.h:83
Left track and direction to north.
Definition: track_type.h:88
Upper track and direction to west.
Definition: track_type.h:86
Y-axis and direction to south-east.
Definition: track_type.h:77
X-Y-axis cross.
Definition: track_type.h:49
Bitflag for a wormhole (used for tunnels)
Definition: track_type.h:58
Lower track and direction to east.
Definition: track_type.h:79
Flag for an invalid track.
Definition: track_type.h:30
Left track and direction to south.
Definition: track_type.h:80
Lower track.
Definition: track_type.h:46
Upper track.
Definition: track_type.h:45
Track x-axis, direction south-west.
Definition: track_type.h:115
Upper and lower track.
Definition: track_type.h:50
Bitflag for a depot.
Definition: track_type.h:59
Right track and direction to south.
Definition: track_type.h:81
Track y-axis, direction north-west.
Definition: track_type.h:116
Lower track and direction to west.
Definition: track_type.h:87
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
Definition: track_type.h:106
"Arrow" to the south-east
Definition: track_type.h:53
Upper track and direction to east.
Definition: track_type.h:78
(Road vehicle) reverse direction north-west
Definition: track_type.h:91
Track y-axis, direction south-east.
Definition: track_type.h:109
Track left, direction south.
Definition: track_type.h:112
No track build.
Definition: track_type.h:107
Track left, direction north.
Definition: track_type.h:119
Left track.
Definition: track_type.h:47
Flag for an invalid trackdir.
Definition: track_type.h:93
Track along the x-axis (north-east to south-west)
Definition: track_type.h:23
#define DECLARE_POSTFIX_INCREMENT(type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:16
Track lower, direction east.
Definition: track_type.h:111
X-axis and direction to north-east.
Definition: track_type.h:76
Track in the upper corner of the tile (north)
Definition: track_type.h:25
No track.
Definition: track_type.h:42
Y-axis track.
Definition: track_type.h:44