OpenTTD
opf_ship.cpp File Reference

Implementation of the oldest supported ship pathfinder. More...

Go to the source code of this file.

Data Structures

struct  RememberData
 
struct  TrackPathFinder
 

Functions

static bool ShipTrackFollower (TileIndex tile, TrackPathFinder *pfs, uint length)
 
static void TPFModeShip (TrackPathFinder *tpf, TileIndex tile, DiagDirection direction)
 
static void OPFShipFollowTrack (TileIndex tile, DiagDirection direction, TrackPathFinder *tpf)
 
static uint FindShipTrack (const Ship *v, TileIndex tile, DiagDirection dir, TrackBits bits, TileIndex skiptile, Track *track)
 
Track OPFShipChooseTrack (const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found)
 Finds the best track to choose on the next tile and returns INVALID_TRACK when it is better to reverse. More...
 

Variables

static const DiagDirection _ship_search_directions [6][4]
 Directions to search towards given track bits and the ship's enter direction. More...
 
static const byte _pick_shiptrack_table [6] = {DIR_NE, DIR_SE, DIR_E, DIR_E, DIR_N, DIR_N}
 Track to "direction (& 3)" mapping. More...
 

Detailed Description

Implementation of the oldest supported ship pathfinder.

Definition in file opf_ship.cpp.

Function Documentation

◆ OPFShipChooseTrack()

Track OPFShipChooseTrack ( const Ship v,
TileIndex  tile,
DiagDirection  enterdir,
TrackBits  tracks,
bool &  path_found 
)

Finds the best track to choose on the next tile and returns INVALID_TRACK when it is better to reverse.

Finds the best path for given ship using OPF.

Parameters
vThe ship.
tileThe tile we are about to enter.
enterdirThe direction entering the tile.
tracksThe tracks available on new tile.
[out]path_foundWhether a path has been found.
Returns
Best track on next tile or INVALID_TRACK when better to reverse.

Definition at line 196 of file opf_ship.cpp.

Variable Documentation

◆ _pick_shiptrack_table

const byte _pick_shiptrack_table[6] = {DIR_NE, DIR_SE, DIR_E, DIR_E, DIR_N, DIR_N}
static

Track to "direction (& 3)" mapping.

Definition at line 134 of file opf_ship.cpp.

◆ _ship_search_directions

const DiagDirection _ship_search_directions[6][4]
static
Initial value:
= {
{ DIAGDIR_NE, INVALID_DIAGDIR, DIAGDIR_SW, INVALID_DIAGDIR },
{ INVALID_DIAGDIR, DIAGDIR_NE, DIAGDIR_NW, INVALID_DIAGDIR },
{ DIAGDIR_NW, DIAGDIR_SW, INVALID_DIAGDIR, INVALID_DIAGDIR },
}
Flag for an invalid DiagDirection.
Northeast, upper right on your monitor.
Southeast.
Southwest.
Northwest.

Directions to search towards given track bits and the ship's enter direction.

Definition at line 124 of file opf_ship.cpp.