OpenTTD Source 20260206-master-g4d4e37dbf1
pbs.cpp File Reference

PBS support routines. More...

#include "stdafx.h"
#include "viewport_func.h"
#include "vehicle_func.h"
#include "newgrf_station.h"
#include "pathfinder/follow_track.hpp"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  FindTrainOnTrackInfo
 Helper struct for finding the best matching vehicle on a specific track. More...

Functions

TrackBits GetReservedTrackbits (TileIndex t)
 Get the reserved trackbits for any tile, regardless of type.
void SetRailStationPlatformReservation (TileIndex start, DiagDirection dir, bool b)
 Set the reservation for a complete station platform.
bool TryReserveRailTrack (TileIndex tile, Track t, bool trigger_stations)
 Try to reserve a specific track on a tile.
void UnreserveRailTrack (TileIndex tile, Track t)
 Lift the reservation of a specific track on a tile.
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.
static void CheckTrainsOnTrack (FindTrainOnTrackInfo &info, TileIndex tile)
 Find the best matching vehicle on a tile.
PBSTileInfo FollowTrainReservation (const Train *v, Vehicle **train_on_res)
 Follow a train reservation to the last tile.
TrainGetTrainForReservation (TileIndex tile, Track track)
 Find the train which has reserved a specific path.
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.
bool IsWaitingPositionFree (const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg)
 Check if a safe position is free.

Detailed Description

PBS support routines.

Definition in file pbs.cpp.

Function Documentation

◆ CheckTrainsOnTrack()

◆ FollowReservation()

◆ FollowTrainReservation()

◆ GetReservedTrackbits()

◆ GetTrainForReservation()

◆ IsSafeWaitingPosition()

bool IsSafeWaitingPosition ( const Train * v,
TileIndex tile,
Trackdir trackdir,
bool include_line_end,
bool forbid_90deg )

◆ IsWaitingPositionFree()

bool IsWaitingPositionFree ( const Train * v,
TileIndex tile,
Trackdir trackdir,
bool forbid_90deg )

Check if a safe position is free.

Parameters
vthe vehicle to test for
tileThe tile
trackdirThe trackdir to test
forbid_90degDon't allow trains to make 90 degree turns
Returns
True if the position is free

Definition at line 427 of file pbs.cpp.

References DiagdirReachesTrackdirs(), GetReservedTrackbits(), GetTileRailType(), HasReservedTracks(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), Rail90DegTurnDisallowed(), Railway, TrackdirBitsToTrackBits(), TrackdirCrossesTrackdirs(), TrackdirToTrack(), and TrackOverlapsTracks().

Referenced by ExtendTrainReservation(), CYapfCostRailT< Types >::PfCalcCost(), CYapfDestinationAnySafeTileRailT< Types >::PfDetectDestination(), and CYapfReserveTrack< Types >::TryReservePath().

◆ SetRailStationPlatformReservation()

void SetRailStationPlatformReservation ( TileIndex start,
DiagDirection dir,
bool b )

Set the reservation for a complete station platform.

Precondition
IsRailStationTile(start)
Parameters
startstarting tile of the platform
dirthe direction in which to follow the platform
bthe state the reservation should be set to

Definition at line 57 of file pbs.cpp.

References DiagDirToAxis(), GetRailStationAxis(), IsCompatibleTrainStationTile(), IsRailStationTile(), MarkTileDirtyByTile(), SetRailStationReservation(), TileAdd(), and TileOffsByDiagDir().

Referenced by ClearPathReservation(), CmdBuildRailStation(), DeleteLastWagon(), FreeTrainReservation(), RestoreTrainReservation(), and ReverseTrainDirection().

◆ TryReserveRailTrack()

◆ UnreserveRailTrack()