OpenTTD Source 20260206-master-g4d4e37dbf1
yapf_ship.cpp File Reference

Implementation of YAPF for ships. More...

#include "../../stdafx.h"
#include "../../ship.h"
#include "../../vehicle_func.h"
#include "yapf.hpp"
#include "yapf_node_ship.hpp"
#include "yapf_ship_regions.h"
#include "../water_regions.h"
#include "../../safeguards.h"

Go to the source code of this file.

Data Structures

class  CYapfDestinationTileWaterT< Types >
class  CYapfFollowShipT< Types >
 Node Follower module of YAPF for ships. More...
class  CYapfCostShipT< Types >
 Cost Provider module of YAPF for ships. More...
struct  CYapfShip_TypesT< Tpf_ >
 Config struct of YAPF for ships. More...
struct  CYapfShip

Functions

Track YapfShipChooseTrack (const Ship *v, TileIndex tile, bool &path_found, ShipPathCache &path_cache)
 Ship controller helper - path finder invoker.
bool YapfShipCheckReverse (const Ship *v, Trackdir *trackdir)
 Returns true if it is better to reverse the ship before leaving depot using YAPF.

Variables

constexpr int NUMBER_OR_WATER_REGIONS_LOOKAHEAD = 4
constexpr int MAX_SHIP_PF_NODES = (NUMBER_OR_WATER_REGIONS_LOOKAHEAD + 1) * WATER_REGION_NUMBER_OF_TILES * 4
constexpr int SHIP_LOST_PATH_LENGTH = 8

Detailed Description

Implementation of YAPF for ships.

Definition in file yapf_ship.cpp.

Function Documentation

◆ YapfShipCheckReverse()

bool YapfShipCheckReverse ( const Ship * v,
Trackdir * trackdir )

Returns true if it is better to reverse the ship before leaving depot using YAPF.

Parameters
vthe ship leaving the depot
trackdir[out] the best of all possible reversed trackdirs
Returns
true if reversing is better

Definition at line 438 of file yapf_ship.cpp.

References CYapfFollowShipT< Types >::CheckShipReverse().

◆ YapfShipChooseTrack()

Track YapfShipChooseTrack ( const Ship * v,
TileIndex tile,
bool & path_found,
ShipPathCache & path_cache )

Ship controller helper - path finder invoker.

Finds the best path for given ship using YAPF.

Definition at line 430 of file yapf_ship.cpp.

References Ship::GetVehicleTrackdir(), INVALID_TRACK, INVALID_TRACKDIR, TRACKDIR_BIT_NONE, TrackdirToTrack(), and TrackdirToTrackdirBits().

Referenced by ChooseShipTrack().

Variable Documentation

◆ MAX_SHIP_PF_NODES

int MAX_SHIP_PF_NODES = (NUMBER_OR_WATER_REGIONS_LOOKAHEAD + 1) * WATER_REGION_NUMBER_OF_TILES * 4
constexpr

Definition at line 22 of file yapf_ship.cpp.

◆ NUMBER_OR_WATER_REGIONS_LOOKAHEAD

int NUMBER_OR_WATER_REGIONS_LOOKAHEAD = 4
constexpr

Definition at line 21 of file yapf_ship.cpp.

◆ SHIP_LOST_PATH_LENGTH

int SHIP_LOST_PATH_LENGTH = 8
constexpr

Definition at line 24 of file yapf_ship.cpp.