summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-12-01 23:56:04 +0000
committerrubidium <rubidium@openttd.org>2009-12-01 23:56:04 +0000
commit76fe20cdccd68679f4681e3f378b7695d161e8a8 (patch)
tree2bc31ade4605acc0304669e3bc3353d7beca0d3f
parent291f6490c65bd88067db472a915b4ea29cc5741a (diff)
downloadopenttd-76fe20cdccd68679f4681e3f378b7695d161e8a8.tar.xz
(svn r18367) -Codechange: unify the ship pathfinder 'calls'
-rw-r--r--projects/openttd_vs80.vcproj112
-rw-r--r--projects/openttd_vs90.vcproj112
-rw-r--r--source.list1
-rw-r--r--src/pathfinder/npf/npf.cpp21
-rw-r--r--src/pathfinder/npf/npf_func.h17
-rw-r--r--src/pathfinder/yapf/yapf.h9
-rw-r--r--src/pathfinder/yapf/yapf.hpp1
-rw-r--r--src/pathfinder/yapf/yapf_ship.cpp4
-rw-r--r--src/rail_cmd.cpp1
-rw-r--r--src/roadveh_cmd.cpp1
-rw-r--r--src/ship_cmd.cpp52
-rw-r--r--src/station_cmd.cpp2
-rw-r--r--src/tunnelbridge_cmd.cpp1
13 files changed, 183 insertions, 151 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 0b2f9f9c6..e47017a0e 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -472,10 +472,6 @@
>
</File>
<File
- RelativePath=".\..\src\aystar.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\bmp.cpp"
>
</File>
@@ -640,10 +636,6 @@
>
</File>
<File
- RelativePath=".\..\src\npf.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\openttd.cpp"
>
</File>
@@ -652,18 +644,10 @@
>
</File>
<File
- RelativePath=".\..\src\pathfind.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\pbs.cpp"
>
</File>
<File
- RelativePath=".\..\src\queue.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\rail.cpp"
>
</File>
@@ -808,10 +792,6 @@
>
</File>
<File
- RelativePath=".\..\src\aystar.h"
- >
- </File>
- <File
RelativePath=".\..\src\base_media_base.h"
>
</File>
@@ -1256,10 +1236,6 @@
>
</File>
<File
- RelativePath=".\..\src\npf.h"
- >
- </File>
- <File
RelativePath=".\..\src\music\null_m.h"
>
</File>
@@ -1288,10 +1264,6 @@
>
</File>
<File
- RelativePath=".\..\src\pathfind.h"
- >
- </File>
- <File
RelativePath=".\..\src\pbs.h"
>
</File>
@@ -1300,10 +1272,6 @@
>
</File>
<File
- RelativePath=".\..\src\queue.h"
- >
- </File>
- <File
RelativePath=".\..\src\rail.h"
>
</File>
@@ -3481,70 +3449,118 @@
</File>
</Filter>
<Filter
+ Name="Pathfinder"
+ >
+ <File
+ RelativePath=".\..\src\pathfinder\opf\opf_ship.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\opf\opf_ship.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\pathfinder_func.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="NPF"
+ >
+ <File
+ RelativePath=".\..\src\pathfinder\npf\aystar.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\aystar.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\queue.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\queue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\npf.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\npf.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\npf_func.h"
+ >
+ </File>
+ </Filter>
+ <Filter
Name="YAPF"
>
<File
- RelativePath=".\..\src\yapf\follow_track.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\follow_track.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\nodelist.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\nodelist.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf.h"
+ RelativePath=".\..\src\pathfinder\yapf\yapf.h"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_base.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_base.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_common.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_common.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_costbase.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_costbase.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_costcache.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_costcache.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_costrail.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_costrail.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_destrail.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_destrail.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_node.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_node.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_node_rail.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_node_rail.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_node_road.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_node_road.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_rail.cpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_rail.cpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_road.cpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_road.cpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_ship.cpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_ship.cpp"
>
</File>
</Filter>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 94b35d120..07fa3253e 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -469,10 +469,6 @@
>
</File>
<File
- RelativePath=".\..\src\aystar.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\bmp.cpp"
>
</File>
@@ -637,10 +633,6 @@
>
</File>
<File
- RelativePath=".\..\src\npf.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\openttd.cpp"
>
</File>
@@ -649,18 +641,10 @@
>
</File>
<File
- RelativePath=".\..\src\pathfind.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\pbs.cpp"
>
</File>
<File
- RelativePath=".\..\src\queue.cpp"
- >
- </File>
- <File
RelativePath=".\..\src\rail.cpp"
>
</File>
@@ -805,10 +789,6 @@
>
</File>
<File
- RelativePath=".\..\src\aystar.h"
- >
- </File>
- <File
RelativePath=".\..\src\base_media_base.h"
>
</File>
@@ -1253,10 +1233,6 @@
>
</File>
<File
- RelativePath=".\..\src\npf.h"
- >
- </File>
- <File
RelativePath=".\..\src\music\null_m.h"
>
</File>
@@ -1285,10 +1261,6 @@
>
</File>
<File
- RelativePath=".\..\src\pathfind.h"
- >
- </File>
- <File
RelativePath=".\..\src\pbs.h"
>
</File>
@@ -1297,10 +1269,6 @@
>
</File>
<File
- RelativePath=".\..\src\queue.h"
- >
- </File>
- <File
RelativePath=".\..\src\rail.h"
>
</File>
@@ -3478,70 +3446,118 @@
</File>
</Filter>
<Filter
+ Name="Pathfinder"
+ >
+ <File
+ RelativePath=".\..\src\pathfinder\opf\opf_ship.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\opf\opf_ship.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\pathfinder_func.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="NPF"
+ >
+ <File
+ RelativePath=".\..\src\pathfinder\npf\aystar.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\aystar.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\queue.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\queue.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\npf.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\npf.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\pathfinder\npf\npf_func.h"
+ >
+ </File>
+ </Filter>
+ <Filter
Name="YAPF"
>
<File
- RelativePath=".\..\src\yapf\follow_track.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\follow_track.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\nodelist.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\nodelist.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf.h"
+ RelativePath=".\..\src\pathfinder\yapf\yapf.h"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_base.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_base.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_common.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_common.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_costbase.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_costbase.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_costcache.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_costcache.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_costrail.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_costrail.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_destrail.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_destrail.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_node.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_node.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_node_rail.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_node_rail.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_node_road.hpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_node_road.hpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_rail.cpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_rail.cpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_road.cpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_road.cpp"
>
</File>
<File
- RelativePath=".\..\src\yapf\yapf_ship.cpp"
+ RelativePath=".\..\src\pathfinder\yapf\yapf_ship.cpp"
>
</File>
</Filter>
diff --git a/source.list b/source.list
index 6d9ae3fe2..eca9da184 100644
--- a/source.list
+++ b/source.list
@@ -825,6 +825,7 @@ pathfinder/npf/queue.cpp
pathfinder/npf/queue.h
pathfinder/npf/npf.cpp
pathfinder/npf/npf.h
+pathfinder/npf/npf_func.h
# YAPF
pathfinder/yapf/follow_track.hpp
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index f4211c298..50795d0ed 100644
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -19,6 +19,7 @@
#include "../../tunnelbridge.h"
#include "../../pbs.h"
#include "../../train.h"
+#include "../../ship.h"
#include "../pathfinder_func.h"
#include "npf.h"
@@ -1118,3 +1119,23 @@ void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, Vehicle *v, bool reser
fstd->reserve_path = reserve_path;
fstd->v = v;
}
+
+/*** Ships ***/
+
+Track NPFShipChooseTrack(Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
+{
+ NPFFindStationOrTileData fstd;
+ Trackdir trackdir = v->GetVehicleTrackdir();
+ assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
+
+ NPFFillWithOrderData(&fstd, v);
+
+ NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
+
+ /* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
+ * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
+ * we did not find our target, but ftd.best_trackdir contains the direction leading
+ * to the tile closest to our target. */
+ if (ftd.best_trackdir == 0xff) return INVALID_TRACK;
+ return TrackdirToTrack(ftd.best_trackdir);
+}
diff --git a/src/pathfinder/npf/npf_func.h b/src/pathfinder/npf/npf_func.h
new file mode 100644
index 000000000..7121ba065
--- /dev/null
+++ b/src/pathfinder/npf/npf_func.h
@@ -0,0 +1,17 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * 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.
+ * 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.
+ * 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/>.
+ */
+
+/** @file npf_func.h Functions to access the new pathfinder. */
+
+#ifndef NPF_FUNC_H
+#define NPF_FUNC_H
+
+Track NPFShipChooseTrack(class Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
+
+#endif /* NPF_FUNC_H */
diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h
index d55a4f372..c0c0cf087 100644
--- a/src/pathfinder/yapf/yapf.h
+++ b/src/pathfinder/yapf/yapf.h
@@ -12,20 +12,17 @@
#ifndef YAPF_H
#define YAPF_H
-#include "../../debug.h"
-#include "../../depot_type.h"
#include "../../direction_type.h"
#include "../../station_type.h"
-#include "../../pbs.h"
/** Finds the best path for given ship.
* @param v the ship that needs to find a path
* @param tile the tile to find the path from (should be next tile the ship is about to enter)
* @param enterdir diagonal direction which the ship will enter this new tile from
* @param tracks available tracks on the new tile (to choose from)
- * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
+ * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found
*/
-Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
+Track YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
/** Finds the best path for given road vehicle.
* @param v the RV that needs to find a path
@@ -45,7 +42,7 @@ Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection ent
* @param target [out] the target tile of the reservation, free is set to true if path was reserved
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
-Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target);
+Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, struct PBSTileInfo *target);
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
* @param v RV (its current tile will be the origin)
diff --git a/src/pathfinder/yapf/yapf.hpp b/src/pathfinder/yapf/yapf.hpp
index a353902c5..a8e887a13 100644
--- a/src/pathfinder/yapf/yapf.hpp
+++ b/src/pathfinder/yapf/yapf.hpp
@@ -24,6 +24,7 @@
#include "../../landscape.h"
#include "yapf.h"
#include "../pathfinder_func.h"
+#include "../../pbs.h"
#include "../../waypoint_base.h"
#include "../../debug.h"
#include "../../settings_type.h"
diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp
index 3ae152bd6..f0de614ac 100644
--- a/src/pathfinder/yapf/yapf_ship.cpp
+++ b/src/pathfinder/yapf/yapf_ship.cpp
@@ -167,7 +167,7 @@ struct CYapfShip2 : CYapfT<CYapfShip_TypesT<CYapfShip2, CFollowTrackWater , C
struct CYapfShip3 : CYapfT<CYapfShip_TypesT<CYapfShip3, CFollowTrackWaterNo90, CShipNodeListTrackDir> > {};
/** Ship controller helper - path finder invoker */
-Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
+Track YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{
/* default is YAPF type 2 */
typedef Trackdir (*PfnChooseShipTrack)(const Vehicle*, TileIndex, DiagDirection, TrackBits);
@@ -181,7 +181,7 @@ Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection ent
}
Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks);
- return td_ret;
+ return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : INVALID_TRACK;
}
/** performance measurement helper */
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 4c6b424fb..269f05500 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -33,6 +33,7 @@
#include "functions.h"
#include "elrail_func.h"
#include "town.h"
+#include "pbs.h"
#include "table/strings.h"
#include "table/railtypes.h"
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index dd6780ca8..0435145fa 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -37,6 +37,7 @@
#include "roadstop_base.h"
#include "cargotype.h"
#include "spritecache.h"
+#include "debug.h"
#include "table/strings.h"
#include "table/sprites.h"
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index e75715750..1d8943a15 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -16,7 +16,7 @@
#include "command_func.h"
#include "news_func.h"
#include "company_func.h"
-#include "pathfinder/npf/npf.h"
+#include "pathfinder/npf/npf_func.h"
#include "depot_base.h"
#include "station_base.h"
#include "vehicle_gui.h"
@@ -99,17 +99,7 @@ SpriteID Ship::GetImage(Direction direction) const
static const Depot *FindClosestShipDepot(const Vehicle *v)
{
- if (_settings_game.pf.pathfinder_for_ships == VPF_NPF) { // NPF is used
- Trackdir trackdir = v->GetVehicleTrackdir();
- NPFFoundTargetData ftd = NPFRouteToDepotTrialError(v->tile, trackdir, false, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPES);
-
- if (ftd.best_bird_dist == 0) return Depot::GetByTile(ftd.node.tile); // Found target
-
- return NULL; // Did not find target
- }
-
- /* OPF or YAPF - find the closest depot */
-
+ /* Find the closest depot */
const Depot *depot;
const Depot *best_depot = NULL;
uint best_dist = UINT_MAX;
@@ -369,16 +359,6 @@ static void ShipArrivesAt(const Vehicle *v, Station *st)
}
-static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData *target, TransportType type, Owner owner, RailTypes railtypes)
-{
-
- void *perf = NpfBeginInterval();
- NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, ignore_start_tile, target, type, 0, owner, railtypes);
- int t = NpfEndInterval(perf);
- DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
- return ret;
-}
-
/** returns the track to choose on the next tile, or -1 when it's better to
* reverse. The tile given is the tile we are about to enter, enterdir is the
* direction in which we are entering the tile */
@@ -387,33 +367,11 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr
assert(IsValidDiagDirection(enterdir));
switch (_settings_game.pf.pathfinder_for_ships) {
- case VPF_YAPF: { // YAPF
- Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
- if (trackdir != INVALID_TRACKDIR) return TrackdirToTrack(trackdir);
- } break;
-
- case VPF_NPF: { // NPF
- NPFFindStationOrTileData fstd;
- Trackdir trackdir = v->GetVehicleTrackdir();
- assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
-
- NPFFillWithOrderData(&fstd, v);
-
- NPFFoundTargetData ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, true, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPES);
-
- /* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
- * the direction we need to take to get there, if ftd.best_bird_dist is not 0,
- * we did not find our target, but ftd.best_trackdir contains the direction leading
- * to the tile closest to our target. */
- if (ftd.best_trackdir != 0xff) return TrackdirToTrack(ftd.best_trackdir); // TODO: Wrapper function?
- } break;
-
- default: NOT_REACHED();
-
case VPF_OPF: return OPFShipChooseTrack(v, tile, enterdir, tracks);
+ case VPF_NPF: return NPFShipChooseTrack(v, tile, enterdir, tracks);
+ case VPF_YAPF: return YapfChooseShipTrack(v, tile, enterdir, tracks);
+ default: NOT_REACHED();
}
-
- return INVALID_TRACK; // We could better reverse
}
static const Direction _new_vehicle_direction_table[] = {
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index a6655af66..45a534733 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -43,6 +43,8 @@
#include "roadstop_base.h"
#include "waypoint_base.h"
#include "waypoint_func.h"
+#include "pbs.h"
+#include "debug.h"
#include "table/strings.h"
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index c429d1ff1..7348a0d4d 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -38,6 +38,7 @@
#include "cheat_type.h"
#include "elrail_func.h"
#include "landscape_type.h"
+#include "pbs.h"
#include "table/sprites.h"
#include "table/strings.h"