OpenTTD Source 20260621-master-g720d10536d
track_data.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
15 {Trackdir::X_NE, Trackdir::Lower_E, Trackdir::Left_N}, // DiagDirection::NE
16 {Trackdir::Y_SE, Trackdir::Left_S, Trackdir::Upper_E}, // DiagDirection::SE
17 {Trackdir::X_SW, Trackdir::Upper_W, Trackdir::Right_S}, // DiagDirection::SW
18 {Trackdir::Y_NW, Trackdir::Right_N, Trackdir::Lower_W}, // DiagDirection::NW
19}}};
20
25};
26
29 {Trackdir::Y_SE, Trackdir::Y_NW}, // TRACK_X
30 {Trackdir::X_NE, Trackdir::X_SW}, // TRACK_Y
35}}};
36
39 Track::Y, // Track::X
40 Track::X, // Track::Y
41 {Track::Left, Track::Right}, // Track::Upper
42 {Track::Left, Track::Right}, // Track::Lower
43 {Track::Upper, Track::Lower}, // Track::Left
44 {Track::Upper, Track::Lower}, // Track::Right
45};
46
51};
52
61}}};
62
71}}};
72
81}}};
82
86};
87
91};
92
93extern const TrackdirBits _uphill_trackdirs[] = {
94 {}, // 0 SLOPE_FLAT
95 {Trackdir::X_SW, Trackdir::Y_NW}, // 1 SLOPE_W -> inclined for diagonal track
96 {Trackdir::X_SW, Trackdir::Y_SE}, // 2 SLOPE_S -> inclined for diagonal track
97 {Trackdir::X_SW}, // 3 SLOPE_SW
98 {Trackdir::X_NE, Trackdir::Y_SE}, // 4 SLOPE_E -> inclined for diagonal track
99 {}, // 5 SLOPE_EW
100 {Trackdir::Y_SE}, // 6 SLOPE_SE
101 {}, // 7 SLOPE_WSE -> leveled
102 {Trackdir::X_NE, Trackdir::Y_NW}, // 8 SLOPE_N -> inclined for diagonal track
103 {Trackdir::Y_NW}, // 9 SLOPE_NW
104 {}, // 10 SLOPE_NS
105 {}, // 11 SLOPE_NWS -> leveled
106 {Trackdir::X_NE}, // 12 SLOPE_NE
107 {}, // 13 SLOPE_ENW -> leveled
108 {}, // 14 SLOPE_SEN -> leveled
109 {}, // 15 invalid
110 {}, // 16 invalid
111 {}, // 17 invalid
112 {}, // 18 invalid
113 {}, // 19 invalid
114 {}, // 20 invalid
115 {}, // 21 invalid
116 {}, // 22 invalid
117 {Trackdir::X_SW, Trackdir::Y_SE}, // 23 SLOPE_STEEP_S -> inclined for diagonal track
118 {}, // 24 invalid
119 {}, // 25 invalid
120 {}, // 26 invalid
121 {Trackdir::X_SW, Trackdir::Y_NW}, // 27 SLOPE_STEEP_W -> inclined for diagonal track
122 {}, // 28 invalid
123 {Trackdir::X_NE, Trackdir::Y_NW}, // 29 SLOPE_STEEP_N -> inclined for diagonal track
124 {Trackdir::X_NE, Trackdir::Y_SE}, // 30 SLOPE_STEEP_E -> inclined for diagonal track
125};
EnumIndexArray< T, DiagDirection, DiagDirection::End > DiagDirectionIndexArray
Array with DiagDirection as index.
@ SW
Southwest.
@ NW
Northwest.
@ NE
Northeast, upper right on your monitor.
@ SE
Southeast.
EnumIndexArray< T, Corner, CORNER_END > CornerIndexArray
Array with Corner as index.
Definition slope_type.h:35
const TrackIndexArray< DiagDirectionIndexArray< Trackdir > > _track_enterdir_to_trackdir
Maps a track and an (4-way) dir to the trackdir that represents the track with the entry in the given...
const TrackIndexArray< TrackdirBits > _track_crosses_trackdirs
Maps a trackdir to all trackdirs that make 90 deg turns with it.
const DiagDirectionIndexArray< TrackdirBits > _exitdir_reaches_trackdirs
Maps a diagonal direction to the all trackdirs that are connected to any track entering in this direc...
const CornerIndexArray< TrackBits > _corner_to_trackbits
Maps a single horizontal/vertical trackbit that is in a specific tile corner.
const TrackdirIndexArray< DiagDirection > _trackdir_to_exitdir
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
const TrackdirIndexArray< Trackdir > _next_trackdir
Next trackdir to use when moving to a new tile for each current trackdir.
const DiagDirectionIndexArray< Trackdir > _dir_to_diag_trackdir
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
const TrackIndexArray< DirectionIndexArray< Trackdir > > _track_direction_to_trackdir
Maps a track and a full (8-way) direction to the trackdir that represents the track running in the gi...
const TrackIndexArray< TrackBits > _track_crosses_tracks
Maps a track to all tracks that make 90 deg turns with it.
const TrackIndexArray< DiagDirectionIndexArray< Trackdir > > _track_exitdir_to_trackdir
Maps a track and an (4-way) dir to the trackdir that represents the track with the exit in the given ...
EnumIndexArray< T, Track, Track::End > TrackIndexArray
Array with Track as index.
Definition track_type.h:40
EnumBitSet< Trackdir, uint16_t > TrackdirBits
Bitset of Trackdir elements.
Definition track_type.h:93
@ 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
@ Invalid
Flag for an invalid trackdir.
Definition track_type.h:82
@ 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
EnumIndexArray< T, Trackdir, Trackdir::End > TrackdirIndexArray
Array with Trackdir as index.
Definition track_type.h:90
@ 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
@ Y
Track along the y-axis (north-west to south-east).
Definition track_type.h:22
@ 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