diff options
Diffstat (limited to 'src/saveload/afterload.cpp')
-rw-r--r-- | src/saveload/afterload.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 15c44d392..2f84ef0e8 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -51,7 +51,9 @@ #include "../core/backup_type.hpp" #include "../smallmap_gui.h" #include "../news_func.h" +#include "../cargodest_func.h" #include "../error.h" +#include "../trafficlight_func.h" #include "saveload_internal.h" @@ -254,6 +256,7 @@ static void InitializeWindowsAndCaches() Station::RecomputeIndustriesNearForAll(); RebuildSubsidisedSourceAndDestinationCache(); + RebuildCargoLinkCounts(); /* Towns have a noise controlled number of airports system * So each airport's noise value must be added to the town->noise_reached value @@ -2761,6 +2764,50 @@ bool AfterLoadGame() _settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM; } + if (IsSavegameVersionBefore(180)) { + /* Update cargo acceptance map of towns. */ + for (TileIndex t = 0; t < map_size; t++) { + if (!IsTileType(t, MP_HOUSE)) continue; + Town::Get(GetTownIndex(t))->cargo_accepted.Add(t); + } + + Town *town; + FOR_ALL_TOWNS(town) { + UpdateTownCargoes(town); + } + + /* Update cargo acceptance of industries. */ + Industry *ind; + FOR_ALL_INDUSTRIES(ind) { + UpdateIndustryAcceptance(ind); + ind->average_production[0] = ind->last_month_production[0]; + ind->average_production[1] = ind->last_month_production[1]; + } + + UpdateCargoLinks(); + + Vehicle *v; + FOR_ALL_VEHICLES(v) { + /* Set the current order index from the order list. */ + Order *o = v->GetOrder(v->cur_implicit_order_index); + if (o != NULL) v->current_order.index = o->index; + + /* Pre-fill route links from orders. */ + if (v->IsFrontEngine()) PrefillRouteLinks(v); + } + } + + if (IsSavegameVersionBefore(TL_SV)) { + /* Savegames before this version can not have trafficlights already. + * Sometimes they are added randomly when loading old savegames. + * Unfortunately also in the wrong places -> not on crossings. + * + * Iterate over the whole map and remove any trafficlights found. */ + for (TileIndex tile = 0; tile < MapSize(); tile++) { + if (HasTrafficLights(tile)) ClearTrafficLights(tile); + } + } + /* Road stops is 'only' updating some caches */ AfterLoadRoadStops(); AfterLoadLabelMaps(); |