diff options
author | rubidium <rubidium@openttd.org> | 2010-12-13 21:56:25 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-12-13 21:56:25 +0000 |
commit | 6bc002ad7414fb7d27e9ace04865d501cc3b08b9 (patch) | |
tree | 14c0e17256d3047f9bcd9746746afe1b27b94a31 /src | |
parent | b05d2675fcb9d95ddf91b96c45985d03ce3cbd71 (diff) | |
download | openttd-6bc002ad7414fb7d27e9ace04865d501cc3b08b9.tar.xz |
(svn r21510) -Feature [FS#1956]: vehicle lost message for road vehicles
Diffstat (limited to 'src')
-rw-r--r-- | src/pathfinder/npf/npf.cpp | 4 | ||||
-rw-r--r-- | src/pathfinder/npf/npf_func.h | 3 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf.h | 3 | ||||
-rw-r--r-- | src/pathfinder/yapf/yapf_road.cpp | 14 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 6 |
5 files changed, 18 insertions, 12 deletions
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 45d968529..6cb013bc3 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -1133,7 +1133,7 @@ FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penal return FindDepotData(ftd.node.tile, ftd.best_path_dist); } -Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs) +Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found) { NPFFindStationOrTileData fstd; @@ -1145,6 +1145,7 @@ Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDir /* We are already at our target. Just do something * @todo: maybe display error? * @todo: go straight ahead if possible? */ + path_found = true; return (Trackdir)FindFirstBit2x64(trackdirs); } @@ -1152,6 +1153,7 @@ Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDir * the direction we need to take to get there, if ftd.best_bird_dist is not 0, * we did not find our target, but ftd.best_trackdir contains the direction leading * to the tile closest to our target. */ + path_found = (ftd.best_bird_dist == 0); return ftd.best_trackdir; } diff --git a/src/pathfinder/npf/npf_func.h b/src/pathfinder/npf/npf_func.h index 3f9ce4280..bdfee0cd7 100644 --- a/src/pathfinder/npf/npf_func.h +++ b/src/pathfinder/npf/npf_func.h @@ -33,9 +33,10 @@ FindDepotData NPFRoadVehicleFindNearestDepot(const RoadVehicle *v, int max_penal * @param tile the tile to find the path from (should be next tile the RV is about to enter) * @param enterdir diagonal direction which the RV will enter this new tile from * @param trackdirs available trackdirs 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_TRACKDIR if the path could not be found */ -Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs); +Trackdir NPFRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found); /** * Finds the best path for given ship using NPF. diff --git a/src/pathfinder/yapf/yapf.h b/src/pathfinder/yapf/yapf.h index 60e10e42a..c0108697d 100644 --- a/src/pathfinder/yapf/yapf.h +++ b/src/pathfinder/yapf/yapf.h @@ -33,9 +33,10 @@ Track YapfShipChooseTrack(const Ship *v, TileIndex tile, DiagDirection enterdir, * @param tile the tile to find the path from (should be next tile the RV is about to enter) * @param enterdir diagonal direction which the RV will enter this new tile from * @param trackdirs available trackdirs 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_TRACKDIR if the path could not be found */ -Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs); +Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found); /** * Finds the best path for given train using YAPF. diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp index 446b84f24..eb832b320 100644 --- a/src/pathfinder/yapf/yapf_road.cpp +++ b/src/pathfinder/yapf/yapf_road.cpp @@ -328,13 +328,13 @@ public: return 'r'; } - static Trackdir stChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir) + static Trackdir stChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found) { Tpf pf; - return pf.ChooseRoadTrack(v, tile, enterdir); + return pf.ChooseRoadTrack(v, tile, enterdir, path_found); } - FORCEINLINE Trackdir ChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir) + FORCEINLINE Trackdir ChooseRoadTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, bool &path_found) { /* Handle special case - when next tile is destination tile. * However, when going to a station the (initial) destination @@ -356,7 +356,7 @@ public: Yapf().SetDestination(v); /* find the best path */ - Yapf().FindPath(v); + path_found = Yapf().FindPath(v); /* if path not found - return INVALID_TRACKDIR */ Trackdir next_trackdir = INVALID_TRACKDIR; @@ -475,10 +475,10 @@ struct CYapfRoadAnyDepot1 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot1, CRoadNod struct CYapfRoadAnyDepot2 : CYapfT<CYapfRoad_TypesT<CYapfRoadAnyDepot2, CRoadNodeListExitDir , CYapfDestinationAnyDepotRoadT> > {}; -Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs) +Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs, bool &path_found) { /* default is YAPF type 2 */ - typedef Trackdir (*PfnChooseRoadTrack)(const RoadVehicle*, TileIndex, DiagDirection); + typedef Trackdir (*PfnChooseRoadTrack)(const RoadVehicle*, TileIndex, DiagDirection, bool &path_found); PfnChooseRoadTrack pfnChooseRoadTrack = &CYapfRoad2::stChooseRoadTrack; // default: ExitDir, allow 90-deg /* check if non-default YAPF type should be used */ @@ -486,7 +486,7 @@ Trackdir YapfRoadVehicleChooseTrack(const RoadVehicle *v, TileIndex tile, DiagDi pfnChooseRoadTrack = &CYapfRoad1::stChooseRoadTrack; // Trackdir, allow 90-deg } - Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir); + Trackdir td_ret = pfnChooseRoadTrack(v, tile, enterdir, path_found); return (td_ret != INVALID_TRACKDIR) ? td_ret : (Trackdir)FindFirstBit2x64(trackdirs); } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 1aff26bc7..aea5a9e99 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -835,6 +835,7 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection TileIndex desttile; Trackdir best_track; + bool path_found = true; TrackStatus ts = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->compatible_roadtypes); TrackdirBits red_signals = TrackStatusToRedSignals(ts); // crossing @@ -910,11 +911,12 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection } switch (_settings_game.pf.pathfinder_for_roadvehs) { - case VPF_NPF: return_track(NPFRoadVehicleChooseTrack(v, tile, enterdir, trackdirs)); - case VPF_YAPF: return_track(YapfRoadVehicleChooseTrack(v, tile, enterdir, trackdirs)); + case VPF_NPF: best_track = NPFRoadVehicleChooseTrack(v, tile, enterdir, trackdirs, path_found); break; + case VPF_YAPF: best_track = YapfRoadVehicleChooseTrack(v, tile, enterdir, trackdirs, path_found); break; default: NOT_REACHED(); } + v->HandlePathfindingResult(path_found); found_best_track:; |