Mercurial > hg > openttd
changeset 20032:eaf4245ab838 draft
(svn r24964) -Fix [FS#5416]: With YAPF the docking behaviour differed per direction; now favour docking in the direction you approached
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 03 Feb 2013 14:16:45 +0000 |
parents | c18979f650ee |
children | 0ad832872f6e |
files | src/pathfinder/yapf/yapf_ship.cpp |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -58,9 +58,12 @@ 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) */