OpenTTD

Data Structures | Functions | Variables
opf_ship.cpp File Reference

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

`#include "../../stdafx.h"`
`#include "../../tunnelbridge_map.h"`
`#include "../../tunnelbridge.h"`
`#include "../../ship.h"`
`#include "../../core/random_func.hpp"`
`#include "../../safeguards.h"`

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)
| returns the track to choose on the next tile, or -1 when it's 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
| ) |  |

returns the track to choose on the next tile, or -1 when it's better to reverse.

Finds the best path for given ship using OPF.

The tile given is the tile we are about to enter, enterdir is the direction in which we are entering the tile

Definition at line 190 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_SE, INVALID_DIAGDIR, DIAGDIR_NW },
{ INVALID_DIAGDIR, DIAGDIR_NE, DIAGDIR_NW, INVALID_DIAGDIR },
{ DIAGDIR_SE, INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SW },
{ DIAGDIR_NW, DIAGDIR_SW, INVALID_DIAGDIR, INVALID_DIAGDIR },
{ INVALID_DIAGDIR, INVALID_DIAGDIR, DIAGDIR_SE, DIAGDIR_NE },
}
INVALID_DIAGDIR
Flag for an invalid DiagDirection.
Definition: direction_type.h:87
DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:82
DIAGDIR_SE
Southeast.
Definition: direction_type.h:83
DIAGDIR_SW
Southwest.
Definition: direction_type.h:84
DIAGDIR_NW
Northwest.
Definition: direction_type.h:85

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

Definition at line 124 of file opf_ship.cpp.