Codechange: Use inline and std::array for old industry structures.

This avoids separate declaration/definition, and less C-style arrays.
This commit is contained in:
Peter Nelson 2023-11-29 22:42:35 +00:00 committed by Peter Nelson
parent f6b38e8e06
commit bd2a92331b
1 changed files with 10 additions and 22 deletions

View File

@ -48,15 +48,11 @@ public:
}
/* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
static CargoID old_cargo[INDUSTRY_NUM_INPUTS];
static uint16_t old_waiting[INDUSTRY_NUM_INPUTS];
static TimerGameEconomy::Date old_last_accepted[INDUSTRY_NUM_INPUTS];
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<TimerGameEconomy::Date, INDUSTRY_NUM_INPUTS> old_last_accepted;
};
/* static */ CargoID SlIndustryAccepted::old_cargo[INDUSTRY_NUM_INPUTS];
/* static */ uint16_t SlIndustryAccepted::old_waiting[INDUSTRY_NUM_INPUTS];
/* static */ TimerGameEconomy::Date SlIndustryAccepted::old_last_accepted[INDUSTRY_NUM_INPUTS];
class SlIndustryProducedHistory : public DefaultSaveLoadHandler<SlIndustryProducedHistory, Industry::ProducedCargo> {
public:
inline static const SaveLoad description[] = {
@ -121,23 +117,15 @@ public:
}
/* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
static CargoID old_cargo[INDUSTRY_NUM_OUTPUTS];
static uint16_t old_waiting[INDUSTRY_NUM_OUTPUTS];
static uint8_t old_rate[INDUSTRY_NUM_OUTPUTS];
static uint16_t old_this_month_production[INDUSTRY_NUM_OUTPUTS];
static uint16_t old_this_month_transported[INDUSTRY_NUM_OUTPUTS];
static uint16_t old_last_month_production[INDUSTRY_NUM_OUTPUTS];
static uint16_t old_last_month_transported[INDUSTRY_NUM_OUTPUTS];
static inline std::array<CargoID, INDUSTRY_NUM_OUTPUTS> old_cargo;
static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_waiting;
static inline std::array<uint8_t, INDUSTRY_NUM_OUTPUTS> old_rate;
static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_production;
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_transported;
};
/* static */ CargoID SlIndustryProduced::old_cargo[INDUSTRY_NUM_OUTPUTS];
/* static */ uint16_t SlIndustryProduced::old_waiting[INDUSTRY_NUM_OUTPUTS];
/* static */ uint8_t SlIndustryProduced::old_rate[INDUSTRY_NUM_OUTPUTS];
/* static */ uint16_t SlIndustryProduced::old_this_month_production[INDUSTRY_NUM_OUTPUTS];
/* static */ uint16_t SlIndustryProduced::old_this_month_transported[INDUSTRY_NUM_OUTPUTS];
/* static */ uint16_t SlIndustryProduced::old_last_month_production[INDUSTRY_NUM_OUTPUTS];
/* static */ uint16_t SlIndustryProduced::old_last_month_transported[INDUSTRY_NUM_OUTPUTS];
static const SaveLoad _industry_desc[] = {
SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
SLE_CONDVAR(Industry, location.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),