# yapf_road.cpp File Reference

`#include "../stdafx.h"`
`#include "yapf.hpp"`
`#include "yapf_node_road.hpp"`

Go to the source code of this file.

## Data Structures
class | CYapfCostRoadT< Types >
class | CYapfDestinationAnyDepotRoadT< Types >
class | CYapfDestinationTileRoadT< Types >
class | CYapfFollowRoadT< Types >
struct | CYapfRoad_TypesT< Tpf_, Tnode_list, Tdestination >
struct | CYapfRoad1
struct | CYapfRoad2
struct | CYapfRoadAnyDepot1
struct | CYapfRoadAnyDepot2
## Functions
Trackdir | YapfChooseRoadTrack (Vehicle *v, TileIndex tile, DiagDirection enterdir)
| Finds the best path for given road vehicle.
uint | YapfRoadVehDistanceToTile (const Vehicle *v, TileIndex tile)
| Used by RV multistop feature to find the nearest road stop that has a free slot.
Depot * | YapfFindNearestRoadDepot (const Vehicle *v)
| Used when user sends RV to the nearest depot or if RV needs servicing.

## Detailed Description

Definition in file yapf_road.cpp.

## Function Documentation

Trackdir YapfChooseRoadTrack | ( | Vehicle * | v,
|  | TileIndex | tile,
|  | DiagDirection | enterdir |
| ) |  |  |

Finds the best path for given road vehicle.

Parameters:

  | v | the RV that needs to find a path
  | tile | the tile to find the path from (should be next tile the RV is about to enter)
  | enterdir | diagonal direction which the RV will enter this new tile from

Returns:
  the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found

Definition at line 403 of file yapf_road.cpp.

Referenced by RoadFindPathToDest().

Depot* YapfFindNearestRoadDepot | ( | const Vehicle * | v | ) |

Used when user sends RV to the nearest depot or if RV needs servicing.

Returns the nearest depot (or NULL if depot was not found).

Definition at line 435 of file yapf_road.cpp.

References GetDepotByTile(), GetVehicleTrackdir(), IsTileDepotType(), IsTileType(), MP_ROAD, TrackdirToTrackdirBits(), and TrackStatusToTrackdirBits().

uint YapfRoadVehDistanceToTile | ( | const Vehicle * | v,
|  | TileIndex | tile |
| ) |  |  |

Used by RV multistop feature to find the nearest road stop that has a free slot.

Parameters:

  | v | RV (its current tile will be the origin)
  | tile | destination tile

Returns:
  distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found

Definition at line 417 of file yapf_road.cpp.