OpenTTD Source  12.0
yapf_ship.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../../stdafx.h"
11 #include "../../ship.h"
12 #include "../../industry.h"
13 #include "../../vehicle_func.h"
14 
15 #include "yapf.hpp"
16 #include "yapf_node_ship.hpp"
17 
18 #include "../../safeguards.h"
19 
20 template <class Types>
22 {
23 public:
24  typedef typename Types::Tpf Tpf;
25  typedef typename Types::TrackFollower TrackFollower;
26  typedef typename Types::NodeList::Titem Node;
27  typedef typename Node::Key Key;
28 
29 protected:
30  TileIndex m_destTile;
31  TrackdirBits m_destTrackdirs;
32  StationID m_destStation;
33 
34 public:
35  void SetDestination(const Ship *v)
36  {
37  if (v->current_order.IsType(OT_GOTO_STATION)) {
38  m_destStation = v->current_order.GetDestination();
39  m_destTile = CalcClosestStationTile(m_destStation, v->tile, STATION_DOCK);
40  m_destTrackdirs = INVALID_TRACKDIR_BIT;
41  } else {
42  m_destStation = INVALID_STATION;
43  m_destTile = v->dest_tile;
45  }
46  }
47 
48 protected:
50  inline Tpf& Yapf()
51  {
52  return *static_cast<Tpf*>(this);
53  }
54 
55 public:
57  inline bool PfDetectDestination(Node& n)
58  {
59  return PfDetectDestinationTile(n.m_segment_last_tile, n.m_segment_last_td);
60  }
61 
62  inline bool PfDetectDestinationTile(TileIndex tile, Trackdir trackdir)
63  {
64  if (m_destStation != INVALID_STATION) {
65  return IsDockingTile(tile) && IsShipDestinationTile(tile, m_destStation);
66  }
67 
68  return tile == m_destTile && ((m_destTrackdirs & TrackdirToTrackdirBits(trackdir)) != TRACKDIR_BIT_NONE);
69  }
70 
75  inline bool PfCalcEstimate(Node& n)
76  {
77  static const int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
78  static const int dg_dir_to_y_offs[] = {0, 1, 0, -1};
79  if (PfDetectDestination(n)) {
80  n.m_estimate = n.m_cost;
81  return true;
82  }
83 
84  TileIndex tile = n.m_segment_last_tile;
85  DiagDirection exitdir = TrackdirToExitdir(n.m_segment_last_td);
86  int x1 = 2 * TileX(tile) + dg_dir_to_x_offs[(int)exitdir];
87  int y1 = 2 * TileY(tile) + dg_dir_to_y_offs[(int)exitdir];
88  int x2 = 2 * TileX(m_destTile);
89  int y2 = 2 * TileY(m_destTile);
90  int dx = abs(x1 - x2);
91  int dy = abs(y1 - y2);
92  int dmin = std::min(dx, dy);
93  int dxy = abs(dx - dy);
94  int d = dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);
95  n.m_estimate = n.m_cost + d;
96  assert(n.m_estimate >= n.m_parent->m_estimate);
97  return true;
98  }
99 };
100 
101 
103 template <class Types>
105 {
106 public:
107  typedef typename Types::Tpf Tpf;
108  typedef typename Types::TrackFollower TrackFollower;
109  typedef typename Types::NodeList::Titem Node;
110  typedef typename Node::Key Key;
111 
112 protected:
114  inline Tpf& Yapf()
115  {
116  return *static_cast<Tpf *>(this);
117  }
118 
119 public:
125  inline void PfFollowNode(Node &old_node)
126  {
127  TrackFollower F(Yapf().GetVehicle());
128  if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td)) {
129  Yapf().AddMultipleNodes(&old_node, F);
130  }
131  }
132 
134  inline char TransportTypeChar() const
135  {
136  return 'w';
137  }
138 
139  static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, ShipPathCache &path_cache)
140  {
141  /* handle special case - when next tile is destination tile */
142  if (tile == v->dest_tile) {
143  /* convert tracks to trackdirs */
144  TrackdirBits trackdirs = TrackBitsToTrackdirBits(tracks);
145  /* limit to trackdirs reachable from enterdir */
146  trackdirs &= DiagdirReachesTrackdirs(enterdir);
147 
148  /* use vehicle's current direction if that's possible, otherwise use first usable one. */
149  Trackdir veh_dir = v->GetVehicleTrackdir();
150  return (HasTrackdir(trackdirs, veh_dir)) ? veh_dir : (Trackdir)FindFirstBit2x64(trackdirs);
151  }
152 
153  /* move back to the old tile/trackdir (where ship is coming from) */
154  TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir));
155  Trackdir trackdir = v->GetVehicleTrackdir();
156  assert(IsValidTrackdir(trackdir));
157 
158  /* convert origin trackdir to TrackdirBits */
159  TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
160 
161  /* create pathfinder instance */
162  Tpf pf;
163  /* set origin and destination nodes */
164  pf.SetOrigin(src_tile, trackdirs);
165  pf.SetDestination(v);
166  /* find best path */
167  path_found = pf.FindPath(v);
168 
169  Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
170 
171  Node *pNode = pf.GetBestNode();
172  if (pNode != nullptr) {
173  uint steps = 0;
174  for (Node *n = pNode; n->m_parent != nullptr; n = n->m_parent) steps++;
175  uint skip = 0;
176  if (path_found) skip = YAPF_SHIP_PATH_CACHE_LENGTH / 2;
177 
178  /* walk through the path back to the origin */
179  Node *pPrevNode = nullptr;
180  while (pNode->m_parent != nullptr) {
181  steps--;
182  /* Skip tiles at end of path near destination. */
183  if (skip > 0) skip--;
184  if (skip == 0 && steps > 0 && steps < YAPF_SHIP_PATH_CACHE_LENGTH) {
185  path_cache.push_front(pNode->GetTrackdir());
186  }
187  pPrevNode = pNode;
188  pNode = pNode->m_parent;
189  }
190  /* return trackdir from the best next node (direct child of origin) */
191  Node &best_next_node = *pPrevNode;
192  assert(best_next_node.GetTile() == tile);
193  next_trackdir = best_next_node.GetTrackdir();
194  /* remove last element for the special case when tile == dest_tile */
195  if (path_found && !path_cache.empty()) path_cache.pop_back();
196  }
197  return next_trackdir;
198  }
199 
210  static bool CheckShipReverse(const Ship *v, TileIndex tile, Trackdir td1, Trackdir td2, Trackdir *trackdir)
211  {
212  /* create pathfinder instance */
213  Tpf pf;
214  /* set origin and destination nodes */
215  pf.SetOrigin(tile, trackdir == nullptr ? TrackdirToTrackdirBits(td1) | TrackdirToTrackdirBits(td2) : DiagdirReachesTrackdirs(ReverseDiagDir(VehicleExitDir(v->direction, v->state))));
216  pf.SetDestination(v);
217  /* find best path */
218  if (!pf.FindPath(v)) return false;
219 
220  Node *pNode = pf.GetBestNode();
221  if (pNode == nullptr) return false;
222 
223  /* path was found
224  * walk through the path back to the origin */
225  while (pNode->m_parent != nullptr) {
226  pNode = pNode->m_parent;
227  }
228 
229  Trackdir best_trackdir = pNode->GetTrackdir();
230  if (trackdir != nullptr) {
231  *trackdir = best_trackdir;
232  } else {
233  assert(best_trackdir == td1 || best_trackdir == td2);
234  }
235  return best_trackdir != td1;
236  }
237 };
238 
240 template <class Types>
242 {
243 public:
244  typedef typename Types::Tpf Tpf;
245  typedef typename Types::TrackFollower TrackFollower;
246  typedef typename Types::NodeList::Titem Node;
247  typedef typename Node::Key Key;
248 
249 protected:
252  {
253  return *static_cast<Tpf *>(this);
254  }
255 
256 public:
257  inline int CurveCost(Trackdir td1, Trackdir td2)
258  {
259  assert(IsValidTrackdir(td1));
260  assert(IsValidTrackdir(td2));
261 
262  if (HasTrackdir(TrackdirCrossesTrackdirs(td1), td2)) {
263  /* 90-deg curve penalty */
264  return Yapf().PfGetSettings().ship_curve90_penalty;
265  } else if (td2 != NextTrackdir(td1)) {
266  /* 45-deg curve penalty */
267  return Yapf().PfGetSettings().ship_curve45_penalty;
268  }
269  return 0;
270  }
271 
272  static Vehicle *CountShipProc(Vehicle *v, void *data)
273  {
274  uint *count = (uint *)data;
275  /* Ignore other vehicles (aircraft) and ships inside depot. */
276  if (v->type == VEH_SHIP && (v->vehstatus & VS_HIDDEN) == 0) (*count)++;
277 
278  return nullptr;
279  }
280 
286  inline bool PfCalcCost(Node &n, const TrackFollower *tf)
287  {
288  /* base tile cost depending on distance */
289  int c = IsDiagonalTrackdir(n.GetTrackdir()) ? YAPF_TILE_LENGTH : YAPF_TILE_CORNER_LENGTH;
290  /* additional penalty for curves */
291  c += CurveCost(n.m_parent->GetTrackdir(), n.GetTrackdir());
292 
293  if (IsDockingTile(n.GetTile())) {
294  /* Check docking tile for occupancy */
295  uint count = 0;
296  HasVehicleOnPos(n.GetTile(), &count, &CountShipProc);
297  c += count * 3 * YAPF_TILE_LENGTH;
298  }
299 
300  /* Skipped tile cost for aqueducts. */
301  c += YAPF_TILE_LENGTH * tf->m_tiles_skipped;
302 
303  /* Ocean/canal speed penalty. */
304  const ShipVehicleInfo *svi = ShipVehInfo(Yapf().GetVehicle()->engine_type);
305  byte speed_frac = (GetEffectiveWaterClass(n.GetTile()) == WATER_CLASS_SEA) ? svi->ocean_speed_frac : svi->canal_speed_frac;
306  if (speed_frac > 0) c += YAPF_TILE_LENGTH * (1 + tf->m_tiles_skipped) * speed_frac / (256 - speed_frac);
307 
308  /* apply it */
309  n.m_cost = n.m_parent->m_cost + c;
310  return true;
311  }
312 };
313 
318 template <class Tpf_, class Ttrack_follower, class Tnode_list>
320 {
323 
325  typedef Tpf_ Tpf;
327  typedef Ttrack_follower TrackFollower;
329  typedef Tnode_list NodeList;
330  typedef Ship VehicleType;
332  typedef CYapfBaseT<Types> PfBase; // base pathfinder class
333  typedef CYapfFollowShipT<Types> PfFollow; // node follower
334  typedef CYapfOriginTileT<Types> PfOrigin; // origin provider
335  typedef CYapfDestinationTileWaterT<Types> PfDestination; // destination/distance provider
336  typedef CYapfSegmentCostCacheNoneT<Types> PfCache; // segment cost cache provider
337  typedef CYapfCostShipT<Types> PfCost; // cost provider
338 };
339 
340 /* YAPF type 1 - uses TileIndex/Trackdir as Node key */
341 struct CYapfShip1 : CYapfT<CYapfShip_TypesT<CYapfShip1, CFollowTrackWater , CShipNodeListTrackDir> > {};
342 /* YAPF type 2 - uses TileIndex/DiagDirection as Node key */
343 struct CYapfShip2 : CYapfT<CYapfShip_TypesT<CYapfShip2, CFollowTrackWater , CShipNodeListExitDir > > {};
344 
346 Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, ShipPathCache &path_cache)
347 {
348  /* default is YAPF type 2 */
349  typedef Trackdir (*PfnChooseShipTrack)(const Ship*, TileIndex, DiagDirection, TrackBits, bool &path_found, ShipPathCache &path_cache);
350  PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir
351 
352  /* check if non-default YAPF type needed */
354  pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir
355  }
356 
357  Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks, path_found, path_cache);
358  return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : INVALID_TRACK;
359 }
360 
361 bool YapfShipCheckReverse(const Ship *v, Trackdir *trackdir)
362 {
363  Trackdir td = v->GetVehicleTrackdir();
364  Trackdir td_rev = ReverseTrackdir(td);
365  TileIndex tile = v->tile;
366 
367  typedef bool (*PfnCheckReverseShip)(const Ship*, TileIndex, Trackdir, Trackdir, Trackdir*);
368  PfnCheckReverseShip pfnCheckReverseShip = CYapfShip2::CheckShipReverse; // default: ExitDir
369 
370  /* check if non-default YAPF type needed */
372  pfnCheckReverseShip = &CYapfShip1::CheckShipReverse; // Trackdir
373  }
374 
375  bool reverse = pfnCheckReverseShip(v, tile, td, td_rev, trackdir);
376 
377  return reverse;
378 }
ChooseShipTrack
static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
Runs the pathfinder to choose a track to continue along.
Definition: ship_cmd.cpp:466
VehicleExitDir
static DiagDirection VehicleExitDir(Direction direction, TrackBits track)
Determine the side in which the vehicle will leave the tile.
Definition: track_func.h:713
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
CYapfShip_TypesT::NodeList
Tnode_list NodeList
node list type
Definition: yapf_ship.cpp:329
Order::IsType
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition: order_base.h:64
TrackdirBits
TrackdirBits
Enumeration of bitmasks for the TrackDirs.
Definition: track_type.h:101
LinkGraph::Node
Updatable node class.
Definition: linkgraph.h:380
CYapfShip_TypesT
Config struct of YAPF for ships.
Definition: yapf_ship.cpp:319
HasVehicleOnPos
bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc)
Checks whether a vehicle is on a specific location.
Definition: vehicle.cpp:513
ShipVehicleInfo::canal_speed_frac
byte canal_speed_frac
Fraction of maximum speed for canal/river tiles.
Definition: engine_type.h:76
CYapfDestinationTileWaterT::PfCalcEstimate
bool PfCalcEstimate(Node &n)
Called by YAPF to calculate cost estimate.
Definition: yapf_ship.cpp:75
Order::GetDestination
DestinationID GetDestination() const
Gets the destination of this order.
Definition: order_base.h:97
yapf.hpp
CYapfDestinationTileWaterT::Key
Node::Key Key
key to hash tables
Definition: yapf_ship.cpp:27
Vehicle::vehstatus
byte vehstatus
Status.
Definition: vehicle_base.h:328
CYapfShip_TypesT::Tpf
Tpf_ Tpf
Tpf - pathfinder type.
Definition: yapf_ship.cpp:325
YapfShipCheckReverse
bool YapfShipCheckReverse(const Ship *v, Trackdir *trackdir)
Returns true if it is better to reverse the ship before leaving depot using YAPF.
Definition: yapf_ship.cpp:361
yapf_node_ship.hpp
YAPF_SHIP_PATH_CACHE_LENGTH
static const int YAPF_SHIP_PATH_CACHE_LENGTH
Maximum length of ship path cache.
Definition: pathfinder_type.h:42
CYapfDestinationTileWaterT::PfDetectDestination
bool PfDetectDestination(Node &n)
Called by YAPF to detect if node ends in the desired destination.
Definition: yapf_ship.cpp:57
GetEffectiveWaterClass
WaterClass GetEffectiveWaterClass(TileIndex tile)
Determine the effective WaterClass for a ship travelling on a tile.
Definition: ship_cmd.cpp:47
CYapfShip_TypesT::TrackFollower
Ttrack_follower TrackFollower
track follower helper class
Definition: yapf_ship.cpp:327
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
CYapfT
YAPF template that uses Ttypes template argument to determine all YAPF components (base classes) from...
Definition: yapf_common.hpp:183
CYapfDestinationTileWaterT::Node
Types::NodeList::Titem Node
this will be our node type
Definition: yapf_ship.cpp:26
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:221
CYapfShip1
Definition: yapf_ship.cpp:341
INVALID_TRACKDIR_BIT
@ INVALID_TRACKDIR_BIT
Flag for an invalid trackdirbit value.
Definition: track_type.h:117
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
CYapfCostShipT::Yapf
Tpf & Yapf()
to access inherited path finder
Definition: yapf_ship.cpp:251
GetTileTrackStatus
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition: landscape.cpp:590
CYapfOriginTileT
YAPF origin provider base class - used when origin is one tile / multiple trackdirs.
Definition: yapf_common.hpp:15
CYapfFollowShipT::Tpf
Types::Tpf Tpf
the pathfinder class (derived from THIS class)
Definition: yapf_ship.cpp:107
GameSettings::pf
PathfinderSettings pf
settings for all pathfinders
Definition: settings_type.h:581
VS_HIDDEN
@ VS_HIDDEN
Vehicle is not visible.
Definition: vehicle_base.h:31
CYapfDestinationTileWaterT::Yapf
Tpf & Yapf()
to access inherited path finder
Definition: yapf_ship.cpp:50
Vehicle::dest_tile
TileIndex dest_tile
Heading for this tile.
Definition: vehicle_base.h:249
CYapfCostShipT::Tpf
Types::Tpf Tpf
the pathfinder class (derived from THIS class)
Definition: yapf_ship.cpp:244
TrackBitsToTrackdirBits
static TrackdirBits TrackBitsToTrackdirBits(TrackBits bits)
Converts TrackBits to TrackdirBits while allowing both directions.
Definition: track_func.h:318
CYapfFollowShipT::PfFollowNode
void PfFollowNode(Node &old_node)
Called by YAPF to move from the given node to the next tile.
Definition: yapf_ship.cpp:125
YAPF_TILE_LENGTH
static const int YAPF_TILE_LENGTH
Length (penalty) of one tile with YAPF.
Definition: pathfinder_type.h:28
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:242
TrackdirToExitdir
static DiagDirection TrackdirToExitdir(Trackdir trackdir)
Maps a trackdir to the (4-way) direction the tile is exited when following that trackdir.
Definition: track_func.h:438
Vehicle::current_order
Order current_order
The current order (+ status, like: loading)
Definition: vehicle_base.h:329
FindFirstBit2x64
static uint8 FindFirstBit2x64(const int value)
Finds the position of the first non-zero bit in an integer.
Definition: bitmath_func.hpp:216
CYapfCostShipT::Key
Node::Key Key
key to hash tables
Definition: yapf_ship.cpp:247
CYapfDestinationTileWaterT
Definition: yapf_ship.cpp:21
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:53
CYapfFollowShipT::CheckShipReverse
static bool CheckShipReverse(const Ship *v, TileIndex tile, Trackdir td1, Trackdir td2, Trackdir *trackdir)
Check whether a ship should reverse to reach its destination.
Definition: yapf_ship.cpp:210
TrackdirCrossesTrackdirs
static TrackdirBits TrackdirCrossesTrackdirs(Trackdir trackdir)
Maps a trackdir to all trackdirs that make 90 deg turns with it.
Definition: track_func.h:605
CYapfFollowShipT::Key
Node::Key Key
key to hash tables
Definition: yapf_ship.cpp:110
CYapfShip2
Definition: yapf_ship.cpp:343
ReverseDiagDir
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition: direction_func.h:118
TileAddByDiagDir
static TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
Adds a DiagDir to a tile.
Definition: map_func.h:382
INVALID_TRACKDIR
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition: track_type.h:89
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
CYapfShip_TypesT::Types
CYapfShip_TypesT< Tpf_, Ttrack_follower, Tnode_list > Types
Types - shortcut for this struct type.
Definition: yapf_ship.cpp:322
CalcClosestStationTile
static TileIndex CalcClosestStationTile(StationID station, TileIndex tile, StationType station_type)
Calculates the tile of given station that is closest to a given tile for this we assume the station i...
Definition: pathfinder_func.h:25
Ship::GetVehicleTrackdir
Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
Definition: ship_cmd.cpp:250
Vehicle::direction
Direction direction
facing
Definition: vehicle_base.h:283
CYapfShip_TypesT::PfBase
CYapfBaseT< Types > PfBase
pathfinder components (modules)
Definition: yapf_ship.cpp:332
DiagdirReachesTrackdirs
static TrackdirBits DiagdirReachesTrackdirs(DiagDirection diagdir)
Returns all trackdirs that can be reached when entering a tile from a given (diagonal) direction.
Definition: track_func.h:554
CYapfSegmentCostCacheNoneT
CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements PfNodeCacheFetc...
Definition: yapf_costcache.hpp:21
TRACKDIR_BIT_NONE
@ TRACKDIR_BIT_NONE
No track build.
Definition: track_type.h:102
Ship
All ships have this type.
Definition: ship.h:26
CYapfFollowShipT::Yapf
Tpf & Yapf()
to access inherited path finder
Definition: yapf_ship.cpp:114
CYapfCostShipT::Node
Types::NodeList::Titem Node
this will be our node type
Definition: yapf_ship.cpp:246
CYapfFollowShipT
Node Follower module of YAPF for ships.
Definition: yapf_ship.cpp:104
TRANSPORT_WATER
@ TRANSPORT_WATER
Transport over water.
Definition: transport_type.h:29
YAPFSettings::disable_node_optimization
bool disable_node_optimization
whether to use exit-dir instead of trackdir in node key
Definition: settings_type.h:402
Ship::state
TrackBits state
The "track" the ship is following.
Definition: ship.h:27
ShipVehicleInfo
Information about a ship vehicle.
Definition: engine_type.h:66
TrackStatusToTrackdirBits
static TrackdirBits TrackStatusToTrackdirBits(TrackStatus ts)
Returns the present-trackdir-information of a TrackStatus.
Definition: track_func.h:351
CYapfCostShipT::PfCalcCost
bool PfCalcCost(Node &n, const TrackFollower *tf)
Called by YAPF to calculate the cost from the origin to the given node.
Definition: yapf_ship.cpp:286
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:38
IsDockingTile
static bool IsDockingTile(TileIndex t)
Checks whether the tile is marked as a dockling tile.
Definition: water_map.h:365
TrackdirToTrackdirBits
static TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir)
Maps a Trackdir to the corresponding TrackdirBits value.
Definition: track_func.h:110
CYapfCostShipT
Cost Provider module of YAPF for ships.
Definition: yapf_ship.cpp:241
PathfinderSettings::yapf
YAPFSettings yapf
pathfinder settings for the yet another pathfinder
Definition: settings_type.h:461
YAPF_TILE_CORNER_LENGTH
static const int YAPF_TILE_CORNER_LENGTH
Length (penalty) of a corner with YAPF.
Definition: pathfinder_type.h:31
IsShipDestinationTile
bool IsShipDestinationTile(TileIndex tile, StationID station)
Test if a tile is a docking tile for the given station.
Definition: ship_cmd.cpp:609
ReverseTrackdir
static Trackdir ReverseTrackdir(Trackdir trackdir)
Maps a trackdir to the reverse trackdir.
Definition: track_func.h:246
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:70
NextTrackdir
static Trackdir NextTrackdir(Trackdir trackdir)
Maps a trackdir to the trackdir that you will end up on if you go straight ahead.
Definition: track_func.h:402
CYapfBaseT
CYapfBaseT - A-star type path finder base class.
Definition: yapf_base.hpp:47
CYapfDestinationTileWaterT::Tpf
Types::Tpf Tpf
the pathfinder class (derived from THIS class)
Definition: yapf_ship.cpp:24
BaseVehicle::type
VehicleType type
Type of vehicle.
Definition: vehicle_type.h:52
WATER_CLASS_SEA
@ WATER_CLASS_SEA
Sea.
Definition: water_map.h:48
Track
Track
These are used to specify a single track.
Definition: track_type.h:19
HasTrackdir
static bool HasTrackdir(TrackdirBits trackdirs, Trackdir trackdir)
Checks whether a TrackdirBits has a given Trackdir.
Definition: track_func.h:339
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
CYapfFollowShipT::Node
Types::NodeList::Titem Node
this will be our node type
Definition: yapf_ship.cpp:109
IsValidTrackdir
static bool IsValidTrackdir(Trackdir trackdir)
Checks if a Trackdir is valid for non-road vehicles.
Definition: track_func.h:51
YapfShipChooseTrack
Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, ShipPathCache &path_cache)
Ship controller helper - path finder invoker.
Definition: yapf_ship.cpp:346
CYapfFollowShipT::TransportTypeChar
char TransportTypeChar() const
return debug report character to identify the transportation type
Definition: yapf_ship.cpp:134
TrackdirToTrack
static Track TrackdirToTrack(Trackdir trackdir)
Returns the Track that a given Trackdir represents.
Definition: track_func.h:261
IsDiagonalTrackdir
static bool IsDiagonalTrackdir(Trackdir trackdir)
Checks if a given Trackdir is diagonal.
Definition: track_func.h:630
ShipVehicleInfo::ocean_speed_frac
byte ocean_speed_frac
Fraction of maximum speed for ocean tiles.
Definition: engine_type.h:75
INVALID_TRACK
@ INVALID_TRACK
Flag for an invalid track.
Definition: track_type.h:28