OpenTTD Source 20241224-master-gf74b0cf984
|
PBS support routines. More...
#include "tile_type.h"
#include "direction_type.h"
#include "track_type.h"
#include "vehicle_type.h"
Go to the source code of this file.
Data Structures | |
struct | PBSTileInfo |
This struct contains information about the end of a reserved path. 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=true) |
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. | |
PBSTileInfo | FollowTrainReservation (const Train *v, Vehicle **train_on_res=nullptr) |
Follow a train reservation to the last tile. | |
bool | IsSafeWaitingPosition (const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg=false) |
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=false) |
Check if a safe position is free. | |
Train * | GetTrainForReservation (TileIndex tile, Track track) |
Find the train which has reserved a specific path. | |
bool | HasReservedTracks (TileIndex tile, TrackBits tracks) |
Check whether some of tracks is reserved on a tile. | |
PBS support routines.
Definition in file pbs.h.
PBSTileInfo FollowTrainReservation | ( | const Train * | v, |
Vehicle ** | train_on_res | ||
) |
Follow a train reservation to the last tile.
v | the vehicle |
train_on_res | Is set to a train we might encounter |
Definition at line 288 of file pbs.cpp.
References _settings_game, FindTrainOnTrackInfo::best, RailTypeInfo::compatible_railtypes, FindTrainOnTrackEnum(), FindVehicleOnPos(), SpecializedVehicle< T, Type >::First(), FollowReservation(), PathfinderSettings::forbid_90_deg, GetDepotReservationTrackBits(), GetOtherTunnelBridgeEnd(), GetRailTypeInfo(), Train::GetVehicleTrackdir(), IsCompatibleTrainStationTile(), IsRailDepotTile(), IsRailStationTile(), IsSafeWaitingPosition(), IsTileType(), MP_TUNNELBRIDGE, PBSTileInfo::okay, Vehicle::owner, GameSettings::pf, FindTrainOnTrackInfo::res, ReverseTrackdir(), PBSTileInfo::tile, Vehicle::tile, TileOffsByDiagDir(), PBSTileInfo::trackdir, TrackdirToExitdir(), BaseVehicle::type, and VEH_TRAIN.
Referenced by ExtendTrainReservation(), TryPathReserve(), and YapfTrainFindNearestDepot().
Get the reserved trackbits for any tile, regardless of type.
t | the tile |
Definition at line 24 of file pbs.cpp.
References GetCrossingReservationTrackBits(), GetDepotReservationTrackBits(), GetRailReservationTrackBits(), GetStationReservationTrackBits(), GetTileType(), GetTunnelBridgeReservationTrackBits(), GetTunnelBridgeTransportType(), HasStationRail(), IsLevelCrossing(), IsPlainRail(), IsRailDepot(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, TRACK_BIT_NONE, and TRANSPORT_RAIL.
Referenced by CmdConvertRail(), CmdRemoveSingleSignal(), FollowReservation(), FreeTrainTrackReservation(), HasReservedTracks(), IsWaitingPositionFree(), CYapfCostRailT< Types >::ReservationCost(), and TrainController().
Find the train which has reserved a specific path.
tile | A tile on the path. |
track | A reserved track on the tile. |
Definition at line 330 of file pbs.cpp.
References FindTrainOnTrackInfo::best, RailTypeInfo::compatible_railtypes, FindTrainOnTrackEnum(), FindVehicleOnPos(), FollowReservation(), GetOtherTunnelBridgeEnd(), GetRailTypeInfo(), GetTileOwner(), GetTileRailType(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), HasReservedTracks(), IsCompatibleTrainStationTile(), IsRailStationTile(), IsTileType(), MP_TUNNELBRIDGE, FindTrainOnTrackInfo::res, ReverseTrackdir(), PBSTileInfo::tile, TileOffsByDiagDir(), PBSTileInfo::trackdir, TrackdirToExitdir(), TrackToTrackBits(), and TrackToTrackdir().
Referenced by CheckFlatLandRailStation(), CmdBuildRailStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), DoClearBridge(), DoClearTunnel(), and RemoveFromRailBaseStation().
Check whether some of tracks is reserved on a tile.
tile | the tile |
tracks | the tracks to test |
Definition at line 58 of file pbs.h.
References GetReservedTrackbits(), and TRACK_BIT_NONE.
Referenced by CheckNextTrainTile(), CmdBuildSingleSignal(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), DeleteLastWagon(), DrawTrackBits(), ExtendTrainReservation(), FollowReservation(), GetTrainForReservation(), IsWaitingPositionFree(), TrainController(), and TryPathReserve().
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.
v | the vehicle to test for |
tile | The tile |
trackdir | The trackdir to test |
include_line_end | Should end-of-line tiles be considered safe? |
forbid_90deg | Don't allow trains to make 90 degree turns |
Definition at line 380 of file pbs.cpp.
References RailTypeInfo::compatible_railtypes, DiagdirReachesTrackdirs(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::exitdir, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetRailTypeInfo(), GetTileRailType(), HasPbsSignalOnTrackdir(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), KillFirstBit(), MP_RAILWAY, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_tile, Rail90DegTurnDisallowed(), ReverseTrackdir(), SIGTYPE_PBS_ONEWAY, TRACKDIR_BIT_NONE, and TrackdirToTrack().
Referenced by CmdBuildSingleSignal(), ExtendTrainReservation(), FollowTrainReservation(), CYapfCostRailT< Types >::PfCalcCost(), and CYapfDestinationAnySafeTileRailT< Types >::PfDetectDestination().
bool IsWaitingPositionFree | ( | const Train * | v, |
TileIndex | tile, | ||
Trackdir | trackdir, | ||
bool | forbid_90deg | ||
) |
Check if a safe position is free.
v | the vehicle to test for |
tile | The tile |
trackdir | The trackdir to test |
forbid_90deg | Don't allow trains to make 90 degree turns |
Definition at line 426 of file pbs.cpp.
References RailTypeInfo::compatible_railtypes, DiagdirReachesTrackdirs(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::exitdir, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetRailTypeInfo(), GetReservedTrackbits(), GetTileRailType(), HasReservedTracks(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), MP_RAILWAY, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_tile, Rail90DegTurnDisallowed(), TrackdirBitsToTrackBits(), TrackdirToTrack(), and TrackOverlapsTracks().
Referenced by ExtendTrainReservation(), CYapfCostRailT< Types >::PfCalcCost(), CYapfDestinationAnySafeTileRailT< Types >::PfDetectDestination(), and CYapfReserveTrack< Types >::TryReservePath().
void SetRailStationPlatformReservation | ( | TileIndex | start, |
DiagDirection | dir, | ||
bool | b | ||
) |
Set the reservation for a complete station platform.
start | starting tile of the platform |
dir | the direction in which to follow the platform |
b | the 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().
Try to reserve a specific track on a tile.
tile | the tile |
t | the track |
trigger_stations | whether to call station randomisation trigger |
true
if reservation was successful, i.e. the track was free and didn't cross any other reserved tracks. Definition at line 80 of file pbs.cpp.
References _settings_client, GetTileTrackStatus(), GetTileType(), GetTunnelBridgeReservationTrackBits(), GetTunnelBridgeTransportType(), ClientSettings::gui, HasCrossingReservation(), HasDepotReservation(), HasStationRail(), HasStationReservation(), HasTrack(), IsBridgeTile(), IsLevelCrossing(), IsPlainRail(), IsRailDepot(), IsRailStation(), MarkBridgeDirty(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, SetCrossingReservation(), SetDepotReservation(), SetRailStationReservation(), SetTunnelBridgeReservation(), GUISettings::show_track_reservation, SRT_PATH_RESERVATION, TrackStatusToTrackBits(), TRANSPORT_RAIL, TriggerStationRandomisation(), TryReserveTrack(), and UpdateLevelCrossing().
Referenced by DeleteLastWagon(), ExtendTrainReservation(), CYapfReserveTrack< Types >::ReserveSingleTrack(), Train::ReserveTrackUnderConsist(), and TrainController().
Lift the reservation of a specific track on a tile.
tile | the tile |
t | the track |
Definition at line 140 of file pbs.cpp.
References _settings_client, GetTileTrackStatus(), GetTileType(), GetTunnelBridgeTransportType(), ClientSettings::gui, HasStationRail(), HasTrack(), IsBridgeTile(), IsLevelCrossing(), IsPlainRail(), IsRailDepot(), MarkBridgeDirty(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, SetCrossingReservation(), SetDepotReservation(), SetRailStationReservation(), SetTunnelBridgeReservation(), GUISettings::show_track_reservation, TrackStatusToTrackBits(), TRANSPORT_RAIL, UnreserveTrack(), and UpdateLevelCrossing().
Referenced by ClearPathReservation(), DeleteLastWagon(), ExtendTrainReservation(), FreeTrainTrackReservation(), and CYapfReserveTrack< Types >::UnreserveSingleTrack().