OpenTTD Source 20260621-master-g720d10536d
track_type.h File Reference

All types related to tracks. More...

#include "core/enum_type.hpp"

Go to the source code of this file.

Data Structures

struct  TrackStatus
 Track status of a tile. More...

Typedefs

template<typename T>
using TrackIndexArray = EnumIndexArray<T, Track, Track::End>
 Array with Track as index.
using TrackBits = EnumBitSet<Track, uint8_t>
 Bitset of Track elements.
template<typename T>
using TrackdirIndexArray = EnumIndexArray<T, Trackdir, Trackdir::End>
 Array with Trackdir as index.
using TrackdirBits = EnumBitSet<Trackdir, uint16_t>
 Bitset of Trackdir elements.

Enumerations

enum class  Track : uint8_t {
  Begin = 0 , X = 0 , Y = 1 , Upper = 2 ,
  Lower = 3 , Left = 4 , Right = 5 , End ,
  Wormhole = 6 , Depot = 7 , Invalid = 0xFF
}
 These are used to specify a single track. More...
enum class  Trackdir : uint8_t {
  X_NE = 0 , Y_SE = 1 , Upper_E = 2 , Lower_E = 3 ,
  Left_S = 4 , Right_S = 5 , RvRev_NE = 6 , RvRev_SE = 7 ,
  X_SW = 8 , Y_NW = 9 , Upper_W = 10 , Lower_W = 11 ,
  Left_N = 12 , Right_N = 13 , RvRev_SW = 14 , RvRev_NW = 15 ,
  End , Invalid = 0xFF
}
 Enumeration for tracks and directions. More...

Variables

static constexpr TrackBits TRACK_BIT_CROSS = {Track::X, Track::Y}
 X-Y-axis cross.
static constexpr TrackBits TRACK_BIT_HORZ = {Track::Upper, Track::Lower}
 Upper and lower track.
static constexpr TrackBits TRACK_BIT_VERT = {Track::Left, Track::Right}
 Left and right track.
static constexpr TrackBits TRACK_BIT_3WAY_NE = {Track::X, Track::Upper, Track::Right}
 "Arrow" to the north-east
static constexpr TrackBits TRACK_BIT_3WAY_SE = {Track::Y, Track::Lower, Track::Right}
 "Arrow" to the south-east
static constexpr TrackBits TRACK_BIT_3WAY_SW = {Track::X, Track::Lower, Track::Left}
 "Arrow" to the south-west
static constexpr TrackBits TRACK_BIT_3WAY_NW = {Track::Y, Track::Upper, Track::Left}
 "Arrow" to the north-west
static constexpr TrackBits TRACK_BIT_ALL = {Track::X, Track::Y, Track::Upper, Track::Lower, Track::Left, Track::Right}
 All possible tracks.
static constexpr TrackdirBits TRACKDIR_BIT_MASK
 Bitset of valid non-road vehicle trackdirs/.
static constexpr TrackdirBits INVALID_TRACKDIR_BIT {UINT16_MAX}
 Marker for an invalid TrackdirBits value.

Detailed Description

All types related to tracks.

Definition in file track_type.h.

Typedef Documentation

◆ TrackBits

using TrackBits = EnumBitSet<Track, uint8_t>

Bitset of Track elements.

Definition at line 43 of file track_type.h.

◆ TrackdirBits

using TrackdirBits = EnumBitSet<Trackdir, uint16_t>

Bitset of Trackdir elements.

Definition at line 93 of file track_type.h.

◆ TrackdirIndexArray

template<typename T>
using TrackdirIndexArray = EnumIndexArray<T, Trackdir, Trackdir::End>

Array with Trackdir as index.

Template Parameters
Tthe type contained within the array.

Definition at line 90 of file track_type.h.

◆ TrackIndexArray

template<typename T>
using TrackIndexArray = EnumIndexArray<T, Track, Track::End>

Array with Track as index.

Template Parameters
Tthe type contained within the array.

Definition at line 40 of file track_type.h.

Enumeration Type Documentation

◆ Track

enum class Track : uint8_t
strong

These are used to specify a single track.

Can be translated to a trackbit with TrackToTrackbit

Enumerator
Begin 

Used for iterations.

Track along the x-axis (north-east to south-west).

Track along the y-axis (north-west to south-east).

Upper 

Track in the upper corner of the tile (north).

Lower 

Track in the lower corner of the tile (south).

Left 

Track in the left corner of the tile (west).

Right 

Track in the right corner of the tile (east).

End 

End marker (of regular track bits).

Wormhole 

Special flag indicating vehicle is inside a bridge or tunnel.

Depot 

Special flag indicating a vehicle is inside a depot.

Invalid 

