OpenTTD Source: src/pathfinder/pathfinder_func.h File Reference

OpenTTD Source 14.0-beta1

Functions
pathfinder_func.h File Reference
`#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) More...
TrackdirBits | GetTrackdirBitsForRoad (TileIndex tile, RoadTramType rtt)
| Wrapper around GetTileTrackStatus() and TrackStatusToTrackdirBits(), as for single tram bits GetTileTrackStatus() returns 0. More...

## 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

  station | The station to calculate the distance to
  tile | The tile from where to calculate the distance
  station_type | the 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 Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::Get(), BaseStation::GetTileArea(), OrthogonalTileArea::h, INVALID_TILE, OrthogonalTileArea::tile, TileX(), 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 GetTileTrackStatus(), TrackStatusToTrackdirBits(), and TRANSPORT_ROAD.

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