@@ -1133,7 +1133,7 @@ FindDepotData NPFRoadVehicleFindNearestD
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
/* 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
* 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;
@@ -33,9 +33,10 @@ FindDepotData NPFRoadVehicleFindNearestD
* @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.
@@ -33,9 +33,10 @@ Track YapfShipChooseTrack(const Ship *v,
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.
@@ -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<CYapf
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(cons
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);
@@ -835,6 +835,7 @@ static Trackdir RoadFindPathToDest(RoadV
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(RoadV
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:;
Status change: