mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
(svn r21631) -Fix [FS#4325]: ships with the old pathfinder would easily show up as lost, even when it would eventually find a path. Now also the distance from the "end" of the pathfinding run to the destination is compared to the current distance to the destination; if the distance to the destination at the end of the pathfinder run is less than the current distance from the destination the ship won't be marked as lost. This means that the ships with the old pathfinder will less likely get marked as lost, but due to the design of the old ship pathfinder there "lostness" is merely a best guess. When you still get a lost message
This commit is contained in:
parent
7cce507443
commit
b323000253
@ -205,8 +205,11 @@ Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir,
|
|||||||
uint dist = FindShipTrack(v, tile, enterdir, tracks, 0, &track);
|
uint dist = FindShipTrack(v, tile, enterdir, tracks, 0, &track);
|
||||||
|
|
||||||
/* If the dist equals zero, or distr equals one (the extra reversing penalty),
|
/* If the dist equals zero, or distr equals one (the extra reversing penalty),
|
||||||
* then we found our destination and we are not lost. */
|
* then we found our destination and we are not lost.
|
||||||
path_found = (dist == 0 || distr == 1);
|
* When we are not lost (yet) and the distance to our destination becomes
|
||||||
|
* less, then we aren't lost yet.
|
||||||
|
* So, we only become lost when the distance to our destination increases. */
|
||||||
|
path_found = (dist == 0 || distr == 1 || (!(v->vehicle_flags & VF_PATHFINDER_LOST) && min(dist, distr) < DistanceManhattan(tile, v->dest_tile)));
|
||||||
if (dist <= distr) return track;
|
if (dist <= distr) return track;
|
||||||
return INVALID_TRACK; // We could better reverse
|
return INVALID_TRACK; // We could better reverse
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user