summaryrefslogtreecommitdiff
path: root/src/pathfinder/opf
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-13 21:56:40 +0000
committerrubidium <rubidium@openttd.org>2010-12-13 21:56:40 +0000
commit4045429df6e39fbd020a5feda379177b2d2bc267 (patch)
tree05b6e3ca49be9fc6cdc7465458a7fd8101719304 /src/pathfinder/opf
parent6bc002ad7414fb7d27e9ace04865d501cc3b08b9 (diff)
downloadopenttd-4045429df6e39fbd020a5feda379177b2d2bc267.tar.xz
(svn r21511) -Feature: vehicle lost message for ships
Diffstat (limited to 'src/pathfinder/opf')
-rw-r--r--src/pathfinder/opf/opf_ship.cpp5
-rw-r--r--src/pathfinder/opf/opf_ship.h3
2 files changed, 6 insertions, 2 deletions
diff --git a/src/pathfinder/opf/opf_ship.cpp b/src/pathfinder/opf/opf_ship.cpp
index 2fef03e12..cb96f4cf8 100644
--- a/src/pathfinder/opf/opf_ship.cpp
+++ b/src/pathfinder/opf/opf_ship.cpp
@@ -183,7 +183,7 @@ bad:;
* reverse. The tile given is the tile we are about to enter, enterdir is the
* direction in which we are entering the tile
*/
-Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
+Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found)
{
assert(IsValidDiagDirection(enterdir));
@@ -202,6 +202,9 @@ Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir,
/* And if we would not reverse? */
uint dist = FindShipTrack(v, tile, enterdir, tracks, 0, &track);
+ /* If the dist equals zero, or distr equals one (the extra reversing penalty),
+ * then we found our destination and we are not lost. */
+ path_found = (dist == 0 || distr == 1);
if (dist <= distr) return track;
return INVALID_TRACK; // We could better reverse
}
diff --git a/src/pathfinder/opf/opf_ship.h b/src/pathfinder/opf/opf_ship.h
index b124ce34e..62668b206 100644
--- a/src/pathfinder/opf/opf_ship.h
+++ b/src/pathfinder/opf/opf_ship.h
@@ -23,8 +23,9 @@
* @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 OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
+Track OPFShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found);
#endif /* OPF_SHIP_H */