Go to the documentation of this file.
192 bool first_loop =
true;
201 while (ft.
Follow(tile, trackdir)) {
229 trackdir = new_trackdir;
237 start_trackdir = trackdir;
241 if (tile == start_tile && trackdir == start_trackdir)
break;
301 if (train_on_res !=
nullptr) {
303 if (ftoti.
best !=
nullptr) *train_on_res = ftoti.
best->
First();
312 if (ftoti.
best !=
nullptr) *train_on_res = ftoti.
best->
First();
318 if (ftoti.
best !=
nullptr) *train_on_res = ftoti.
best->
First();
350 if (ftoti.
best !=
nullptr)
return ftoti.
best;
357 if (ftoti.
best !=
nullptr)
return ftoti.
best;
364 if (ftoti.
best !=
nullptr)
return ftoti.
best;
394 if (!ft.
Follow(tile, trackdir)) {
396 if (include_line_end)
return true;
411 return include_line_end;
442 if (!ft.
Follow(tile, trackdir))
return true;
bool m_is_station
last turn passed station
static Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
bool okay
True if tile is a safe waiting position, false otherwise.
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
uint32 TileIndex
The index/ID of a Tile.
#define TILE_ADD(x, y)
Adds to tiles together.
static bool HasReservedTracks(TileIndex tile, TrackBits tracks)
Check whether some of tracks is reserved on a tile.
@ TRACK_BIT_NONE
No track.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
TileIndex m_old_tile
the origin (vehicle moved from) before move
bool forbid_90_deg
forbid trains to make 90 deg turns
@ TRANSPORT_RAIL
Transport by train.
void SetRailStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
Set the reservation for a complete station platform.
TrackBits GetReservedTrackbits(TileIndex t)
Get the reserved trackbits for any tile, regardless of type.
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static void SetRailStationReservation(TileIndex t, bool b)
Set the reservation state of the rail station.
static bool IsRailStation(TileIndex t)
Is this station tile a rail station?
Tindex index
Index of this pool item.
PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res)
Follow a train reservation to the last tile.
static T KillFirstBit(T value)
Clear the first bit in an integer.
static TrackBits GetCrossingReservationTrackBits(TileIndex t)
Get the reserved track bits for a rail crossing.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
static bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
Check if a tile is a valid continuation to a railstation tile.
static void SetCrossingReservation(TileIndex t, bool b)
Set the reservation state of the rail crossing.
ClientSettings _settings_client
The current settings for this game.
static bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def=_settings_game.pf.forbid_90_deg)
Test if 90 degree turns are disallowed between two railtypes.
Owner owner
Which company owns the vehicle?
Trackdir GetVehicleTrackdir() const
Get the tracks of the train vehicle.
Owner
Enum for all companies/owners.
@ MP_ROAD
A tile with road (or tram tracks)
static bool IsRailDepot(TileIndex t)
Is this rail tile a rail depot?
static bool IsLevelCrossing(TileIndex t)
Return whether a tile is a level crossing.
static bool HasPbsSignalOnTrackdir(TileIndex tile, Trackdir td)
Is a pbs signal present along the trackdir?
static TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
Try to reserve a specific track on a tile.
static TrackBits GetRailReservationTrackBits(TileIndex t)
Returns the reserved track bits of the tile.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
PathfinderSettings pf
settings for all pathfinders
void UnreserveRailTrack(TileIndex tile, Track t)
Lift the reservation of a specific track on a tile.
void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg)
Check if a safe position is free.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
int32 TileIndexDiff
An offset value between to tiles.
TileIndex tile
Current tile index.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
This struct contains information about the end of a reserved path.
@ VS_CRASHED
Vehicle is crashed.
static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Trackdir trackdir, bool ignore_oneway=false)
Follow a reservation starting from a specific tile to the end.
PBSTileInfo res
Information about the track.
Trackdir trackdir
The reserved trackdir on the tile.
static bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
static bool HasDepotReservation(TileIndex t)
Get the reservation state of the depot.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
static bool IsRailDepotTile(TileIndex t)
Is this tile rail tile and a rail depot?
'Train' is either a loco or a wagon.
static bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
Is a one-way signal blocking the trackdir? A one-way signal on the trackdir against will block,...
static bool HasStationReservation(TileIndex t)
Get the reservation state of the rail station.
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
Determine whether a certain track on a tile is a safe position to end a path.
static TrackBits GetDepotReservationTrackBits(TileIndex t)
Get the reserved track bits for a depot.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
void UpdateLevelCrossing(TileIndex tile, bool sound=true)
Sets correct crossing state.
static bool HasCrossingReservation(TileIndex t)
Get the reservation state of the rail crossing.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
DiagDirection
Enumeration for diagonal directions.
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail station?
bool show_track_reservation
highlight reserved tracks.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
static bool TrackOverlapsTracks(TrackBits tracks, Track track)
Check if a given track is contained within or overlaps some other tracks.
static void SetDepotReservation(TileIndex t, bool b)
Set the reservation state of the depot.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
static TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
static TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
Get the reserved track bits for a rail tunnel/bridge.
TileIndex tile
Tile the path ends, INVALID_TILE if no valid path was found.
@ TRACKDIR_BIT_NONE
No track build.
@ SIGTYPE_PBS_ONEWAY
no-entry signal
static bool IsPlainRail(TileIndex t)
Returns whether this is plain rails, with or without signals.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
static void UnreserveTrack(TileIndex tile, Track t)
Lift the reservation of a specific track on a tile.
static void SetTunnelBridgeReservation(TileIndex t, bool b)
Set the reservation state of the rail tunnel/bridge.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
@ MP_STATION
A tile of a station.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
FindTrainOnTrackInfo()
Init the best location to nullptr always!
static void BarCrossing(TileIndex t)
Bar a level crossing.
Train * best
The currently "best" vehicle we have found.
TileIndex m_new_tile
the new tile (the vehicle has entered)
TrackBits
Bitfield corresponding to Track.
@ SRT_PATH_RESERVATION
Trigger platform when train reserves path.
bool Follow(TileIndex old_tile, Trackdir old_td)
main follower routine.
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
DiagDirection m_exitdir
exit direction (leaving the old tile)
TrackdirBits m_new_td_bits
the new set of available trackdirs
RailType GetTileRailType(TileIndex tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
static TrackBits GetStationReservationTrackBits(TileIndex t)
Get the reserved track bits for a waypoint.
Trackdir
Enumeration for tracks and directions.
static Vehicle * FindTrainOnTrackEnum(Vehicle *v, void *data)
Callback for Has/FindVehicleOnPos to find a train on a specific track.
static TileType GetTileType(TileIndex tile)
Get the tiletype of a given tile.
@ VEH_TRAIN
Train vehicle type.
VehicleType type
Type of vehicle.
T * First() const
Get the first vehicle in the chain.
Helper struct for finding the best matching vehicle on a specific track.
Track
These are used to specify a single track.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
static TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
RailTypes
The different railtypes we support, but then a bitmask of them.
static bool HasTrack(TileIndex tile, Track track)
Returns whether the given track is present on the given tile.
static bool TryReserveTrack(TileIndex tile, Track t)
Try to reserve a specific track on a tile.
Track follower helper template class (can serve pathfinders and vehicle controllers).
int m_tiles_skipped
number of skipped tunnel or station tiles
static Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
static Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
GUISettings gui
settings related to the GUI
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.