#include "stdafx.h"
#include "pbs.h"
#include "functions.h"
#include "vehicle_func.h"
#include "yapf/follow_track.hpp"
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 | SetRailwayStationPlatformReservation (TileIndex start, DiagDirection dir, bool b) |
Set the reservation for a complete station platform. | |
bool | TryReserveRailTrack (TileIndex tile, Track t) |
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 Vehicle * | FindTrainOnTrackEnum (Vehicle *v, void *data) |
Callback for Has/FindVehicleOnPos to find a train on a specific track. | |
PBSTileInfo | FollowTrainReservation (const Vehicle *v, bool *train_on_res) |
Follow a train reservation to the last tile. | |
Vehicle * | GetTrainForReservation (TileIndex tile, Track track) |
Find the train which has reserved a specific path. | |
bool | IsSafeWaitingPosition (const Vehicle *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 Vehicle *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg) |
Check if a safe position is free. |
Definition in file pbs.cpp.
static Vehicle* FindTrainOnTrackEnum | ( | Vehicle * | v, | |
void * | data | |||
) | [static] |
Callback for Has/FindVehicleOnPos to find a train on a specific track.
Definition at line 232 of file pbs.cpp.
References FindTrainOnTrackInfo::best, HasBit(), FindTrainOnTrackInfo::res, TRACK_BIT_WORMHOLE, PBSTileInfo::trackdir, and TrackdirToTrack().
Referenced by FollowTrainReservation(), and GetTrainForReservation().
static PBSTileInfo FollowReservation | ( | Owner | o, | |
RailTypes | rts, | |||
TileIndex | tile, | |||
Trackdir | trackdir, | |||
bool | ignore_oneway = false | |||
) | [static] |
Follow a reservation starting from a specific tile to the end.
Definition at line 170 of file pbs.cpp.
References FindFirstTrackdir(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetReservedTrackbits(), HasOnewaySignalBlockingTrackdir(), HasReservedTracks(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, MP_RAILWAY, TrackBitsToTrackdirBits(), TRACKDIR_BIT_NONE, TrackdirToTrack(), and TrackToTrackBits().
Referenced by FollowTrainReservation(), and GetTrainForReservation().
PBSTileInfo FollowTrainReservation | ( | const Vehicle * | v, | |
bool * | 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 256 of file pbs.cpp.
References _settings_game, RailtypeInfo::compatible_railtypes, FindTrainOnTrackEnum(), FollowReservation(), PathfinderSettings::forbid_90_deg, GetRailDepotReservation(), GetRailTypeInfo(), GetVehicleTrackdir(), HasVehicleOnPos(), IsRailDepotTile(), IsSafeWaitingPosition(), PBSTileInfo::okay, GameSettings::pf, FindTrainOnTrackInfo::res, PBSTileInfo::tile, and PBSTileInfo::trackdir.
Referenced by DoTrainPathfind(), ExtendTrainReservation(), FindClosestTrainDepot(), TryPathReserve(), and YapfFindNearestRailDepotTwoWay().
Get the reserved trackbits for any tile, regardless of type.
t | the tile |
Definition at line 16 of file pbs.cpp.
References GetRailCrossingReservation(), GetRailStationReservation(), GetRailTunnelBridgeReservation(), GetRailWaypointReservation(), GetTileType(), GetTrackReservation(), GetTunnelBridgeTransportType(), IsPlainRail(), IsRailDepot(), IsRailWaypoint(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, TRACK_BIT_NONE, and TRANSPORT_RAIL.
Referenced by CmdConvertRail(), FollowReservation(), FreeTrainTrackReservation(), HasReservedTracks(), IsWaitingPositionFree(), and TryPathReserve().
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 279 of file pbs.cpp.
References FindTrainOnTrackInfo::best, RailtypeInfo::compatible_railtypes, FindTrainOnTrackEnum(), FindVehicleOnPos(), FollowReservation(), GetOtherTunnelBridgeEnd(), GetRailTypeInfo(), GetTileOwner(), GetTileRailType(), HasReservedTracks(), IsTileType(), MP_TUNNELBRIDGE, FindTrainOnTrackInfo::res, ReverseTrackdir(), PBSTileInfo::tile, TileOffsByDiagDir(), PBSTileInfo::trackdir, TrackdirToExitdir(), TrackToTrackBits(), and TrackToTrackdir().
Referenced by CmdBuildRailroadStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveFromRailroadStation(), CmdRemoveSingleRail(), CmdRemoveSingleSignal(), and RemoveTrainWaypoint().
bool IsSafeWaitingPosition | ( | const Vehicle * | 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_90def | Don't allow trains to make 90 degree turns |
Definition at line 325 of file pbs.cpp.
References RailtypeInfo::compatible_railtypes, DiagdirReachesTrackdirs(), FindFirstTrackdir(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetRailTypeInfo(), HasPbsSignalOnTrackdir(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), KillFirstBit(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_exitdir, CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, MP_RAILWAY, TRACKDIR_BIT_NONE, TrackdirCrossesTrackdirs(), and TrackdirToTrack().
Referenced by ExtendTrainReservation(), FindSafePosition(), FollowTrainReservation(), and NPFFindSafeTile().
bool IsWaitingPositionFree | ( | const Vehicle * | 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_90def | Don't allow trains to make 90 degree turns |
Definition at line 365 of file pbs.cpp.
References RailtypeInfo::compatible_railtypes, DiagdirReachesTrackdirs(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetRailTypeInfo(), GetReservedTrackbits(), HasReservedTracks(), HasSignalOnTrackdir(), IsRailDepotTile(), IsTileType(), CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_exitdir, CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, MP_RAILWAY, TrackdirBitsToTrackBits(), TrackdirCrossesTrackdirs(), TrackdirToTrack(), and TrackOverlapsTracks().
Referenced by ExtendTrainReservation(), NPFFindSafeTile(), and NPFSaveTargetData().
void SetRailwayStationPlatformReservation | ( | 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 49 of file pbs.cpp.
References DiagDirToAxis(), MarkTileDirtyByTile(), SetRailwayStationReservation(), TILE_ADD, and TileOffsByDiagDir().
Referenced by ClearPathReservation(), CmdBuildRailroadStation(), CmdRemoveFromRailroadStation(), and NPFSaveTargetData().
Try to reserve a specific track on a tile.
tile | the tile | |
t | the track |
Definition at line 71 of file pbs.cpp.
References _settings_client, GetCrossingReservation(), GetDepotWaypointReservation(), GetRailTunnelBridgeReservation(), GetRailwayStationReservation(), GetTileTrackStatus(), GetTileType(), GetTunnelBridgeTransportType(), ClientSettings::gui, IsPlainRail(), IsRailDepot(), IsRailWaypoint(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, SetCrossingReservation(), SetDepotWaypointReservation(), SetRailwayStationReservation(), SetTunnelBridgeReservation(), GUISettings::show_track_reservation, TrackToTrackBits(), TRANSPORT_RAIL, and TryReserveTrack().
Referenced by DeleteLastWagon(), ExtendTrainReservation(), and NPFSaveTargetData().
Lift the reservation of a specific track on a tile.
tile | the tile | |
t | the track |
Definition at line 127 of file pbs.cpp.
References _settings_client, GetTileTrackStatus(), GetTileType(), GetTunnelBridgeTransportType(), ClientSettings::gui, IsPlainRail(), IsRailDepot(), IsRailWaypoint(), MarkTileDirtyByTile(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, SetCrossingReservation(), SetDepotWaypointReservation(), SetRailwayStationReservation(), SetTunnelBridgeReservation(), GUISettings::show_track_reservation, TrackToTrackBits(), TRANSPORT_RAIL, UnreserveTrack(), and UpdateLevelCrossing().
Referenced by ClearPathReservation(), DeleteLastWagon(), ExtendTrainReservation(), and FreeTrainTrackReservation().