Changeset - r26470:40beb4ba4113
[Not reviewed]
master
0 1 0
Nicolas Chappe - 23 months ago 2022-07-27 16:56:58
74881848+nchappe@users.noreply.github.com
Feature: Constantly update destination of 'any depot' orders
1 file changed with 11 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -2541,6 +2541,7 @@ static Track ChooseTrainTrack(Train *v, 
 
	Track best_track = INVALID_TRACK;
 
	bool do_track_reservation = _settings_game.pf.reserve_paths || force_res;
 
	bool changed_signal = false;
 
	TileIndex final_dest = INVALID_TILE;
 

	
 
	assert((tracks & ~TRACK_BIT_MASK) == 0);
 

	
 
@@ -2613,7 +2614,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, nullptr);
 
		Track next_track = DoTrainPathfind(v, new_tile, dest_enterdir, tracks, path_found, do_track_reservation, &res_dest, &final_dest);
 
		if (new_tile == tile) best_track = next_track;
 
		v->HandlePathfindingResult(path_found);
 
	}
 
@@ -2687,6 +2688,15 @@ static Track ChooseTrainTrack(Train *v, 
 

	
 
	if (changed_signal) MarkTileDirtyByTile(tile);
 

	
 
	orders.Restore();
 
	if (v->current_order.IsType(OT_GOTO_DEPOT) &&
 
			(v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) &&
 
			final_dest != INVALID_TILE && IsRailDepotTile(final_dest)) {
 
		v->current_order.SetDestination(GetDepotIndex(final_dest));
 
		v->dest_tile = final_dest;
 
		SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
 
	}
 

	
 
	return best_track;
 
}
 

	
0 comments (0 inline, 0 general)