OpenTTD Source 20260421-master-gc2fbc6fdeb
CYapfCostRailT< Types > Class Template Reference
Inheritance diagram for CYapfCostRailT< Types >:
CYapfCostBase CYapfT< CYapfRail_TypesT< CYapfAnyDepotRail, CFollowTrackRail, CYapfDestinationAnyDepotRailT, CYapfFollowAnyDepotRailT > > CYapfT< CYapfRail_TypesT< CYapfAnyDepotRailNo90, CFollowTrackRailNo90, CYapfDestinationAnyDepotRailT, CYapfFollowAnyDepotRailT > > CYapfT< CYapfRail_TypesT< CYapfAnySafeTileRail, CFollowTrackFreeRail, CYapfDestinationAnySafeTileRailT, CYapfFollowAnySafeTileRailT > > CYapfT< CYapfRail_TypesT< CYapfAnySafeTileRailNo90, CFollowTrackFreeRailNo90, CYapfDestinationAnySafeTileRailT, CYapfFollowAnySafeTileRailT > > CYapfT< CYapfRail_TypesT< CYapfRail, CFollowTrackRail, CYapfDestinationTileOrStationRailT, CYapfFollowRailT > > CYapfT< CYapfRail_TypesT< CYapfRailNo90, CFollowTrackRailNo90, CYapfDestinationTileOrStationRailT, CYapfFollowRailT > > CYapfRailBase< CYapfRail_TypesT< CYapfAnyDepotRail, CFollowTrackRail, CYapfDestinationAnyDepotRailT, CYapfFollowAnyDepotRailT > > CYapfRailBase< CYapfRail_TypesT< CYapfAnyDepotRailNo90, CFollowTrackRailNo90, CYapfDestinationAnyDepotRailT, CYapfFollowAnyDepotRailT > > CYapfRailBase< CYapfRail_TypesT< CYapfAnySafeTileRail, CFollowTrackFreeRail, CYapfDestinationAnySafeTileRailT, CYapfFollowAnySafeTileRailT > > CYapfRailBase< CYapfRail_TypesT< CYapfAnySafeTileRailNo90, CFollowTrackFreeRailNo90, CYapfDestinationAnySafeTileRailT, CYapfFollowAnySafeTileRailT > > CYapfRailBase< CYapfRail_TypesT< CYapfRail, CFollowTrackRail, CYapfDestinationTileOrStationRailT, CYapfFollowRailT > > CYapfRailBase< CYapfRail_TypesT< CYapfRailNo90, CFollowTrackRailNo90, CYapfDestinationTileOrStationRailT, CYapfFollowRailT > > CYapfAnyDepotRail CYapfAnyDepotRailNo90 CYapfAnySafeTileRail CYapfAnySafeTileRailNo90 CYapfRail CYapfRailNo90

Data Structures

struct  TILE
 Structure used inside PfCalcCost() to keep basic tile information. More...

Public Types

typedef Types::Tpf Tpf
 the pathfinder class (derived from THIS class)
typedef Types::TrackFollower TrackFollower
typedef Types::NodeList::Item Node
 this will be our node type
typedef Node::Key Key
 key to hash tables
typedef Node::CachedData CachedData

Public Member Functions

void SetTreatFirstRedTwoWaySignalAsEOL (bool enabled)
 Sets whether the first two-way signal should be treated as a dead end.
bool TreatFirstRedTwoWaySignalAsEOL ()
 Returns whether the first two-way signal should be treated as a dead end.
int SlopeCost (TileIndex tile, Trackdir td)
int CurveCost (Trackdir td1, Trackdir td2)
int SwitchCost (TileIndex tile1, TileIndex tile2, DiagDirection exitdir)
int OneTileCost (TileIndex tile, Trackdir trackdir)
 Return one tile cost (base cost + level crossing penalty).
bool IsAnyStationTileReserved (TileIndex tile, Trackdir trackdir, int distance)
 Check for a reserved station platform.
int ReservationCost (Node &n, TileIndex tile, Trackdir trackdir, int skipped)
 Calculate the cost for reserved tiles, including skipped ones.
int SignalCost (Node &n, TileIndex tile, Trackdir trackdir)
int PlatformLengthPenalty (int platform_length)
void SetMaxCost (int max_cost)
bool PfCalcCost (Node &n, const TrackFollower *follower)
 Called by YAPF to calculate the cost from the origin to the given node.
bool CanUseGlobalCache (Node &n) const
void ConnectNodeToCachedData (Node &n, CachedData &ci)
void DisableCache (bool disable)

Data Fields

bool stopped_on_first_two_way_signal = false

Protected Member Functions

TpfYapf ()
 Access the inherited path finder.

Protected Attributes

int max_cost = 0
bool disable_cache = false
std::vector< int > sig_look_ahead_costs = {}
bool treat_first_red_two_way_signal_as_eol = false

Static Protected Attributes

static constexpr int MAX_SEGMENT_COST = 10000

Additional Inherited Members

