# yapf_road.cpp File Reference

The road pathfinding. More...

`#include "../stdafx.h"`
`#include "../depot_base.h"`
`#include "../station_base.h"`
`#include "../roadveh.h"`
`#include "../cargotype.h"`
`#include "../newgrf_cargo.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 | CYapfDestinationAnyRoadVehicleCompatibleStopOfGivenStationT< Types >
class | CYapfDestinationTileRoadT< Types >
class | CYapfFollowRoadT< Types >
struct | CYapfRoad_TypesT< Tpf_, Tnode_list, Tdestination >
struct | CYapfRoad1
struct | CYapfRoad2
struct | CYapfRoadAnyDepot1
struct | CYapfRoadAnyDepot2
struct | CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation1
struct | CYapfRoadAnyRoadVehicleCompatibleStopOfGivenStation2

## Functions

Trackdir | YapfChooseRoadTrack (const 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.
bool | YapfFindNearestRoadVehicleCompatibleStop (const Vehicle *v, StationID station, TileIndex *stop_tile)
| Used to determinine the closest reachable compatible road stop for a given vehicle.

## Detailed Description

The road pathfinding.

Definition in file yapf_road.cpp.

## Function Documentation

Trackdir YapfChooseRoadTrack | ( | const 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 536 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GameSettings::pf, and PathfinderSettings::yapf.

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 572 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GetDepotByTile(), GetTileTrackStatus(), GetVehicleTrackdir(), GameSettings::pf, TrackdirToTrackdirBits(), TrackStatusToTrackdirBits(), TRANSPORT_ROAD, and PathfinderSettings::yapf.

bool YapfFindNearestRoadVehicleCompatibleStop | ( | const Vehicle * | v,
|  | StationID | station,
|  | TileIndex * | stop_tile |
| ) |  |  |

Used to determinine the closest reachable compatible road stop for a given vehicle.

Parameters:

  | v | vehicle that needs to go to the road stop
  | station | the station the road stop must belong to
  | stop_tile | receives the stop tile if a stop was found

Returns:
  true if stop was found.

Definition at line 599 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GetTileTrackStatus(), GetVehicleTrackdir(), INVALID_TILE, GameSettings::pf, TrackdirToTrackdirBits(), TrackStatusToTrackdirBits(), TRANSPORT_ROAD, RoadStop::xy, and PathfinderSettings::yapf.

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 551 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GameSettings::pf, and PathfinderSettings::yapf.