OpenTTD
|
Track follower helper template class (can serve pathfinders and vehicle controllers). More...
#include <follow_track.hpp>
Public Types | |
enum | ErrorCode { EC_NONE, EC_OWNER, EC_RAIL_TYPE, EC_90DEG, EC_NO_WAY, EC_RESERVED } |
Public Member Functions | |
CFollowTrackT (const VehicleType *v=NULL, RailTypes railtype_override=INVALID_RAILTYPES, CPerformanceTimer *pPerf=NULL) | |
CFollowTrackT (Owner o, RailTypes railtype_override=INVALID_RAILTYPES, CPerformanceTimer *pPerf=NULL) | |
void | Init (const VehicleType *v, RailTypes railtype_override, CPerformanceTimer *pPerf) |
void | Init (Owner o, RailTypes railtype_override, CPerformanceTimer *pPerf) |
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=NULL) const |
Helper for pathfinders - get min/max speed on the m_old_tile/m_old_td. |
Static Public Member Functions | |
static TransportType | TT () |
static bool | IsWaterTT () |
static bool | IsRailTT () |
static bool | IsRoadTT () |
static bool | Allow90degTurns () |
static bool | DoTrackMasking () |
Data Fields | |
const VehicleType * | m_veh |
moving vehicle | |
Owner | m_veh_owner |
owner of the vehicle | |
TileIndex | m_old_tile |
the origin (vehicle moved from) before move | |
Trackdir | m_old_td |
the trackdir (the vehicle was on) before move | |
TileIndex | m_new_tile |
the new tile (the vehicle has entered) | |
TrackdirBits | m_new_td_bits |
the new set of available trackdirs | |
DiagDirection | m_exitdir |
exit direction (leaving the old tile) | |
bool | m_is_tunnel |
last turn passed tunnel | |
bool | m_is_bridge |
last turn passed bridge ramp | |
bool | m_is_station |
last turn passed station | |
int | m_tiles_skipped |
number of skipped tunnel or station tiles | |
ErrorCode | m_err |
CPerformanceTimer * | m_pPerf |
RailTypes | m_railtypes |
Protected Member Functions | |
void | FollowTileExit () |
Follow the m_exitdir from m_old_tile and fill m_new_tile and m_tiles_skipped. | |
bool | QueryNewTileTrackStatus () |
stores track status (available trackdirs) for the new tile into m_new_td_bits | |
bool | CanExitOldTile () |
return true if we can leave m_old_tile in m_exitdir | |
bool | CanEnterNewTile () |
return true if we can enter m_new_tile from m_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 |
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 30 of file follow_track.hpp.
|
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(), SpecializedVehicle< RoadVehicle, Type >::From(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSingleTramBit(), GetTileTrackStatus(), INVALID_DIAGDIR, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_exitdir, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_old_td, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_old_tile, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_veh, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), TRACKDIR_BIT_NONE, TrackdirCrossesTrackdirs(), TrackdirToExitdir(), TrackdirToTrackdirBits(), TrackStatusToTrackdirBits(), and CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::TryReverse().
Referenced by CheckNextTrainTile(), ExtendTrainReservation(), FollowReservation(), FreeTrainTrackReservation(), IsSafeWaitingPosition(), IsWaitingPositionFree(), and CYapfCostRailT< Types >::PfCalcCost().