OpenTTD Source 20241224-master-gee860a5c8e
CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks > Struct Template Reference

Track follower helper template class (can serve pathfinders and vehicle controllers). More...

#include <follow_track.hpp>

Inheritance diagram for CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >:
DummyFollower

Public Types

enum  ErrorCode {
  EC_NONE , EC_OWNER , EC_RAIL_ROAD_TYPE , EC_90DEG ,
  EC_NO_WAY , EC_RESERVED
}
 

Public Member Functions

 CFollowTrackT (const VehicleType *v=nullptr, RailTypes railtype_override=INVALID_RAILTYPES)
 
 CFollowTrackT (Owner o, RailTypes railtype_override=INVALID_RAILTYPES)
 
void Init (const VehicleType *v, RailTypes railtype_override)
 
void Init (Owner o, RailTypes railtype_override)
 
bool IsTram ()
 
DiagDirection GetSingleTramBit (TileIndex tile)
 Tests if a tile is a road tile with a single tramtrack (tram can reverse)
 
bool Follow (TileIndex old_tile, Trackdir old_td)
 main follower routine.
 
bool MaskReservedTracks ()
 
int GetSpeedLimit (int *pmin_speed=nullptr) const
 Helper for pathfinders - get min/max speed on the old_tile/old_td.
 

Static Public Member Functions

static debug_inline TransportType TT ()
 
static debug_inline bool IsWaterTT ()
 
static debug_inline bool IsRailTT ()
 
static debug_inline bool IsRoadTT ()
 
static bool Allow90degTurns ()
 
static bool DoTrackMasking ()
 

Data Fields

const VehicleTypeveh
 moving vehicle
 
Owner veh_owner
 owner of the vehicle
 
TileIndex old_tile
 the origin (vehicle moved from) before move
 
Trackdir old_td
 the trackdir (the vehicle was on) before move
 
TileIndex new_tile
 the new tile (the vehicle has entered)
 
TrackdirBits new_td_bits
 the new set of available trackdirs
 
DiagDirection exitdir
 exit direction (leaving the old tile)
 
bool is_tunnel
 last turn passed tunnel
 
bool is_bridge
 last turn passed bridge ramp
 
bool is_station
 last turn passed station
 
int tiles_skipped
 number of skipped tunnel or station tiles
 
ErrorCode err
 
RailTypes railtypes
 

Protected Member Functions

void FollowTileExit ()
 Follow the exitdir from old_tile and fill new_tile and tiles_skipped.
 
bool QueryNewTileTrackStatus ()
 stores track status (available trackdirs) for the new tile into new_td_bits
 
bool CanExitOldTile ()
 return true if we can leave old_tile in exitdir
 
bool CanEnterNewTile ()
 return true if we can enter new_tile from exitdir
 
bool ForcedReverse ()
 return true if we must reverse (in depots and single tram bits)
 
bool TryReverse ()
 return true if we successfully reversed at end of road/track
 

Detailed Description

template<TransportType Ttr_type_, typename VehicleType, bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
struct CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >

Track follower helper template class (can serve pathfinders and vehicle controllers).

See 6 different typedefs below for 3 different transport types w/ or w/o 90-deg turns allowed

Definition at line 28 of file follow_track.hpp.

Member Enumeration Documentation

◆ ErrorCode

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
enum CFollowTrackT::ErrorCode

Definition at line 30 of file follow_track.hpp.

Constructor & Destructor Documentation

◆ CFollowTrackT() [1/2]

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CFollowTrackT ( const VehicleType v = nullptr,
RailTypes  railtype_override = INVALID_RAILTYPES 
)
inline

Definition at line 53 of file follow_track.hpp.

◆ CFollowTrackT() [2/2]

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CFollowTrackT ( Owner  o,
RailTypes  railtype_override = INVALID_RAILTYPES 
)
inline

Definition at line 58 of file follow_track.hpp.

Member Function Documentation

◆ Allow90degTurns()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
static bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Allow90degTurns ( )
inlinestatic

Definition at line 96 of file follow_track.hpp.

◆ CanEnterNewTile()

◆ CanExitOldTile()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanExitOldTile ( )
inlineprotected

