OpenTTD Source  20240919-master-gdf0233f4c2
yapf_ship_regions.cpp File Reference
#include "../../stdafx.h"
#include "../../ship.h"
#include "yapf.hpp"
#include "yapf_ship_regions.h"
#include "../water_regions.h"
#include "../../safeguards.h"

Go to the source code of this file.

Data Structures

struct  CYapfRegionPatchNodeKey
 Yapf Node Key that represents a single patch of interconnected water within a water region. More...
 
struct  CYapfRegionNodeT< Tkey_ >
 Yapf Node for water regions. More...
 
class  CYapfOriginRegionT< Types >
 YAPF origin for water regions. More...
 
class  CYapfDestinationRegionT< Types >
 YAPF destination provider for water regions. More...
 
class  CYapfFollowRegionT< Types >
 YAPF node following for water region pathfinding. More...
 
class  CYapfCostRegionT< Types >
 Cost Provider of YAPF for water regions. More...
 
struct  DummyFollower
 
struct  CYapfRegion_TypesT< Tpf_, Tnode_list >
 Config struct of YAPF for route planning. More...
 
struct  CYapfRegionWater
 

Typedefs

typedef CNodeList_HashTableT< CYapfRegionNodeT< CYapfRegionPatchNodeKey >, 12, 12 > CRegionNodeListWater
 

Functions

uint ManhattanDistance (const CYapfRegionPatchNodeKey &a, const CYapfRegionPatchNodeKey &b)
 
std::vector< WaterRegionPatchDescYapfShipFindWaterRegionPath (const Ship *v, TileIndex start_tile, int max_returned_path_length)
 Finds a path at the water region level. More...
 

Variables

constexpr int DIRECT_NEIGHBOR_COST = 100
 
constexpr int NODES_PER_REGION = 4
 
constexpr int MAX_NUMBER_OF_NODES = 65536
 

Detailed Description

Implementation of YAPF for water regions, which are used for finding intermediate ship destinations.

Definition in file yapf_ship_regions.cpp.

Function Documentation

◆ YapfShipFindWaterRegionPath()

std::vector<WaterRegionPatchDesc> YapfShipFindWaterRegionPath ( const Ship v,
TileIndex  start_tile,
int  max_returned_path_length 
)

Finds a path at the water region level.

Note that the starting region is always included if the path was found.

Parameters
vThe ship to find a path for.
start_tileThe tile to start searching from.
max_returned_path_lengthThe maximum length of the path that will be returned.
Returns
A path of water region patches, or an empty vector if no path was found.

Definition at line 310 of file yapf_ship_regions.cpp.