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