From 021817aa61f9005bab188ed7a0c3cd08e63ea1de Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Mon, 1 Jan 2024 17:17:10 +0000 Subject: [PATCH] Change: Update group statistics earlier in AfterLoad This commit prefaces the next incoming set of commit changes in order to have the vehicle lists already generated as an attempt to prevent AfterLoad actions accessing them empty. --- src/saveload/afterload.cpp | 2 -- src/saveload/vehicle_sl.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index ac75e3abcb..0d83826908 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1899,7 +1899,6 @@ bool AfterLoadGame() } if (IsSavegameVersionBefore(SLV_62)) { - GroupStatistics::UpdateAfterLoad(); // Ensure statistics pool is initialised before trying to delete vehicles /* Remove all trams from savegames without tram support. * There would be trams without tram track under causing crashes sooner or later. */ for (RoadVehicle *v : RoadVehicle::Iterate()) { @@ -3317,7 +3316,6 @@ void ReloadNewGRFData() ResetVehicleHash(); AfterLoadVehicles(false); StartupEngines(); - GroupStatistics::UpdateAfterLoad(); /* update station graphics */ AfterLoadStations(); /* Update company statistics. */ diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 8d482a1b89..eab4ee4d67 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -491,6 +491,8 @@ void AfterLoadVehicles(bool part_of_load) v->UpdatePosition(); v->UpdateViewport(false); } + + GroupStatistics::UpdateAfterLoad(); } bool TrainController(Train *v, Vehicle *nomove, bool reverse = true); // From train_cmd.cpp