|
@@ -2318,13 +2318,16 @@ static const byte _initial_tile_subcoord
|
|
|
* @param[out] path_found Whether a path has been found or not.
|
|
|
* @param do_track_reservation Path reservation is requested
|
|
|
* @param[out] dest State and destination of the requested path
|
|
|
* @param[out] final_dest Final tile of the best path found
|
|
|
* @return The best track the train should follow
|
|
|
*/
|
|
|
static Track DoTrainPathfind(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool do_track_reservation, PBSTileInfo *dest)
|
|
|
static Track DoTrainPathfind(const Train *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool &path_found, bool do_track_reservation, PBSTileInfo *dest, TileIndex *final_dest)
|
|
|
{
|
|
|
if (final_dest != nullptr) *final_dest = INVALID_TILE;
|
|
|
|
|
|
switch (_settings_game.pf.pathfinder_for_trains) {
|
|
|
case VPF_NPF: return NPFTrainChooseTrack(v, path_found, do_track_reservation, dest);
|
|
|
case VPF_YAPF: return YapfTrainChooseTrack(v, tile, enterdir, tracks, path_found, do_track_reservation, dest);
|
|
|
case VPF_YAPF: return YapfTrainChooseTrack(v, tile, enterdir, tracks, path_found, do_track_reservation, dest, final_dest);
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
}
|
|
@@ -2596,7 +2599,7 @@ static Track ChooseTrainTrack(Train *v,
|
|
|
bool path_found = true;
|
|
|
TileIndex new_tile = res_dest.tile;
|
|
|
|
|
|
Track next_track = DoTrainPathfind(v, new_tile, dest_enterdir, tracks, path_found, do_track_reservation, &res_dest);
|
|
|
Track next_track = DoTrainPathfind(v, new_tile, dest_enterdir, tracks, path_found, do_track_reservation, &res_dest, nullptr);
|
|
|
if (new_tile == tile) best_track = next_track;
|
|
|
v->HandlePathfindingResult(path_found);
|
|
|
}
|
|
@@ -2644,7 +2647,7 @@ static Track ChooseTrainTrack(Train *v,
|
|
|
if (orders.SwitchToNextOrder(true)) {
|
|
|
PBSTileInfo cur_dest;
|
|
|
bool path_found;
|
|
|
DoTrainPathfind(v, next_tile, exitdir, reachable, path_found, true, &cur_dest);
|
|
|
DoTrainPathfind(v, next_tile, exitdir, reachable, path_found, true, &cur_dest, nullptr);
|
|
|
if (cur_dest.tile != INVALID_TILE) {
|
|
|
res_dest = cur_dest;
|
|
|
if (res_dest.okay) continue;
|