Static Public Member Functions inherited from CYapfCostBase
static bool stSlopeCost (TileIndex tile, Trackdir td)
 Does the given track direction on the given tile yield an uphill penalty?

Detailed Description

template<class Types>
class CYapfCostRailT< Types >

Definition at line 21 of file yapf_costrail.hpp.

Member Typedef Documentation

◆ CachedData

template<class Types>
typedef Node::CachedData CYapfCostRailT< Types >::CachedData

Definition at line 27 of file yapf_costrail.hpp.

◆ Key

template<class Types>
typedef Node::Key CYapfCostRailT< Types >::Key

key to hash tables

Definition at line 26 of file yapf_costrail.hpp.

◆ Node

template<class Types>
typedef Types::NodeList::Item CYapfCostRailT< Types >::Node

this will be our node type

Definition at line 25 of file yapf_costrail.hpp.

◆ Tpf

template<class Types>
typedef Types::Tpf CYapfCostRailT< Types >::Tpf

the pathfinder class (derived from THIS class)

Definition at line 23 of file yapf_costrail.hpp.

◆ TrackFollower

template<class Types>
typedef Types::TrackFollower CYapfCostRailT< Types >::TrackFollower

Definition at line 24 of file yapf_costrail.hpp.

Constructor & Destructor Documentation

◆ CYapfCostRailT()

template<class Types>
CYapfCostRailT< Types >::CYapfCostRailT ( )
inlineprotected

Definition at line 59 of file yapf_costrail.hpp.

Member Function Documentation

◆ CanUseGlobalCache()

template<class Types>
bool CYapfCostRailT< Types >::CanUseGlobalCache ( Node & n) const
inline

Definition at line 636 of file yapf_costrail.hpp.

◆ ConnectNodeToCachedData()

template<class Types>
void CYapfCostRailT< Types >::ConnectNodeToCachedData ( Node & n,
CachedData & ci )
inline

Definition at line 643 of file yapf_costrail.hpp.

◆ CurveCost()

template<class Types>
int CYapfCostRailT< Types >::CurveCost ( Trackdir td1,
Trackdir td2 )
inline

Definition at line 103 of file yapf_costrail.hpp.

◆ DisableCache()

template<class Types>
void CYapfCostRailT< Types >::DisableCache ( bool disable)
inline

Definition at line 652 of file yapf_costrail.hpp.

◆ IsAnyStationTileReserved()

template<class Types>
bool CYapfCostRailT< Types >::IsAnyStationTileReserved ( TileIndex tile,
Trackdir trackdir,
int distance )
inline

Check for a reserved station platform.

Parameters
tileThe tile to check.
trackdirThe direction to check in.
distanceThe number of tiles to check.
Returns
true iff there is any reserved tile in the given direction for the given distance.

Definition at line 166 of file yapf_costrail.hpp.

References HasStationReservation(), ReverseTrackdir(), TileOffsByDiagDir(), and TrackdirToExitdir().

Referenced by ReservationCost().

◆ OneTileCost()

template<class Types>
int CYapfCostRailT< Types >::OneTileCost ( TileIndex tile,
Trackdir trackdir )
inline

Return one tile cost (base cost + level crossing penalty).

Parameters
tileThe tile to consider.
trackdirThe direction of travel.
Returns
The cost.

Definition at line 135 of file yapf_costrail.hpp.

References GetTileType(), IsDiagonalTrackdir(), IsLevelCrossing(), Road, Yapf(), YAPF_TILE_CORNER_LENGTH, and YAPF_TILE_LENGTH.

◆ PfCalcCost()

template<class Types>
bool CYapfCostRailT< Types >::PfCalcCost ( Node & n,
const TrackFollower * follower )
inline

Called by YAPF to calculate the cost from the origin to the given node.

Calculates only the cost of given node, adds it to the parent node cost and stores the result into Node::cost member.

Parameters
nThe node to consider.
followerThe track follower to the next node.
Returns
true iff the costs could be calculated.

Definition at line 294 of file yapf_costrail.hpp.

References _settings_game, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), ChoiceFollows, Vehicle::current_order, DeadEnd, Depot, ESRF_ABORT_PF_MASK, ESRF_CACHED_MASK, ESRF_POSSIBLE_TARGET, FindFirstBit(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), SpecializedStation< Waypoint, true >::Get(), BaseStation::GetByTile(), Order::GetDestination(), Train::GetDisplayMaxSpeed(), Order::GetMaxSpeed(), BaseStation::GetPlatformLength(), GetSignalStateByTrackdir(), GetSignalType(), GetStationIndex(), HasOnewaySignalBlockingTrackdir(), HasSignalOnTrackdir(), HasTrackdir(), InfiniteLoop, INVALID_TILE, INVALID_TRACKDIR, IsPbsSignal(), IsRailDepot(), IsRailDepotTile(), IsRailWaypoint(), IsSafeWaitingPosition(), IsTileType(), Order::IsType(), IsWaitingPositionFree(), KillFirstBit(), 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, PathTooLong, RailType, Railway, RemoveFirstTrackdir(), ReverseDiagDir(), ReverseTrackdir(), SafeTile, SegmentTooLong, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SIGNAL_STATE_RED, SIGTYPE_EXIT, SIGTYPE_PBS_ONEWAY, Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACKDIR_BIT_NONE, TrackdirToExitdir(), TrackdirToTrack(), Waypoint, Yapf(), and YAPF_TILE_LENGTH.

