OpenTTD Source 20260208-master-g43af8e94d0
yapf_road.cpp File Reference

The road pathfinding. More...

#include "../../stdafx.h"
#include "yapf.hpp"
#include "yapf_node_road.hpp"
#include "../../roadstop_base.h"
#include "../../safeguards.h"

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_, Tdestination >
struct  CYapfRoad
struct  CYapfRoadAnyDepot

Functions

Trackdir YapfRoadVehicleChooseTrack (const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found, RoadVehPathCache &path_cache)
 Finds the best path for given road vehicle using YAPF.
FindDepotData YapfRoadVehicleFindNearestDepot (const RoadVehicle *v, int max_distance)
 Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.

Detailed Description

The road pathfinding.

Definition in file yapf_road.cpp.

Function Documentation

◆ YapfRoadVehicleChooseTrack()

Trackdir YapfRoadVehicleChooseTrack ( const RoadVehicle * v,
TileIndex tile,
DiagDirection enterdir,
TrackdirBits trackdirs,
bool & path_found,
RoadVehPathCache & path_cache )

Finds the best path for given road vehicle using YAPF.

Parameters
vthe RV that needs to find a path
tilethe tile to find the path from (should be next tile the RV is about to enter)
enterdirdiagonal direction which the RV will enter this new tile from
trackdirsavailable trackdirs on the new tile (to choose from)
path_found[out] Whether a path has been found (true) or has been guessed (false)
path_cacheCache of a previously chosen path.
Returns
the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found

Definition at line 508 of file yapf_road.cpp.

References FindFirstBit(), and INVALID_TRACKDIR.

Referenced by RoadFindPathToDest().

◆ YapfRoadVehicleFindNearestDepot()

FindDepotData YapfRoadVehicleFindNearestDepot ( const RoadVehicle * v,
int max_penalty )

Used when user sends road vehicle to the nearest depot or if road vehicle needs servicing using YAPF.

Parameters
vvehicle that needs to go to some depot
max_penaltymax distance (in pathfinder penalty) from the current vehicle position (used also as optimization - the pathfinder can stop path finding if max_penalty was reached and no depot was seen)
Returns
the data about the depot

Definition at line 515 of file yapf_road.cpp.

References GetTrackdirBitsForRoad(), RoadVehicle::GetVehicleTrackdir(), HasTrackdir(), RoadVehicle::roadtype, and Vehicle::tile.