191 bool first_loop =
true;
200 while (ft.
Follow(tile, trackdir)) {
228 trackdir = new_trackdir;
236 start_trackdir = trackdir;
240 if (tile == start_tile && trackdir == start_trackdir)
break;
300 if (train_on_res !=
nullptr) {
302 if (ftoti.
best !=
nullptr) *train_on_res = ftoti.
best->
First();
311 if (ftoti.
best !=
nullptr) *train_on_res = ftoti.
best->
First();
317 if (ftoti.
best !=
nullptr) *train_on_res = ftoti.
best->
First();
349 if (ftoti.
best !=
nullptr)
return ftoti.
best;
356 if (ftoti.
best !=
nullptr)
return ftoti.
best;
363 if (ftoti.
best !=
nullptr)
return ftoti.
best;
393 if (!ft.
Follow(tile, trackdir)) {
395 if (include_line_end)
return true;
410 return include_line_end;
441 if (!ft.
Follow(tile, trackdir))
return true;
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T KillFirstBit(T value)
Clear the first bit in an integer.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
RailTypes compatible_railtypes
bitmask to the OTHER railtypes on which an engine of THIS railtype can physically travel
Owner
Enum for all companies/owners.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
DiagDirection
Enumeration for diagonal directions.
Template function for track followers.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
constexpr TileIndex TileAdd(TileIndex tile, TileIndexDiff offset)
Adds a given offset to a tile.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
int32_t TileIndexDiff
An offset value between two tiles.
void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
Header file for NewGRF stations.
@ SRT_PATH_RESERVATION
Trigger platform when train reserves path.
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 Vehicle * FindTrainOnTrackEnum(Vehicle *v, void *data)
Callback for Has/FindVehicleOnPos to find a train on a specific track.
PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res)
Follow a train reservation to the last tile.
bool TryReserveRailTrack(TileIndex tile, Track t, bool trigger_stations)
Try to reserve a specific track on a tile.
Train * GetTrainForReservation(TileIndex tile, Track track)
Find the train which has reserved a specific path.
bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg)
Check if a safe position is free.
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.
void UnreserveRailTrack(TileIndex tile, Track t)
Lift the reservation of a specific track on a tile.
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.
bool HasReservedTracks(TileIndex tile, TrackBits tracks)
Check whether some of tracks is reserved on a tile.
RailType GetTileRailType(Tile tile)
Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def=_settings_game.pf.forbid_90_deg)
Test if 90 degree turns are disallowed between two railtypes.
bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
Is a one-way signal blocking the trackdir? A one-way signal on the trackdir against will block,...
bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
Checks for the presence of signals along the given trackdir on the given rail tile.
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
Is a pbs signal present along the trackdir?
static debug_inline bool IsRailDepot(Tile t)
Is this rail tile a rail depot?
void UnreserveTrack(Tile tile, Track t)
Lift the reservation of a specific track on a tile.
void SetDepotReservation(Tile t, bool b)
Set the reservation state of the depot.
TrackBits GetDepotReservationTrackBits(Tile t)
Get the reserved track bits for a depot.
static debug_inline bool IsPlainRail(Tile t)
Returns whether this is plain rails, with or without signals.
TrackBits GetRailReservationTrackBits(Tile t)
Returns the reserved track bits of the tile.
bool HasDepotReservation(Tile t)
Get the reservation state of the depot.
bool TryReserveTrack(Tile tile, Track t)
Try to reserve a specific track on a tile.
bool HasTrack(Tile tile, Track track)
Returns whether the given track is present on the given tile.
RailTypes
Allow incrementing of Track variables.
void UpdateLevelCrossing(TileIndex tile, bool sound=true, bool force_bar=false)
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
bool HasCrossingReservation(Tile t)
Get the reservation state of the rail crossing.
TrackBits GetCrossingReservationTrackBits(Tile t)
Get the reserved track bits for a rail crossing.
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
@ SIGTYPE_PBS_ONEWAY
no-entry signal
bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
Check if a tile is a valid continuation to a railstation tile.
bool IsRailStationTile(Tile t)
Is this tile a station tile and a rail station?
bool IsRailStation(Tile t)
Is this station tile a rail station?
void SetRailStationReservation(Tile t, bool b)
Set the reservation state of the rail station.
Axis GetRailStationAxis(Tile t)
Get the rail direction of a rail station.
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
bool HasStationReservation(Tile t)
Get the reservation state of the rail station.
TrackBits GetStationReservationTrackBits(Tile t)
Get the reserved track bits for a waypoint.
Definition of base types and functions in a cross-platform compatible way.
VehicleType type
Type of vehicle.
Track follower helper template class (can serve pathfinders and vehicle controllers).
bool Follow(TileIndex old_tile, Trackdir old_td)
main follower routine.
int tiles_skipped
number of skipped tunnel or station tiles
DiagDirection exitdir
exit direction (leaving the old tile)
TrackdirBits new_td_bits
the new set of available trackdirs
TileIndex new_tile
the new tile (the vehicle has entered)
bool is_station
last turn passed station
TileIndex old_tile
the origin (vehicle moved from) before move
GUISettings gui
settings related to the GUI
Helper struct for finding the best matching vehicle on a specific track.
PBSTileInfo res
Information about the track.
FindTrainOnTrackInfo()
Init the best location to nullptr always!
Train * best
The currently "best" vehicle we have found.
bool show_track_reservation
highlight reserved tracks.
PathfinderSettings pf
settings for all pathfinders
This struct contains information about the end of a reserved path.
Trackdir trackdir
The reserved trackdir on the tile.
TileIndex tile
Tile the path ends, INVALID_TILE if no valid path was found.
bool okay
True if tile is a safe waiting position, false otherwise.
bool forbid_90_deg
forbid trains to make 90 deg turns
Tindex index
Index of this pool item.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
T * First() const
Get the first vehicle in the chain.
'Train' is either a loco or a wagon.
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
TileIndex tile
Current tile index.
Owner owner
Which company owns the vehicle?
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
static debug_inline TileType GetTileType(Tile tile)
Get the tiletype of a given tile.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ MP_ROAD
A tile with road (or tram tracks)
@ MP_STATION
A tile of a station.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Trackdir TrackToTrackdir(Track track)
Returns a Trackdir for the given Track.
Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
bool TrackOverlapsTracks(TrackBits tracks, Track track)
Check if a given track is contained within or overlaps some other tracks.
TrackBits TrackToTrackBits(Track track)
Maps a Track to the corresponding TrackBits value.
TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
Trackdir FindFirstTrackdir(TrackdirBits trackdirs)
Returns first Trackdir from TrackdirBits or INVALID_TRACKDIR.
TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
Trackdir DiagDirToDiagTrackdir(DiagDirection diagdir)
Maps a (4-way) direction to the diagonal trackdir that runs in that direction.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
Discards all directional information from a TrackdirBits value.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
@ TRACK_BIT_NONE
No track.
Trackdir
Enumeration for tracks and directions.
TrackdirBits
Allow incrementing of Trackdir variables.
@ TRACKDIR_BIT_NONE
No track build.
Track
These are used to specify a single track.
@ TRANSPORT_RAIL
Transport by train.
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
TrackBits GetTunnelBridgeReservationTrackBits(Tile t)
Get the reserved track bits for a rail tunnel/bridge.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
void SetTunnelBridgeReservation(Tile t, bool b)
Set the reservation state of the rail tunnel/bridge.
void FindVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Find a vehicle from a specific location.
@ VS_CRASHED
Vehicle is crashed.
Functions related to vehicles.
@ VEH_TRAIN
Train vehicle type.
Functions related to (drawing on) viewports.