Codechange: Explicitly reset old industry data before loading games.

This commit is contained in:
Peter Nelson 2023-11-29 22:49:34 +00:00 committed by Peter Nelson
parent bd2a92331b
commit f79ec7955a
1 changed files with 20 additions and 0 deletions

View File

@ -51,6 +51,13 @@ public:
static inline std::array<CargoID, INDUSTRY_NUM_INPUTS> old_cargo; static inline std::array<CargoID, INDUSTRY_NUM_INPUTS> old_cargo;
static inline std::array<uint16_t, INDUSTRY_NUM_INPUTS> old_waiting; static inline std::array<uint16_t, INDUSTRY_NUM_INPUTS> old_waiting;
static inline std::array<TimerGameEconomy::Date, INDUSTRY_NUM_INPUTS> old_last_accepted; static inline std::array<TimerGameEconomy::Date, INDUSTRY_NUM_INPUTS> 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<SlIndustryProducedHistory, Industry::ProducedCargo> { class SlIndustryProducedHistory : public DefaultSaveLoadHandler<SlIndustryProducedHistory, Industry::ProducedCargo> {
@ -124,6 +131,17 @@ public:
static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_transported; static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_transported;
static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_production; static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_production;
static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_transported; static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> 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[] = { static const SaveLoad _industry_desc[] = {
@ -223,6 +241,8 @@ struct INDYChunkHandler : ChunkHandler {
int index; int index;
SlIndustryAccepted::ResetOldStructure();
SlIndustryProduced::ResetOldStructure();
Industry::ResetIndustryCounts(); Industry::ResetIndustryCounts();
while ((index = SlIterateArray()) != -1) { while ((index = SlIterateArray()) != -1) {