|
OpenTTD Source 20260711-master-g3fb3006dff
|
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 *consist, Vehicle **train_on_res) |
| Follow a train reservation to the last tile. | |
| Train * | GetTrainForReservation (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. | |
PBS support routines.
Definition in file pbs.cpp.
|
static |
Find the best matching vehicle on a tile.
| [in,out] | info | State of the finding a vehicle on a reservation. |
| tile | The tile to search for. |
Definition at line 279 of file pbs.cpp.
References FindTrainOnTrackInfo::best, Crashed, SpecializedVehicle< T, Type >::First(), SpecializedVehicle< Train, Type >::From(), FindTrainOnTrackInfo::res, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Train::track, PBSTileInfo::trackdir, TrackdirToTrack(), Train, and Wormhole.
Referenced by FollowTrainReservation(), and GetTrainForReservation().
|
static |
Follow a reservation starting from a specific tile to the end.
| o | The owner of the track to follow; tracks of other owners are excluded. |
| rts | The rail types to follow the reservation for; rail types not in the mask are excluded. |
| tile | The start tile. |
| trackdir | The start trackdir on the tile. |
| ignore_oneway | Whether one way signals are to be ignored. |
Definition at line 199 of file pbs.cpp.
References DiagDirToDiagTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::exitdir, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetReservedTrackbits(), HasBlockSignalOnTrackdir(), HasOnewaySignalBlockingTrackdir(), HasReservedTracks(), HasStationReservation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_station, IsRailDepotTile(), 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, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), TileOffsByDiagDir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::tiles_skipped, TrackBitsToTrackdirBits(), and TrackdirToTrack().
Referenced by FollowTrainReservation(), and GetTrainForReservation().
| PBSTileInfo FollowTrainReservation | ( | const Train * | consist, |
| Vehicle ** | train_on_res ) |
Follow a train reservation to the last tile.
| consist | the vehicle |
| train_on_res | Is set to a train we might encounter |
Definition at line 301 of file pbs.cpp.
References _settings_game, FindTrainOnTrackInfo::best, CheckTrainsOnTrack(), SpecializedVehicle< T, Type >::First(), FollowReservation(), GetAllCompatibleRailTypes(), GetDepotReservationTrackBits(), SpecializedVehicle< T, Type >::GetMovingFront(), GetOtherTunnelBridgeEnd(), Train::GetVehicleTrackdir(), IsCompatibleTrainStationTile(), IsRailDepotTile(), IsRailStationTile(), IsSafeWaitingPosition(), IsTileType(), None, PBSTileInfo::okay, Vehicle::owner, Train::railtypes, FindTrainOnTrackInfo::res, ReverseTrackdir(), PBSTileInfo::tile, Vehicle::tile, TileOffsByDiagDir(), PBSTileInfo::trackdir, TrackdirToExitdir(), Train, TunnelBridge, and BaseVehicle::type.
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(), Rail, Railway, Road, Station, and TunnelBridge.
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 345 of file pbs.cpp.
References FindTrainOnTrackInfo::best, CheckTrainsOnTrack(), RailTypeInfo::compatible_railtypes, FollowReservation(), GetOtherTunnelBridgeEnd(), GetRailTypeInfo(), GetTileOwner(), GetTileRailType(), HasOnewaySignalBlockingTrackdir(), HasPbsSignalOnTrackdir(), HasReservedTracks(), IsCompatibleTrainStationTile(), IsRailStationTile(), IsTileType(), FindTrainOnTrackInfo::res, ReverseTrackdir(), PBSTileInfo::tile, TileOffsByDiagDir(), PBSTileInfo::trackdir, TrackdirToExitdir(), TrackToTrackdir(), and TunnelBridge.
Referenced by CheckFlatLandRailStation(), CmdBuildRailStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), DoClearBridge(), DoClearTunnel(), and RemoveFromRailBaseStation().
| 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 395 of file pbs.cpp.
References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), DiagdirReachesTrackdirs(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::exitdir, FindFirstTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetAllCompatibleRailTypes(), GetSignalType(), GetTileRailType(), HasBlockSignalOnTrackdir(), HasPbsSignalOnTrackdir(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), 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, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_tile, PathOneWay, Rail90DegTurnDisallowed(), Train::railtypes, Railway, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), ReverseTrackdir(), TrackdirCrossesTrackdirs(), 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 439 of file pbs.cpp.
References DiagdirReachesTrackdirs(), GetReservedTrackbits(), GetTileRailType(), HasBlockSignalOnTrackdir(), HasReservedTracks(), IsRailDepotTile(), Rail90DegTurnDisallowed(), TrackdirBitsToTrackBits(), TrackdirCrossesTrackdirs(), 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, BaseStation::GetByTile(), GetTileTrackStatus(), GetTileType(), GetTunnelBridgeReservationTrackBits(), GetTunnelBridgeTransportType(), HasCrossingReservation(), HasDepotReservation(), HasStationRail(), HasStationReservation(), Invalid, IsBridgeTile(), IsLevelCrossing(), IsPlainRail(), IsRailDepot(), MarkBridgeDirty(), MarkTileDirtyByTile(), None, PathReservation, Rail, Railway, Road, SetCrossingReservation(), SetDepotReservation(), SetRailStationReservation(), SetTunnelBridgeReservation(), Station, TrackdirBitsToTrackBits(), TriggerStationRandomisation(), TryReserveTrack(), TunnelBridge, 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 144 of file pbs.cpp.
References _settings_client, GetTileTrackStatus(), GetTileType(), GetTunnelBridgeTransportType(), HasStationRail(), Invalid, IsBridgeTile(), IsLevelCrossing(), IsPlainRail(), IsRailDepot(), MarkBridgeDirty(), MarkTileDirtyByTile(), Rail, Railway, Road, SetCrossingReservation(), SetDepotReservation(), SetRailStationReservation(), SetTunnelBridgeReservation(), Station, TrackdirBitsToTrackBits(), TunnelBridge, UnreserveTrack(), and UpdateLevelCrossing().
Referenced by ClearPathReservation(), DeleteLastWagon(), ExtendTrainReservation(), FreeTrainTrackReservation(), and CYapfReserveTrack< Types >::UnreserveSingleTrack().