◆ DoTrackMasking()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
static bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::DoTrackMasking ( )
inlinestatic

Definition at line 97 of file follow_track.hpp.

◆ Follow()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow ( TileIndex  old_tile,
Trackdir  old_td 
)
inline

main follower routine.

Fills all members and return true on success. Otherwise returns false if track can't be followed.

Definition at line 121 of file follow_track.hpp.

References CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanEnterNewTile(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::CanExitOldTile(), DiagdirReachesTrackdirs(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::ForcedReverse(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSingleTramBit(), GetTileRailType(), GetTileTrackStatus(), INVALID_DIAGDIR, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_td, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), Rail90DegTurnDisallowed(), TRACKDIR_BIT_NONE, TrackdirCrossesTrackdirs(), TrackdirToExitdir(), TrackdirToTrackdirBits(), TrackStatusToTrackdirBits(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::TryReverse().

Referenced by CheckNextTrainTile(), ExtendTrainReservation(), FollowReservation(), WaterRegion::ForceUpdate(), FreeTrainTrackReservation(), IsSafeWaitingPosition(), IsWaitingPositionFree(), and CYapfCostRailT< Types >::PfCalcCost().

◆ FollowTileExit()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
void CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::FollowTileExit ( )
inlineprotected

◆ ForcedReverse()

◆ GetSingleTramBit()

◆ GetSpeedLimit()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
int CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit ( int *  pmin_speed = nullptr) const
inline

◆ Init() [1/2]

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
void CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Init ( const VehicleType v,
RailTypes  railtype_override 
)
inline

Definition at line 65 of file follow_track.hpp.

◆ Init() [2/2]

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
void CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Init ( Owner  o,
RailTypes  railtype_override 
)
inline

Definition at line 72 of file follow_track.hpp.

◆ IsRailTT()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
static debug_inline bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::IsRailTT ( )
inlinestatic

Definition at line 93 of file follow_track.hpp.

◆ IsRoadTT()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
static debug_inline bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::IsRoadTT ( )
inlinestatic

Definition at line 95 of file follow_track.hpp.

◆ IsTram()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::IsTram ( )
inline

Definition at line 94 of file follow_track.hpp.

◆ IsWaterTT()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
static debug_inline bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::IsWaterTT ( )
inlinestatic

Definition at line 92 of file follow_track.hpp.

◆ MaskReservedTracks()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::MaskReservedTracks ( )
inline

Definition at line 171 of file follow_track.hpp.

◆ QueryNewTileTrackStatus()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus ( )
inlineprotected

◆ TryReverse()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::TryReverse ( )
inlineprotected

◆ TT()

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
static debug_inline TransportType CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::TT ( )
inlinestatic

Definition at line 91 of file follow_track.hpp.

Field Documentation

◆ err

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
ErrorCode CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::err

Definition at line 50 of file follow_track.hpp.

◆ exitdir

◆ is_bridge

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_bridge

last turn passed bridge ramp

Definition at line 47 of file follow_track.hpp.

Referenced by WaterRegion::ForceUpdate(), and FreeTrainTrackReservation().

◆ is_station

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_station

last turn passed station

Definition at line 48 of file follow_track.hpp.

Referenced by ExtendTrainReservation(), FollowReservation(), and FreeTrainTrackReservation().

◆ is_tunnel

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
bool CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::is_tunnel

last turn passed tunnel

Definition at line 46 of file follow_track.hpp.

Referenced by FreeTrainTrackReservation().

◆ new_td_bits

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
TrackdirBits CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_td_bits

◆ new_tile

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
TileIndex CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::new_tile

◆ old_td

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
Trackdir CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::old_td

◆ old_tile

◆ railtypes

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
RailTypes CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::railtypes

Definition at line 51 of file follow_track.hpp.

◆ tiles_skipped

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
int CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::tiles_skipped

◆ veh

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
const VehicleType* CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::veh

moving vehicle

Definition at line 39 of file follow_track.hpp.

◆ veh_owner

template<TransportType Ttr_type_, typename VehicleType , bool T90deg_turns_allowed_ = true, bool Tmask_reserved_tracks = false>
Owner CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::veh_owner

owner of the vehicle

Definition at line 40 of file follow_track.hpp.


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