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"

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

Variables

static const byte _ship_search_directions [6][4]
static const byte _pick_shiptrack_table [6] = {1, 3, 2, 2, 0, 0}

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 
)

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 184 of file opf_ship.cpp.

References DiagdirReachesTracks(), GetTileTrackStatus(), INVALID_TRACK, IsValidDiagDirection(), ReverseDiagDir(), TILE_ADD, TileOffsByDiagDir(), TrackStatusToTrackBits(), and TRANSPORT_WATER.

Referenced by ChooseShipTrack().


Variable Documentation

const byte _ship_search_directions[6][4] [static]
Initial value:
 {
  { 0, 9, 2, 9 },
  { 9, 1, 9, 3 },
  { 9, 0, 3, 9 },
  { 1, 9, 9, 2 },
  { 3, 2, 9, 9 },
  { 9, 9, 1, 0 },
}

Definition at line 121 of file opf_ship.cpp.


Generated on Mon Aug 30 19:37:08 2010 for OpenTTD by  doxygen 1.6.1