OpenTTD Source 20260421-master-gc2fbc6fdeb
pathfinder_func.h File Reference

General functions related to pathfinders. More...

#include "../tile_cmd.h"
#include "../waypoint_base.h"

Go to the source code of this file.

Functions

TileIndex CalcClosestStationTile (StationID station, TileIndex tile, StationType station_type)
 Calculates the tile of given station that is closest to a given tile for this we assume the station is a rectangle, as defined by its tile are (st->train_station).
TrackdirBits GetTrackdirBitsForRoad (TileIndex tile, RoadTramType rtt)
 Wrapper around GetTileTrackStatus() and TrackStatusToTrackdirBits(), as for single tram bits GetTileTrackStatus() returns 0.

Detailed Description

General functions related to pathfinders.

Definition in file pathfinder_func.h.

Function Documentation

◆ CalcClosestStationTile()

TileIndex CalcClosestStationTile ( StationID station,
TileIndex tile,
StationType station_type )
inline

Calculates the tile of given station that is closest to a given tile for this we assume the station is a rectangle, as defined by its tile are (st->train_station).

Parameters
stationThe station to calculate the distance to
tileThe tile from where to calculate the distance
station_typethe station type to get the closest tile of
Returns
The closest station tile to the given tile.

Definition at line 25 of file pathfinder_func.h.

References ClampU(), BaseStation::GetTileArea(), OrthogonalTileArea::h, INVALID_TILE, OrthogonalTileArea::tile, TileX(), TileXY(), TileY(), OrthogonalTileArea::w, and BaseStation::xy.

◆ GetTrackdirBitsForRoad()

TrackdirBits GetTrackdirBitsForRoad ( TileIndex tile,
RoadTramType rtt )
inline

Wrapper around GetTileTrackStatus() and TrackStatusToTrackdirBits(), as for single tram bits GetTileTrackStatus() returns 0.

The reason for this is that there are no half-tile TrackBits in OpenTTD. This tile, however, is a valid tile for trams, one on which they can reverse safely. To "fix" this, pretend that if we are on a half-tile, we are in fact on a straight tram track tile. CFollowTrackT will make sure the pathfinders cannot exit on the wrong side and allows reversing on such tiles.

Parameters
tileThe tile to check.
rttWhether to check the road or tram type.
Returns
The trackdir bits on the tile.

Definition at line 62 of file pathfinder_func.h.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), GetRoadBits(), GetTileTrackStatus(), IsNormalRoadTile(), NE, NW, SE, SW, TRACKDIR_BIT_NONE, TRACKDIR_BIT_X_NE, TRACKDIR_BIT_X_SW, TRACKDIR_BIT_Y_NW, TRACKDIR_BIT_Y_SE, TrackStatusToTrackdirBits(), Tram, and TRANSPORT_ROAD.

Referenced by CFollowTrackT< TRANSPORT_WATER, Ship, true >::QueryNewTileTrackStatus(), CYapfFollowRoadT< Types >::SetOriginFromVehiclePos(), and YapfRoadVehicleFindNearestDepot().