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/yapf/yapf.h | 3 ++- src/pathfinder/yapf/yapf_ship.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/pathfinder/yapf') diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h index c0108697d..c5cb5d7f6 100644 --- a/src/pathfinder/yapf/yapf.h +++ b/src/pathfinder/yapf/yapf.h @@ -23,9 +23,10 @@ * @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); +Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found); /** * Finds the best path for given road vehicle using YAPF. diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index b9c87bf9d..51fc84944 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -51,7 +51,7 @@ public: return 'w'; } - static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) + static Trackdir ChooseShipTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found) { /* handle special case - when next tile is destination tile */ if (tile == v->dest_tile) { @@ -78,7 +78,7 @@ public: pf.SetOrigin(src_tile, trackdirs); pf.SetDestination(v->dest_tile, dest_trackdirs); /* find best path */ - pf.FindPath(v); + path_found = pf.FindPath(v); Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found" @@ -174,10 +174,10 @@ struct CYapfShip2 : CYapfT > {}; /** Ship controller helper - path finder invoker */ -Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks) +Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found) { /* default is YAPF type 2 */ - typedef Trackdir (*PfnChooseShipTrack)(const Ship*, TileIndex, DiagDirection, TrackBits); + typedef Trackdir (*PfnChooseShipTrack)(const Ship*, TileIndex, DiagDirection, TrackBits, bool &path_found); PfnChooseShipTrack pfnChooseShipTrack = CYapfShip2::ChooseShipTrack; // default: ExitDir, allow 90-deg /* check if non-default YAPF type needed */ @@ -187,6 +187,6 @@ Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, pfnChooseShipTrack = &CYapfShip1::ChooseShipTrack; // Trackdir, allow 90-deg } - Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks); + Trackdir td_ret = pfnChooseShipTrack(v, tile, enterdir, tracks, path_found); return (td_ret != INVALID_TRACKDIR) ? TrackdirToTrack(td_ret) : INVALID_TRACK; } -- cgit v1.2.3-54-g00ecf