OpenTTD Source 20260206-master-g4d4e37dbf1
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

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 skipped)
 Check for a reserved station platform.
int ReservationCost (Node &n, TileIndex tile, Trackdir trackdir, int skipped)
 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 ()
 to access 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 616 of file yapf_costrail.hpp.

◆ ConnectNodeToCachedData()

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

Definition at line 623 of file yapf_costrail.hpp.

◆ CurveCost()

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

Definition at line 97 of file yapf_costrail.hpp.

◆ DisableCache()

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

Definition at line 632 of file yapf_costrail.hpp.

◆ IsAnyStationTileReserved()

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

Check for a reserved station platform.

Definition at line 149 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).

Definition at line 124 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

Definition at line 274 of file yapf_costrail.hpp.

References _settings_game, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), ChoiceFollows, Vehicle::current_order, DeadEnd, Depot, 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(), GetStationIndex(), HasOnewaySignalBlockingTrackdir(), HasSignalOnTrackdir(), HasTrackdir(), InfiniteLoop, INVALID_TILE, INVALID_TRACKDIR, 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 245 of file yapf_costrail.hpp.

◆ ReservationCost()

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

◆ SetMaxCost()

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

Definition at line 264 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.

Definition at line 80 of file yapf_costrail.hpp.

◆ SignalCost()

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

Definition at line 174 of file yapf_costrail.hpp.

◆ SlopeCost()

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

Definition at line 91 of file yapf_costrail.hpp.

◆ SwitchCost()

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

Definition at line 113 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.

Definition at line 86 of file yapf_costrail.hpp.

References Yapf().

◆ Yapf()

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

to access inherited 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: