OpenTTD Source 20260311-master-g511d3794ce
pbs.cpp
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#include "stdafx.h"
11#include "viewport_func.h"
12#include "vehicle_func.h"
13#include "newgrf_station.h"
15
16#include "safeguards.h"
17
25{
26 switch (GetTileType(t)) {
30 break;
31
32 case TileType::Road:
34 break;
35
38 break;
39
42 break;
43
44 default:
45 break;
46 }
47 return TRACK_BIT_NONE;
48}
49
58{
59 TileIndex tile = start;
61
62 assert(IsRailStationTile(start));
63 assert(GetRailStationAxis(start) == DiagDirToAxis(dir));
64
65 do {
68 tile = TileAdd(tile, diff);
69 } while (IsCompatibleTrainStationTile(tile, start));
70}
71
80bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
81{
83
84 if (_settings_client.gui.show_track_reservation) {
85 /* show the reserved rail if needed */
86 if (IsBridgeTile(tile)) {
87 MarkBridgeDirty(tile);
88 } else {
90 }
91 }
92
93 switch (GetTileType(tile)) {
95 if (IsPlainRail(tile)) return TryReserveTrack(tile, t);
96 if (IsRailDepot(tile)) {
97 if (!HasDepotReservation(tile)) {
98 SetDepotReservation(tile, true);
99 MarkTileDirtyByTile(tile); // some GRFs change their appearance when tile is reserved
100 return true;
101 }
102 }
103 break;
104
105 case TileType::Road:
106 if (IsLevelCrossing(tile) && !HasCrossingReservation(tile)) {
107 SetCrossingReservation(tile, true);
108 UpdateLevelCrossing(tile, false);
109 return true;
110 }
111 break;
112
114 if (HasStationRail(tile) && !HasStationReservation(tile)) {
115 SetRailStationReservation(tile, true);
116 if (trigger_stations) {
117 auto *st = BaseStation::GetByTile(tile);
119 TriggerStationAnimation(st, tile, StationAnimationTrigger::PathReservation);
120 }
121 MarkTileDirtyByTile(tile); // some GRFs need redraw after reserving track
122 return true;
123 }
124 break;
125
128 SetTunnelBridgeReservation(tile, true);
129 return true;
130 }
131 break;
132
133 default:
134 break;
135 }
136 return false;
137}
138
145{
147
148 if (_settings_client.gui.show_track_reservation) {
149 if (IsBridgeTile(tile)) {
150 MarkBridgeDirty(tile);
151 } else {
153 }
154 }
155
156 switch (GetTileType(tile)) {
158 if (IsRailDepot(tile)) {
159 SetDepotReservation(tile, false);
161 break;
162 }
163 if (IsPlainRail(tile)) UnreserveTrack(tile, t);
164 break;
165
166 case TileType::Road:
167 if (IsLevelCrossing(tile)) {
168 SetCrossingReservation(tile, false);
170 }
171 break;
172
174 if (HasStationRail(tile)) {
175 SetRailStationReservation(tile, false);
177 }
178 break;
179
182 break;
183
184 default:
185 break;
186 }
187}
188
189
199static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Trackdir trackdir, bool ignore_oneway = false)
200{
201 TileIndex start_tile = tile;
202 Trackdir start_trackdir = trackdir;
203 bool first_loop = true;
204
205 /* Start track not reserved? This can happen if two trains
206 * are on the same tile. The reservation on the next tile
207 * is not ours in this case, so exit. */
208 if (!HasReservedTracks(tile, TrackToTrackBits(TrackdirToTrack(trackdir)))) return PBSTileInfo(tile, trackdir, false);
209
210 /* Do not disallow 90 deg turns as the setting might have changed between reserving and now. */
211 CFollowTrackRail ft(o, rts);
212 while (ft.Follow(tile, trackdir)) {
214
215 /* No reservation --> path end found */
216 if (reserved == TRACKDIR_BIT_NONE) {
217 if (ft.is_station) {
218 /* Check skipped station tiles as well, maybe our reservation ends inside the station. */
220 while (ft.tiles_skipped-- > 0) {
221 ft.new_tile -= diff;
223 tile = ft.new_tile;
224 trackdir = DiagDirToDiagTrackdir(ft.exitdir);
225 break;
226 }
227 }
228 }
229 break;
230 }
231
232 /* Can't have more than one reserved trackdir */
233 Trackdir new_trackdir = FindFirstTrackdir(reserved);
234
235 /* One-way signal against us. The reservation can't be ours as it is not
236 * a safe position from our direction and we can never pass the signal. */
237 if (!ignore_oneway && HasOnewaySignalBlockingTrackdir(ft.new_tile, new_trackdir)) break;
238
239 tile = ft.new_tile;
240 trackdir = new_trackdir;
241
242 if (first_loop) {
243 /* Update the start tile after we followed the track the first
244 * time. This is necessary because the track follower can skip
245 * tiles (in stations for example) which means that we might
246 * never visit our original starting tile again. */
247 start_tile = tile;
248 start_trackdir = trackdir;
249 first_loop = false;
250 } else {
251 /* Loop encountered? */
252 if (tile == start_tile && trackdir == start_trackdir) break;
253 }
254 /* Depot tile? Can't continue. */
255 if (IsRailDepotTile(tile)) break;
256 /* Non-pbs signal? Reservation can't continue. */
257 if (IsTileType(tile, TileType::Railway) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, TrackdirToTrack(trackdir)))) break;
258 }
259
260 return PBSTileInfo(tile, trackdir, false);
261}
262
273
280{
281 for (Vehicle *v : VehiclesOnTile(tile)) {
282 if (v->type != VEH_TRAIN || v->vehstatus.Test(VehState::Crashed)) continue;
283
284 Train *t = Train::From(v);
285 if (t->track == TRACK_BIT_WORMHOLE || HasBit(static_cast<TrackBits>(t->track), TrackdirToTrack(info.res.trackdir))) {
286 t = t->First();
287
288 /* ALWAYS return the lowest ID (anti-desync!) */
289 if (info.best == nullptr || t->index < info.best->index) info.best = t;
290 }
291 }
292}
293
302{
303 assert(v->type == VEH_TRAIN);
304
305 TileIndex tile = v->tile;
306 Trackdir trackdir = v->GetVehicleTrackdir();
307
308 if (IsRailDepotTile(tile) && !GetDepotReservationTrackBits(tile)) return PBSTileInfo(tile, trackdir, false);
309
311 ftoti.res = FollowReservation(v->owner, GetAllCompatibleRailTypes(v->railtypes), tile, trackdir);
312 ftoti.res.okay = IsSafeWaitingPosition(v, ftoti.res.tile, ftoti.res.trackdir, true, _settings_game.pf.forbid_90_deg);
313 if (train_on_res != nullptr) {
314 CheckTrainsOnTrack(ftoti, ftoti.res.tile);
315 if (ftoti.best != nullptr) *train_on_res = ftoti.best->First();
316 if (*train_on_res == nullptr && IsRailStationTile(ftoti.res.tile)) {
317 /* The target tile is a rail station. The track follower
318 * has stopped on the last platform tile where we haven't
319 * found a train. Also check all previous platform tiles
320 * for a possible train. */
322 for (TileIndex st_tile = ftoti.res.tile + diff; *train_on_res == nullptr && IsCompatibleTrainStationTile(st_tile, ftoti.res.tile); st_tile += diff) {
323 CheckTrainsOnTrack(ftoti, st_tile);
324 if (ftoti.best != nullptr) *train_on_res = ftoti.best->First();
325 }
326 }
327 if (*train_on_res == nullptr && IsTileType(ftoti.res.tile, TileType::TunnelBridge)) {
328 /* The target tile is a bridge/tunnel, also check the other end tile. */
330 if (ftoti.best != nullptr) *train_on_res = ftoti.best->First();
331 }
332 }
333 return ftoti.res;
334}
335
344{
345 assert(HasReservedTracks(tile, TrackToTrackBits(track)));
346 Trackdir trackdir = TrackToTrackdir(track);
347
349
350 /* Follow the path from tile to both ends, one of the end tiles should
351 * have a train on it. We need FollowReservation to ignore one-way signals
352 * here, as one of the two search directions will be the "wrong" way. */
353 for (int i = 0; i < 2; ++i, trackdir = ReverseTrackdir(trackdir)) {
354 /* If the tile has a one-way block signal in the current trackdir, skip the
355 * search in this direction as the reservation can't come from this side.*/
356 if (HasOnewaySignalBlockingTrackdir(tile, ReverseTrackdir(trackdir)) && !HasPbsSignalOnTrackdir(tile, trackdir)) continue;
357
359 ftoti.res = FollowReservation(GetTileOwner(tile), rts, tile, trackdir, true);
360
361 CheckTrainsOnTrack(ftoti, ftoti.res.tile);
362 if (ftoti.best != nullptr) return ftoti.best;
363
364 /* Special case for stations: check the whole platform for a vehicle. */
365 if (IsRailStationTile(ftoti.res.tile)) {
367 for (TileIndex st_tile = ftoti.res.tile + diff; IsCompatibleTrainStationTile(st_tile, ftoti.res.tile); st_tile += diff) {
368 CheckTrainsOnTrack(ftoti, st_tile);
369 if (ftoti.best != nullptr) return ftoti.best;
370 }
371 }
372
373 /* Special case for bridges/tunnels: check the other end as well. */
376 if (ftoti.best != nullptr) return ftoti.best;
377 }
378 }
379
380 return nullptr;
381}
382
393bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
394{
395 if (IsRailDepotTile(tile)) return true;
396
397 if (IsTileType(tile, TileType::Railway)) {
398 /* For non-pbs signals, stop on the signal tile. */
399 if (HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, TrackdirToTrack(trackdir)))) return true;
400 }
401
402 /* Check next tile. For performance reasons, we check for 90 degree turns ourself. */
403 CFollowTrackRail ft(v, GetAllCompatibleRailTypes(v->railtypes));
404
405 /* End of track? */
406 if (!ft.Follow(tile, trackdir)) {
407 /* Last tile of a terminus station is a safe position. */
408 if (include_line_end) return true;
409 }
410
411 /* Check for reachable tracks. */
414 if (ft.new_td_bits == TRACKDIR_BIT_NONE) return include_line_end;
415
418 /* PBS signal on next trackdir? Safe position. */
419 if (HasPbsSignalOnTrackdir(ft.new_tile, td)) return true;
420 /* One-way PBS signal against us? Safe if end-of-line is allowed. */
423 return include_line_end;
424 }
425 }
426
427 return false;
428}
429
439bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg)
440{
441 Track track = TrackdirToTrack(trackdir);
442 TrackBits reserved = GetReservedTrackbits(tile);
443
444 /* Tile reserved? Can never be a free waiting position. */
445 if (TrackOverlapsTracks(reserved, track)) return false;
446
447 /* Not reserved and depot or not a pbs signal -> free. */
448 if (IsRailDepotTile(tile)) return true;
449 if (IsTileType(tile, TileType::Railway) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, track))) return true;
450
451 /* Check the next tile, it has to be free as well. Do not filter for compatible railtypes
452 * to make sure we never accidentally join up reservations. */
453 CFollowTrackRail ft(v, RailTypes{});
454
455 if (!ft.Follow(tile, trackdir)) return true;
456
457 /* Check for reachable tracks. */
458 ft.new_td_bits &= DiagdirReachesTrackdirs(ft.exitdir);
459 if (Rail90DegTurnDisallowed(GetTileRailType(ft.old_tile), GetTileRailType(ft.new_tile), forbid_90deg)) ft.new_td_bits &= ~TrackdirCrossesTrackdirs(trackdir);
460
461 return !HasReservedTracks(ft.new_tile, TrackdirBitsToTrackBits(ft.new_td_bits));
462}
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Definition bridge_map.h:35
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
Definition rail.h:180
Iterate over all vehicles on a tile.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
DiagDirection
Enumeration for diagonal directions.
Template function for track followers.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
Definition map_func.h:461
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition map_func.h:574
int32_t TileIndexDiff
An offset value between two tiles.
Definition map_type.h:23
void TriggerStationRandomisation(BaseStation *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoType cargo_type)
Trigger station randomisation.
Header file for NewGRF stations.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
Definition pbs.cpp:343
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
Definition pbs.cpp:57
static void CheckTrainsOnTrack(FindTrainOnTrackInfo &info, TileIndex tile)
Find the best matching vehicle on a tile.
Definition pbs.cpp:279
TrackBits GetReservedTrackbits(TileIndex t)
Get the reserved trackbits for any tile, regardless of type.
Definition pbs.cpp:24
PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res)
Follow a train reservation to the last tile.
Definition pbs.cpp:301
bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
Try to reserve a specific track on a tile.
Definition pbs.cpp:80
bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg)
Check if a safe position is free.
Definition pbs.cpp:439
static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Trackdir trackdir, bool ignore_oneway=false)
Follow a reservation starting from a specific tile to the end.
Definition pbs.cpp:199
void UnreserveRailTrack(TileIndex tile, Track t)
Lift the reservation of a specific track on a tile.
Definition pbs.cpp:144
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
Determine whether a certain track on a tile is a safe position to end a path.
Definition pbs.cpp:393
bool HasReservedTracks(TileIndex tile, TrackBits tracks)
Check whether some of tracks is reserved on a tile.
Definition pbs.h:58
RailType GetTileRailType(Tile tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
Definition rail.cpp:39
bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def=_settings_game.pf.forbid_90_deg)
Test if 90 degree turns are disallowed between two railtypes.
Definition rail.h:411
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition rail.h:301
RailTypes GetAllCompatibleRailTypes(RailTypes railtypes)
Returns all compatible railtypes for a set of railtypes.
Definition rail.h:313
bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
Is a one-way signal blocking the trackdir?
Definition rail_map.h:548
static bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
Definition rail_map.h:49
bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
Definition rail_map.h:491
static bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
Definition rail_map.h:95
bool IsPbsSignal(SignalType s)
Checks whether the given signal is a path based signal.
Definition rail_map.h:292
bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
Is a pbs signal present along the trackdir?
Definition rail_map.h:535
SignalType GetSignalType(Tile t, Track track)
Get the signal type for a track on a tile.
Definition rail_map.h:304
void UnreserveTrack(Tile tile, Track t)
Lift the reservation of a specific track on a tile.
Definition rail_map.h:243
void SetDepotReservation(Tile t, bool b)
Set the reservation state of the depot.
Definition rail_map.h:269
TrackBits GetDepotReservationTrackBits(Tile t)
Get the reserved track bits for a depot.
Definition rail_map.h:281
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
Definition rail_map.h:194
bool HasDepotReservation(Tile t)
Get the reservation state of the depot.
Definition rail_map.h:257
bool TryReserveTrack(Tile tile, Track t)
Try to reserve a specific track on a tile.
Definition rail_map.h:225
static bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
Definition rail_map.h:105
bool HasTrack(Tile tile, Track track)
Returns whether the given track is present on the given tile.
Definition rail_map.h:160
EnumBitSet< RailType, uint64_t > RailTypes
Allow incrementing of Track variables.
Definition rail_type.h:38
void UpdateLevelCrossing(TileIndex tile, bool sound=true, bool force_bar=false)
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
bool HasCrossingReservation(Tile t)
Get the reservation state of the rail crossing.
Definition road_map.h:390
TrackBits GetCrossingReservationTrackBits(Tile t)
Get the reserved track bits for a rail crossing.
Definition road_map.h:415
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
Definition road_map.h:403
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
Definition road_map.h:69
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
@ SIGTYPE_PBS_ONEWAY
no-entry signal
Definition signal_type.h:29
bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
Check if a tile is a valid continuation to a railstation tile.
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
void SetRailStationReservation(Tile t, bool b)
Set the reservation state of the rail station.
Axis GetRailStationAxis(Tile t)
Get the rail direction of a rail station.
bool HasStationRail(Tile t)
Has this station tile a rail?
bool HasStationReservation(Tile t)
Get the reservation state of the rail station.
TrackBits GetStationReservationTrackBits(Tile t)
Get the reserved track bits for a waypoint.
@ PathReservation
Trigger platform when train reserves path.
@ PathReservation
Trigger platform when train reserves path.
Definition of base types and functions in a cross-platform compatible way.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
VehicleType type
Type of vehicle.
bool Follow(TileIndex old_tile, Trackdir old_td)
main follower routine.
int tiles_skipped
number of skipped tunnel or station tiles
DiagDirection exitdir
exit direction (leaving the old tile)
TrackdirBits new_td_bits
the new set of available trackdirs
TileIndex new_tile
the new tile (the vehicle has entered)
bool is_station
last turn passed station
TileIndex old_tile
the origin (vehicle moved from) before move
Helper struct for finding the best matching vehicle on a specific track.
Definition pbs.cpp:266
PBSTileInfo res
Information about the track.
Definition pbs.cpp:267
FindTrainOnTrackInfo()
Init the best location to nullptr always!
Definition pbs.cpp:271
Train * best
The currently "best" vehicle we have found.
Definition pbs.cpp:268
This struct contains information about the end of a reserved path.
Definition pbs.h:26
Trackdir trackdir
The reserved trackdir on the tile.
Definition pbs.h:28
TileIndex tile
Tile the path ends, INVALID_TILE if no valid path was found.
Definition pbs.h:27
bool okay
True if tile is a safe waiting position, false otherwise.
Definition pbs.h:29
static Train * From(Vehicle *v)
T * First() const
Get the first vehicle in the chain.
'Train' is either a loco or a wagon.
Definition train.h:97
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
RailTypes railtypes
On which rail types the train can run.
Definition train.h:108
TrackBits track
On which track the train currently is.
Definition train.h:110
Vehicle data structure.
TileIndex tile
Current tile index.
Owner owner
Which company owns the vehicle?
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
Definition tile_map.h:178
static TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
Definition tile_map.h:96
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
@ TunnelBridge
Tunnel entry/exit and bridge heads.
Definition tile_type.h:58
@ Station
A tile of a station or airport.
Definition tile_type.h:54
@ Railway
A tile with railway.
Definition tile_type.h:50
@ Road
A tile with road and/or tram tracks.
Definition tile_type.h:51
Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
Definition track_func.h:279
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Definition track_func.h:262
bool TrackOverlapsTracks(TrackBits tracks, Track track)
Check if a given track is contained within or overlaps some other tracks.
Definition track_func.h:667
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
Definition track_func.h:77
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
Definition track_func.h:319
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
Definition track_func.h:247
Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
Definition track_func.h:211
TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
Definition track_func.h:611
TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
Definition track_func.h:560
Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
Definition track_func.h:542
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition track_func.h:365
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
Definition track_func.h:441
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
Definition track_func.h:308
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_NONE
No track.
Definition track_type.h:36
Trackdir
Enumeration for tracks and directions.
Definition track_type.h:66
TrackdirBits
Allow incrementing of Trackdir variables.
Definition track_type.h:97
@ TRACKDIR_BIT_NONE
No track build.
Definition track_type.h:98
Track
These are used to specify a single track.
Definition track_type.h:19
@ TRANSPORT_RAIL
Transport by train.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
TrackBits GetTunnelBridgeReservationTrackBits(Tile t)
Get the reserved track bits for a rail tunnel/bridge.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
void SetTunnelBridgeReservation(Tile t, bool b)
Set the reservation state of the rail tunnel/bridge.
@ Crashed
Vehicle is crashed.
Functions related to vehicles.
@ VEH_TRAIN
Train vehicle type.
Functions related to (drawing on) viewports.