OpenTTD Source 20241224-master-gee860a5c8e
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(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::Get(), 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.

Definition at line 60 of file pathfinder_func.h.

References GetRoadBits(), GetTileTrackStatus(), IsNormalRoadTile(), ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, TRACKDIR_BIT_NONE, TRACKDIR_BIT_X_NE, TRACKDIR_BIT_X_SW, TRACKDIR_BIT_Y_NW, TRACKDIR_BIT_Y_SE, TrackStatusToTrackdirBits(), and TRANSPORT_ROAD.

Referenced by CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::QueryNewTileTrackStatus(), CYapfFollowRoadT< Types >::SetOriginFromVehiclePos(), and YapfRoadVehicleFindNearestDepot().