summaryrefslogtreecommitdiff
path: root/ship_cmd.c
diff options
context:
space:
mode:
authorKUDr <kudr@openttd.org>2006-05-27 16:12:16 +0000
committerKUDr <kudr@openttd.org>2006-05-27 16:12:16 +0000
commit5e73dce0e71791b87e5b096a890578eefcc26639 (patch)
treee4580db6e03032a997fce1392929b7190dc3b03d /ship_cmd.c
parent3d01010440440cfbffd1e5d3b0cf1f23f0503a76 (diff)
downloadopenttd-5e73dce0e71791b87e5b096a890578eefcc26639.tar.xz
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
Diffstat (limited to 'ship_cmd.c')
-rw-r--r--ship_cmd.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/ship_cmd.c b/ship_cmd.c
index 0f9abf178..41a46693a 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -20,6 +20,8 @@
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "water_map.h"
+#include "yapf/yapf.h"
+#include "debug.h"
static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D};
static const byte _ship_sometracks[4] = {0x19, 0x16, 0x25, 0x2A};
@@ -518,6 +520,16 @@ bad:;
return best_bird_dist;
}
+static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes)
+{
+
+ void* perf = NpfBeginInterval();
+ NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes);
+ int t = NpfEndInterval(perf);
+ DEBUG(yapf, 1)("[YAPF][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 */
@@ -525,7 +537,10 @@ static int ChooseShipTrack(Vehicle *v, TileIndex tile, int enterdir, uint tracks
{
assert(enterdir>=0 && enterdir<=3);
- if (_patches.new_pathfinding_all) {
+ if (_patches.yapf.ship_use_yapf) {
+ Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
+ return (trackdir != INVALID_TRACKDIR) ? (int)TrackdirToTrack(trackdir) : -1;
+ } else if (_patches.new_pathfinding_all) {
NPFFindStationOrTileData fstd;
NPFFoundTargetData ftd;
TileIndex src_tile = TILE_ADD(tile, TileOffsByDir(ReverseDiagDir(enterdir)));
@@ -534,7 +549,7 @@ static int ChooseShipTrack(Vehicle *v, TileIndex tile, int enterdir, uint tracks
NPFFillWithOrderData(&fstd, v);
- ftd = NPFRouteToStationOrTile(src_tile, trackdir, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPE);
+ ftd = PerfNPFRouteToStationOrTile(src_tile, trackdir, &fstd, TRANSPORT_WATER, v->owner, INVALID_RAILTYPE);
if (ftd.best_trackdir != 0xff) {
/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains