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.

Variables

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

Detailed Description

Implementation of the oldest supported ship pathfinder.

Definition in file opf_ship.cpp.

Function Documentation

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.

References DiagdirReachesTracks(), GetTileTrackStatus(), Ship::GetVehicleTrackdir(), INVALID_TRACK, IsValidDiagDirection(), ReverseDiagDir(), TILE_ADD, TileOffsByDiagDir(), TrackdirBitsToTrackBits(), TrackdirToTrackdirBits(), TrackStatusToTrackBits(), and TRANSPORT_WATER.

Referenced by ChooseShipTrack().

Variable Documentation

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.

const DiagDirection _ship_search_directions[6][4]
static
Initial value:

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

Definition at line 124 of file opf_ship.cpp.