OpenTTD Source  20241120-master-g6d3adc6169
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. More...
 
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 Function Documentation

◆ 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

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