10 #include "../stdafx.h"
15 #include "../industry.h"
18 #include "../safeguards.h"
24 inline static const SaveLoad description[] = {
31 void Save(
Industry *i)
const override
40 void Load(
Industry *i)
const override
45 for (
size_t index = 0; index < len; ++index) {
46 auto &a = i->
accepted.emplace_back();
52 static inline std::array<CargoID, INDUSTRY_NUM_INPUTS> old_cargo;
53 static inline std::array<uint16_t, INDUSTRY_NUM_INPUTS> old_waiting;
54 static inline std::array<TimerGameEconomy::Date, INDUSTRY_NUM_INPUTS> old_last_accepted;
56 static void ResetOldStructure()
58 SlIndustryAccepted::old_cargo.fill(INVALID_CARGO);
59 SlIndustryAccepted::old_waiting.fill(0);
60 SlIndustryAccepted::old_last_accepted.fill(0);
66 inline static const SaveLoad description[] = {
70 inline const static SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
92 if (--len > p->
history.size())
break;
100 inline static const SaveLoad description[] = {
108 void Save(
Industry *i)
const override
117 void Load(
Industry *i)
const override
122 for (
size_t index = 0; index < len; ++index) {
123 auto &p = i->
produced.emplace_back();
129 static inline std::array<CargoID, INDUSTRY_NUM_OUTPUTS> old_cargo;
130 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_waiting;
131 static inline std::array<uint8_t, INDUSTRY_NUM_OUTPUTS> old_rate;
132 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_production;
133 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_transported;
134 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_production;
135 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_transported;
137 static void ResetOldStructure()
139 SlIndustryProduced::old_cargo.fill(INVALID_CARGO);
140 SlIndustryProduced::old_waiting.fill(0);
141 SlIndustryProduced::old_rate.fill(0);
142 SlIndustryProduced::old_this_month_production.fill(0);
143 SlIndustryProduced::old_this_month_transported.fill(0);
144 SlIndustryProduced::old_last_month_production.fill(0);
145 SlIndustryProduced::old_this_month_production.fill(0);
149 static const SaveLoad _industry_desc[] = {
214 SlSetArrayIndex(ind->index);
219 void LoadMoveAcceptsProduced(
Industry *i, uint inputs, uint outputs)
const
222 for (uint j = 0; j != inputs; ++j) {
223 auto &a = i->
accepted.emplace_back();
224 a.cargo = SlIndustryAccepted::old_cargo[j];
225 a.waiting = SlIndustryAccepted::old_waiting[j];
226 a.last_accepted = SlIndustryAccepted::old_last_accepted[j];
230 for (uint j = 0; j != outputs; ++j) {
231 auto &p = i->
produced.emplace_back();
232 p.cargo = SlIndustryProduced::old_cargo[j];
233 p.waiting = SlIndustryProduced::old_waiting[j];
234 p.rate = SlIndustryProduced::old_rate[j];
235 p.history[THIS_MONTH].production = SlIndustryProduced::old_this_month_production[j];
236 p.history[THIS_MONTH].transported = SlIndustryProduced::old_this_month_transported[j];
237 p.history[LAST_MONTH].production = SlIndustryProduced::old_last_month_production[j];
238 p.history[LAST_MONTH].transported = SlIndustryProduced::old_last_month_transported[j];
248 SlIndustryAccepted::ResetOldStructure();
249 SlIndustryProduced::ResetOldStructure();
261 std::copy(std::begin(_old_ind_persistent_storage.
storage), std::end(_old_ind_persistent_storage.
storage), std::begin(i->
psa->
storage));
366 extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers);