summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-02-03 14:16:45 +0000
committerrubidium <rubidium@openttd.org>2013-02-03 14:16:45 +0000
commiteb538da2284634c9300afdbbf09a016ddaa0a5ac (patch)
tree1f1615055d69718c60d3b0b5248b860fcad87d47
parent968b41fa3f159e679249d55584a14028f083e147 (diff)
downloadopenttd-eb538da2284634c9300afdbbf09a016ddaa0a5ac.tar.xz
(svn r24964) -Fix [FS#5416]: With YAPF the docking behaviour differed per direction; now favour docking in the direction you approached
-rw-r--r--src/pathfinder/yapf/yapf_ship.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp
index a4113144e..37edf2719 100644
--- a/src/pathfinder/yapf/yapf_ship.cpp
+++ b/src/pathfinder/yapf/yapf_ship.cpp
@@ -58,9 +58,12 @@ public:
if (tile == v->dest_tile) {
/* convert tracks to trackdirs */
TrackdirBits trackdirs = (TrackdirBits)(tracks | ((int)tracks << 8));
- /* choose any trackdir reachable from enterdir */
+ /* limit to trackdirs reachable from enterdir */
trackdirs &= DiagdirReachesTrackdirs(enterdir);
- return (Trackdir)FindFirstBit2x64(trackdirs);
+
+ /* use vehicle's current direction if that's possible, otherwise use first usable one. */
+ Trackdir veh_dir = v->GetVehicleTrackdir();
+ return ((trackdirs & TrackdirToTrackdirBits(veh_dir)) != 0) ? veh_dir : (Trackdir)FindFirstBit2x64(trackdirs);
}
/* move back to the old tile/trackdir (where ship is coming from) */