diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h index 80b6c4ca54..ca7b4f02c9 100644 --- a/src/pathfinder/yapf/yapf.h +++ b/src/pathfinder/yapf/yapf.h @@ -22,11 +22,10 @@ * @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) * @param path_found [out] Whether a path has been found (true) or has been guessed (false) * @return the best trackdir for next turn or INVALID_TRACK if the path could not be found */ -Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, ShipPathCache &path_cache); +Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, bool &path_found, ShipPathCache &path_cache); /** * Returns true if it is better to reverse the ship before leaving depot using YAPF. diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index 22360c6328..709d4f2919 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -204,20 +204,8 @@ public: return result; } - static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, ShipPathCache &path_cache) + static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, bool &path_found, ShipPathCache &path_cache) { - /* Handle special case - when next tile is destination tile. */ - if (tile == v->dest_tile) { - /* Convert tracks to trackdirs */ - TrackdirBits trackdirs = TrackBitsToTrackdirBits(tracks); - /* Limit to trackdirs reachable from enterdir. */ - trackdirs &= DiagdirReachesTrackdirs(enterdir); - - /* use vehicle's current direction if that's possible, otherwise use first usable one. */ - Trackdir veh_dir = v->GetVehicleTrackdir(); - return (HasTrackdir(trackdirs, veh_dir)) ? veh_dir : (Trackdir)FindFirstBit(trackdirs); - } - /* Move back to the old tile/trackdir (where ship is coming from). */ const TileIndex src_tile = TileAddByDiagDir(tile, ReverseDiagDir(enterdir)); const Trackdir trackdir = v->GetVehicleTrackdir(); @@ -449,9 +437,9 @@ struct CYapfShip : CYapfTpath); break; + case VPF_YAPF: track = YapfShipChooseTrack(v, tile, enterdir, path_found, v->path); break; default: NOT_REACHED(); } }