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