Flag for an invalid track.

Definition at line 19 of file track_type.h.

◆ Trackdir

enum class Trackdir : uint8_t
strong

Enumeration for tracks and directions.

These are a combination of tracks and directions. Values are 0-5 in one direction (corresponding to the Track enum) and 8-13 in the other direction. 6, 7, 14 and 15 are used to encode the reversing of road vehicles. Those reversing track dirs are not considered to be 'valid' except in a small corner in the road vehicle controller.

Enumerator
X_NE 

X-axis and direction to north-east.

Y_SE 

Y-axis and direction to south-east.

Upper_E 

Upper track and direction to east.

Lower_E 

Lower track and direction to east.

Left_S 

Left track and direction to south.

Right_S 

Right track and direction to south.

RvRev_NE 

(Road vehicle) reverse direction north-east

RvRev_SE 

(Road vehicle) reverse direction south-east

X_SW 

X-axis and direction to south-west.

Y_NW 

Y-axis and direction to north-west.

Upper_W 

Upper track and direction to west.

Lower_W 

Lower track and direction to west.

Left_N 

Left track and direction to north.

Right_N 

Right track and direction to north.

RvRev_SW 

(Road vehicle) reverse direction south-west

RvRev_NW 

(Road vehicle) reverse direction north-west

End 

End marker.

Invalid 

Flag for an invalid trackdir.

Definition at line 63 of file track_type.h.

Variable Documentation

◆ INVALID_TRACKDIR_BIT

TrackdirBits INVALID_TRACKDIR_BIT {UINT16_MAX}
staticconstexpr

Marker for an invalid TrackdirBits value.

Definition at line 102 of file track_type.h.

Referenced by RemoveFirstTrackdir(), and ValueStr().

◆ TRACK_BIT_3WAY_NE

TrackBits TRACK_BIT_3WAY_NE = {Track::X, Track::Upper, Track::Right}
staticconstexpr

"Arrow" to the north-east

Definition at line 48 of file track_type.h.

Referenced by DrawTile_Rail(), GetJunctionGroundSpriteOffset(), GetTileTrackStatus_Station(), and TileLoop_Rail().

◆ TRACK_BIT_3WAY_NW

TrackBits TRACK_BIT_3WAY_NW = {Track::Y, Track::Upper, Track::Left}
staticconstexpr

"Arrow" to the north-west

Definition at line 51 of file track_type.h.

Referenced by DrawTile_Rail(), GetJunctionGroundSpriteOffset(), and TileLoop_Rail().

◆ TRACK_BIT_3WAY_SE

TrackBits TRACK_BIT_3WAY_SE = {Track::Y, Track::Lower, Track::Right}
staticconstexpr

"Arrow" to the south-east

Definition at line 49 of file track_type.h.

Referenced by DrawTile_Rail(), GetJunctionGroundSpriteOffset(), and TileLoop_Rail().

◆ TRACK_BIT_3WAY_SW

TrackBits TRACK_BIT_3WAY_SW = {Track::X, Track::Lower, Track::Left}
staticconstexpr

"Arrow" to the south-west

Definition at line 50 of file track_type.h.

Referenced by DrawTile_Rail(), GetJunctionGroundSpriteOffset(), and TileLoop_Rail().

◆ TRACK_BIT_ALL

◆ TRACK_BIT_CROSS

TrackBits TRACK_BIT_CROSS = {Track::X, Track::Y}
staticconstexpr

X-Y-axis cross.

Definition at line 45 of file track_type.h.

Referenced by CmdRemoveSingleRail(), DrawTrackBits(), and MaskWireBits().

◆ TRACK_BIT_HORZ

TrackBits TRACK_BIT_HORZ = {Track::Upper, Track::Lower}
staticconstexpr

Upper and lower track.

Definition at line 46 of file track_type.h.

Referenced by DrawTrackBits(), ExploreSegment(), GenericPlaceSignals(), GetRailFoundation(), and TracksOverlap().

◆ TRACK_BIT_VERT

TrackBits TRACK_BIT_VERT = {Track::Left, Track::Right}
staticconstexpr

Left and right track.

Definition at line 47 of file track_type.h.

Referenced by DrawTrackBits(), ExploreSegment(), GenericPlaceSignals(), GetRailFoundation(), and TracksOverlap().

◆ TRACKDIR_BIT_MASK

TrackdirBits TRACKDIR_BIT_MASK
staticconstexpr
Initial value:
{
}
@ 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
@ 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
@ Upper_E
Upper track and direction to east.
Definition track_type.h:66
@ 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

Bitset of valid non-road vehicle trackdirs/.

Definition at line 96 of file track_type.h.

Referenced by IsValidTrackdir().