OpenTTD Source 20250312-master-gcdcc6b491d
CYapfCostRailT< Types > Class Template Reference
Inheritance diagram for CYapfCostRailT< Types >:
CYapfCostBase

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 *tf)
 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 618 of file yapf_costrail.hpp.

◆ ConnectNodeToCachedData()

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

Definition at line 625 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 634 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 CYapfCostRailT< Types >::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(), MP_ROAD, CYapfCostRailT< Types >::Yapf(), YAPF_TILE_CORNER_LENGTH, and YAPF_TILE_LENGTH.

◆ PfCalcCost()

template<class Types >
bool CYapfCostRailT< Types >::PfCalcCost ( Node n,
const TrackFollower *  tf 
)
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, ChoiceFollows, Vehicle::current_order, DeadEnd, Depot, FindFirstBit(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), PathfinderSettings::forbid_90_deg, 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(), Waypoint::IsSingleTile(), IsTileType(), Order::IsType(), IsWaitingPositionFree(), KillFirstBit(), CYapfCostRailT< Types >::max_cost, MP_RAILWAY, MP_STATION, 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, GameSettings::pf, RailType, RemoveFirstTrackdir(), ReverseDiagDir(), ReverseTrackdir(), SafeTile, SegmentTooLong, SIGNAL_STATE_RED, SIGTYPE_EXIT, SIGTYPE_PBS_ONEWAY, Station, TRACKDIR_BIT_NONE, TrackdirToExitdir(), TrackdirToTrack(), Waypoint, CYapfCostRailT< Types >::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 CYapfCostRailT< Types >::Yapf().

◆ Yapf()

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

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.

Referenced by CYapfCostRailT< Types >::PfCalcCost().

◆ MAX_SEGMENT_COST

template<class Types >
constexpr 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: