From f79ec7955ac06d1821f2087f814c65a0e3dfb9a6 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 29 Nov 2023 22:49:34 +0000 Subject: [PATCH] Codechange: Explicitly reset old industry data before loading games. --- src/saveload/industry_sl.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/saveload/industry_sl.cpp b/src/saveload/industry_sl.cpp index 0dc09a43c8..693fe7160f 100644 --- a/src/saveload/industry_sl.cpp +++ b/src/saveload/industry_sl.cpp @@ -51,6 +51,13 @@ public: static inline std::array old_cargo; static inline std::array old_waiting; static inline std::array old_last_accepted; + + static void ResetOldStructure() + { + SlIndustryAccepted::old_cargo.fill(INVALID_CARGO); + SlIndustryAccepted::old_waiting.fill(0); + SlIndustryAccepted::old_last_accepted.fill(0); + } }; class SlIndustryProducedHistory : public DefaultSaveLoadHandler { @@ -124,6 +131,17 @@ public: static inline std::array old_this_month_transported; static inline std::array old_last_month_production; static inline std::array old_last_month_transported; + + static void ResetOldStructure() + { + SlIndustryProduced::old_cargo.fill(INVALID_CARGO); + SlIndustryProduced::old_waiting.fill(0); + SlIndustryProduced::old_rate.fill(0); + SlIndustryProduced::old_this_month_production.fill(0); + SlIndustryProduced::old_this_month_transported.fill(0); + SlIndustryProduced::old_last_month_production.fill(0); + SlIndustryProduced::old_this_month_production.fill(0); + } }; static const SaveLoad _industry_desc[] = { @@ -223,6 +241,8 @@ struct INDYChunkHandler : ChunkHandler { int index; + SlIndustryAccepted::ResetOldStructure(); + SlIndustryProduced::ResetOldStructure(); Industry::ResetIndustryCounts(); while ((index = SlIterateArray()) != -1) {