◆ PlatformLengthPenalty()

template<class Types>
int CYapfCostRailT< Types >::PlatformLengthPenalty ( int platform_length)
inline

Definition at line 269 of file yapf_costrail.hpp.

◆ ReservationCost()

template<class Types>
int CYapfCostRailT< Types >::ReservationCost ( Node & n,
TileIndex tile,
Trackdir trackdir,
int skipped )
inline

Calculate the cost for reserved tiles, including skipped ones.

Parameters
nThe current node.
tileThe start tile to look at.
trackdirThe chosen track direction at the tile.
skippedThe number of tiles the path follower skipped.
Returns
The total reservation cost.

Definition at line 183 of file yapf_costrail.hpp.

References GetReservedTrackbits(), IsAnyStationTileReserved(), IsDiagonalTrackdir(), IsPbsSignal(), IsRailStationTile(), TrackdirToTrack(), TrackOverlapsTracks(), Yapf(), YAPF_TILE_CORNER_LENGTH, and YAPF_TILE_LENGTH.

◆ SetMaxCost()

template<class Types>
void CYapfCostRailT< Types >::SetMaxCost ( int max_cost)
inline

Definition at line 288 of file yapf_costrail.hpp.

◆ SetTreatFirstRedTwoWaySignalAsEOL()

template<class Types>
void CYapfCostRailT< Types >::SetTreatFirstRedTwoWaySignalAsEOL ( bool enabled)
inline

Sets whether the first two-way signal should be treated as a dead end.

Parameters
enabledWhether to treat them as dead ends.

Definition at line 83 of file yapf_costrail.hpp.

◆ SignalCost()

template<class Types>
int CYapfCostRailT< Types >::SignalCost ( Node & n,
TileIndex tile,
Trackdir trackdir )
inline

Definition at line 198 of file yapf_costrail.hpp.

◆ SlopeCost()

template<class Types>
int CYapfCostRailT< Types >::SlopeCost ( TileIndex tile,
Trackdir td )
inline

Definition at line 97 of file yapf_costrail.hpp.

◆ SwitchCost()

template<class Types>
int CYapfCostRailT< Types >::SwitchCost ( TileIndex tile1,
TileIndex tile2,
DiagDirection exitdir )
inline

Definition at line 119 of file yapf_costrail.hpp.

◆ TreatFirstRedTwoWaySignalAsEOL()

template<class Types>
bool CYapfCostRailT< Types >::TreatFirstRedTwoWaySignalAsEOL ( )
inline

Returns whether the first two-way signal should be treated as a dead end.

Returns
true iff the rail_firstred_twoway_eol setting is enabled, and it is enabled for this instance.

Definition at line 92 of file yapf_costrail.hpp.

References Yapf().

◆ Yapf()

template<class Types>
Tpf & CYapfCostRailT< Types >::Yapf ( )
inlineprotected

Access the inherited path finder.

Returns
The current path finder.

Definition at line 73 of file yapf_costrail.hpp.

Referenced by OneTileCost(), PfCalcCost(), ReservationCost(), and TreatFirstRedTwoWaySignalAsEOL().

Field Documentation

◆ disable_cache

template<class Types>
bool CYapfCostRailT< Types >::disable_cache = false
protected

Definition at line 49 of file yapf_costrail.hpp.

◆ max_cost

template<class Types>
int CYapfCostRailT< Types >::max_cost = 0
protected
Note
maximum cost doesn't work with caching enabled
Todo
fix maximum cost failing with caching (e.g. FS#2900)

Definition at line 48 of file yapf_costrail.hpp.

◆ MAX_SEGMENT_COST

template<class Types>
int CYapfCostRailT< Types >::MAX_SEGMENT_COST = 10000
staticconstexprprotected

Definition at line 57 of file yapf_costrail.hpp.

◆ sig_look_ahead_costs

template<class Types>
std::vector<int> CYapfCostRailT< Types >::sig_look_ahead_costs = {}
protected

Definition at line 50 of file yapf_costrail.hpp.

◆ stopped_on_first_two_way_signal

template<class Types>
bool CYapfCostRailT< Types >::stopped_on_first_two_way_signal = false

Definition at line 54 of file yapf_costrail.hpp.

◆ treat_first_red_two_way_signal_as_eol

template<class Types>
bool CYapfCostRailT< Types >::treat_first_red_two_way_signal_as_eol = false
protected

Definition at line 51 of file yapf_costrail.hpp.


The documentation for this class was generated from the following file: