From 4045429df6e39fbd020a5feda379177b2d2bc267 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 13 Dec 2010 21:56:40 +0000 Subject: (svn r21511) -Feature: vehicle lost message for ships --- src/pathfinder/opf/opf_ship.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/pathfinder/opf/opf_ship.cpp') 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 } -- cgit v1.2.3-54-g00ecf