OpenTTD Source  20241108-master-g80f628063a
industry_sl.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "../stdafx.h"
11 
12 #include "saveload.h"
14 
15 #include "../industry.h"
16 #include "newgrf_sl.h"
17 
18 #include "../safeguards.h"
19 
20 static OldPersistentStorage _old_ind_persistent_storage;
21 
22 class SlIndustryAccepted : public DefaultSaveLoadHandler<SlIndustryAccepted, Industry> {
23 public:
24  inline static const SaveLoad description[] = {
25  SLE_VAR(Industry::AcceptedCargo, cargo, SLE_UINT8),
26  SLE_VAR(Industry::AcceptedCargo, waiting, SLE_UINT16),
27  SLE_VAR(Industry::AcceptedCargo, last_accepted, SLE_INT32),
28  };
29  inline const static SaveLoadCompatTable compat_description = _industry_accepts_sl_compat;
30 
31  void Save(Industry *i) const override
32  {
34 
35  for (auto &a : i->accepted) {
36  SlObject(&a, this->GetDescription());
37  }
38  }
39 
40  void Load(Industry *i) const override
41  {
43 
44  i->accepted.reserve(len);
45  for (size_t index = 0; index < len; ++index) {
46  auto &a = i->accepted.emplace_back();
47  SlObject(&a, this->GetLoadDescription());
48  }
49  }
50 
51  /* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
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;
55 
56  static void ResetOldStructure()
57  {
58  SlIndustryAccepted::old_cargo.fill(INVALID_CARGO);
59  SlIndustryAccepted::old_waiting.fill(0);
60  SlIndustryAccepted::old_last_accepted.fill(0);
61  }
62 };
63 
64 class SlIndustryProducedHistory : public DefaultSaveLoadHandler<SlIndustryProducedHistory, Industry::ProducedCargo> {
65 public:
66  inline static const SaveLoad description[] = {
67  SLE_VAR(Industry::ProducedHistory, production, SLE_UINT16),
68  SLE_VAR(Industry::ProducedHistory, transported, SLE_UINT16),
69  };
70  inline const static SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
71 
72  void Save(Industry::ProducedCargo *p) const override
73  {
74  if (!IsValidCargoID(p->cargo)) {
75  /* Don't save any history if cargo slot isn't used. */
77  return;
78  }
79 
80  SlSetStructListLength(p->history.size());
81 
82  for (auto &h : p->history) {
83  SlObject(&h, this->GetDescription());
84  }
85  }
86 
87  void Load(Industry::ProducedCargo *p) const override
88  {
89  size_t len = SlGetStructListLength(p->history.size());
90 
91  for (auto &h : p->history) {
92  if (--len > p->history.size()) break; // unsigned so wraps after hitting zero.
93  SlObject(&h, this->GetDescription());
94  }
95  }
96 };
97 
98 class SlIndustryProduced : public DefaultSaveLoadHandler<SlIndustryProduced, Industry> {
99 public:
100  inline static const SaveLoad description[] = {
101  SLE_VAR(Industry::ProducedCargo, cargo, SLE_UINT8),
102  SLE_VAR(Industry::ProducedCargo, waiting, SLE_UINT16),
103  SLE_VAR(Industry::ProducedCargo, rate, SLE_UINT8),
105  };
106  inline const static SaveLoadCompatTable compat_description = _industry_produced_sl_compat;
107 
108  void Save(Industry *i) const override
109  {
110  SlSetStructListLength(i->produced.size());
111 
112  for (auto &p : i->produced) {
113  SlObject(&p, this->GetDescription());
114  }
115  }
116 
117  void Load(Industry *i) const override
118  {
120 
121  i->produced.reserve(len);
122  for (size_t index = 0; index < len; ++index) {
123  auto &p = i->produced.emplace_back();
124  SlObject(&p, this->GetLoadDescription());
125  }
126  }
127 
128  /* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
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;
136 
137  static void ResetOldStructure()
138  {
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);
146  }
147 };
148 
149 static const SaveLoad _industry_desc[] = {
150  SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
151  SLE_CONDVAR(Industry, location.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
152  SLE_VAR(Industry, location.w, SLE_FILE_U8 | SLE_VAR_U16),
153  SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16),
154  SLE_REF(Industry, town, REF_TOWN),
156  SLEG_CONDARR("produced_cargo", SlIndustryProduced::old_cargo, SLE_UINT8, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
157  SLEG_CONDARR("produced_cargo", SlIndustryProduced::old_cargo, SLE_UINT8, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
158  SLEG_CONDARR("incoming_cargo_waiting", SlIndustryAccepted::old_waiting, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_INPUTS, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
159  SLEG_CONDARR("incoming_cargo_waiting", SlIndustryAccepted::old_waiting, SLE_UINT16, INDUSTRY_NUM_INPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
160  SLEG_CONDARR("produced_cargo_waiting", SlIndustryProduced::old_waiting, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
161  SLEG_CONDARR("produced_cargo_waiting", SlIndustryProduced::old_waiting, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
162  SLEG_CONDARR("production_rate", SlIndustryProduced::old_rate, SLE_UINT8, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
163  SLEG_CONDARR("production_rate", SlIndustryProduced::old_rate, SLE_UINT8, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
164  SLEG_CONDARR("accepts_cargo", SlIndustryAccepted::old_cargo, SLE_UINT8, INDUSTRY_ORIGINAL_NUM_INPUTS, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
165  SLEG_CONDARR("accepts_cargo", SlIndustryAccepted::old_cargo, SLE_UINT8, INDUSTRY_NUM_INPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
166  SLE_VAR(Industry, prod_level, SLE_UINT8),
167  SLEG_CONDARR("this_month_production", SlIndustryProduced::old_this_month_production, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
168  SLEG_CONDARR("this_month_production", SlIndustryProduced::old_this_month_production, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
169  SLEG_CONDARR("this_month_transported", SlIndustryProduced::old_this_month_transported, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
170  SLEG_CONDARR("this_month_transported", SlIndustryProduced::old_this_month_transported, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
171  SLEG_CONDARR("last_month_production", SlIndustryProduced::old_last_month_production, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
172  SLEG_CONDARR("last_month_production", SlIndustryProduced::old_last_month_production, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
173  SLEG_CONDARR("last_month_transported", SlIndustryProduced::old_last_month_transported, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
174  SLEG_CONDARR("last_month_transported", SlIndustryProduced::old_last_month_transported, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
175 
176  SLE_VAR(Industry, counter, SLE_UINT16),
177 
178  SLE_VAR(Industry, type, SLE_UINT8),
179  SLE_VAR(Industry, owner, SLE_UINT8),
180  SLE_VAR(Industry, random_colour, SLE_UINT8),
181  SLE_CONDVAR(Industry, last_prod_year, SLE_FILE_U8 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
182  SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, SLV_31, SL_MAX_VERSION),
183  SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8),
185 
186  SLE_CONDVAR(Industry, founder, SLE_UINT8, SLV_70, SL_MAX_VERSION),
187  SLE_CONDVAR(Industry, construction_date, SLE_INT32, SLV_70, SL_MAX_VERSION),
188  SLE_CONDVAR(Industry, construction_type, SLE_UINT8, SLV_70, SL_MAX_VERSION),
189  SLEG_CONDVAR("last_cargo_accepted_at[0]", SlIndustryAccepted::old_last_accepted[0], SLE_INT32, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
190  SLEG_CONDARR("last_cargo_accepted_at", SlIndustryAccepted::old_last_accepted, SLE_INT32, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
191  SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, SLV_73, SL_MAX_VERSION),
192  SLE_CONDVAR(Industry, exclusive_supplier, SLE_UINT8, SLV_GS_INDUSTRY_CONTROL, SL_MAX_VERSION),
193  SLE_CONDVAR(Industry, exclusive_consumer, SLE_UINT8, SLV_GS_INDUSTRY_CONTROL, SL_MAX_VERSION),
194 
195  SLEG_CONDARR("storage", _old_ind_persistent_storage.storage, SLE_UINT32, 16, SLV_76, SLV_161),
197 
198  SLE_CONDVAR(Industry, random, SLE_UINT16, SLV_82, SL_MAX_VERSION),
200 
203 };
204 
206  INDYChunkHandler() : ChunkHandler('INDY', CH_TABLE) {}
207 
208  void Save() const override
209  {
210  SlTableHeader(_industry_desc);
211 
212  /* Write the industries */
213  for (Industry *ind : Industry::Iterate()) {
214  SlSetArrayIndex(ind->index);
215  SlObject(ind, _industry_desc);
216  }
217  }
218 
219  void LoadMoveAcceptsProduced(Industry *i, uint inputs, uint outputs) const
220  {
221  i->accepted.reserve(inputs);
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];
227  }
228 
229  i->produced.reserve(outputs);
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];
239  }
240  }
241 
242  void Load() const override
243  {
244  const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_desc, _industry_sl_compat);
245 
246  int index;
247 
248  SlIndustryAccepted::ResetOldStructure();
249  SlIndustryProduced::ResetOldStructure();
251 
252  while ((index = SlIterateArray()) != -1) {
253  Industry *i = new (index) Industry();
254  SlObject(i, slt);
255 
256  /* Before savegame version 161, persistent storages were not stored in a pool. */
258  /* Store the old persistent storage. The GRFID will be added later. */
260  i->psa = new PersistentStorage(0, 0, 0);
261  std::copy(std::begin(_old_ind_persistent_storage.storage), std::end(_old_ind_persistent_storage.storage), std::begin(i->psa->storage));
262  }
264  LoadMoveAcceptsProduced(i, INDUSTRY_ORIGINAL_NUM_INPUTS, INDUSTRY_ORIGINAL_NUM_OUTPUTS);
266  LoadMoveAcceptsProduced(i, INDUSTRY_NUM_INPUTS, INDUSTRY_NUM_OUTPUTS);
267  }
269  }
270  }
271 
272  void FixPointers() const override
273  {
274  for (Industry *i : Industry::Iterate()) {
275  SlObject(i, _industry_desc);
276  }
277  }
278 };
279 
281  IIDSChunkHandler() : NewGRFMappingChunkHandler('IIDS', _industry_mngr) {}
282 };
283 
285  TIDSChunkHandler() : NewGRFMappingChunkHandler('TIDS', _industile_mngr) {}
286 };
287 
290  SLEG_VAR("wanted_inds", _industry_builder.wanted_inds, SLE_UINT32),
291 };
292 
295  IBLDChunkHandler() : ChunkHandler('IBLD', CH_TABLE) {}
296 
297  void Save() const override
298  {
300 
301  SlSetArrayIndex(0);
303  }
304 
305  void Load() const override
306  {
307  const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_builder_desc, _industry_builder_sl_compat);
308 
310  SlGlobList(slt);
311  if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many IBLD entries");
312  }
313 };
314 
317  SLE_VAR(IndustryTypeBuildData, probability, SLE_UINT32),
318  SLE_VAR(IndustryTypeBuildData, min_number, SLE_UINT8),
319  SLE_VAR(IndustryTypeBuildData, target_count, SLE_UINT16),
320  SLE_VAR(IndustryTypeBuildData, max_wait, SLE_UINT16),
321  SLE_VAR(IndustryTypeBuildData, wait_count, SLE_UINT16),
322 };
323 
326  ITBLChunkHandler() : ChunkHandler('ITBL', CH_TABLE) {}
327 
328  void Save() const override
329  {
331 
332  for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
333  SlSetArrayIndex(i);
335  }
336  }
337 
338  void Load() const override
339  {
341 
342  for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
344  }
345  int index;
346  while ((index = SlIterateArray()) != -1) {
347  if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas");
348  SlObject(_industry_builder.builddata + index, slt);
349  }
350  }
351 };
352 
353 static const INDYChunkHandler INDY;
354 static const IIDSChunkHandler IIDS;
355 static const TIDSChunkHandler TIDS;
356 static const IBLDChunkHandler IBLD;
357 static const ITBLChunkHandler ITBL;
358 static const ChunkHandlerRef industry_chunk_handlers[] = {
359  INDY,
360  IIDS,
361  TIDS,
362  IBLD,
363  ITBL,
364 };
365 
366 extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers);
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
Definition: cargo_type.h:107
@ Industry
Source/destination is an industry.
Default handler for saving/loading an object to/from disk.
Definition: saveload.h:577
SaveLoadTable GetDescription() const override
Definition: saveload.h:579
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
Definition: saveload.cpp:3288
IndustryBuildData _industry_builder
In-game manager of industries.
static const SaveLoad _industrytype_builder_desc[]
Description of the data to save and load in IndustryTypeBuildData.
static const SaveLoad _industry_builder_desc[]
Description of the data to save and load in IndustryBuildData.
Loading of industry chunks before table headers were added.
const SaveLoadCompat _industry_sl_compat[]
Original field order for _industry_desc.
const SaveLoadCompat _industry_builder_sl_compat[]
Original field order for _industry_builder_desc.
const SaveLoadCompat _industrytype_builder_sl_compat[]
Original field order for _industrytype_builder_desc.
static const int INDUSTRY_ORIGINAL_NUM_INPUTS
Original number of accepted cargo types.
Definition: industry_type.h:40
static const int INDUSTRY_NUM_OUTPUTS
Number of cargo types an industry can produce.
Definition: industry_type.h:39
static const int INDUSTRY_NUM_INPUTS
Number of cargo types an industry can accept.
Definition: industry_type.h:38
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
Definition: industry_type.h:26
static const int INDUSTRY_ORIGINAL_NUM_OUTPUTS
Original number of produced cargo types.
Definition: industry_type.h:41
Code handling saving and loading of NewGRF mappings.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
Definition: saveload.cpp:1684
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition: saveload.cpp:658
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
Definition: saveload.cpp:351
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
Definition: saveload.cpp:1888
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Definition: saveload.cpp:1750
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Definition: saveload.cpp:1697
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
Definition: saveload.cpp:1942
void SlSetStructListLength(size_t length)
Set the length of this list.
Definition: saveload.cpp:1668
Functions/types related to saving and loading games.
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SL_VAR elements in some savegame versions.
Definition: saveload.h:1095
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
Definition: saveload.h:1205
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
Definition: saveload.h:684
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition: saveload.h:1074
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition: saveload.h:505
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
Definition: saveload.h:508
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
Definition: saveload.h:1151
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
Definition: saveload.h:992
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
Definition: saveload.h:514
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition: saveload.h:926
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:861
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:1227
@ SLV_INDUSTRY_TEXT
289 PR#8576 v1.11.0-RC1 Additional GS text for industries.
Definition: saveload.h:326
@ SLV_SERVE_NEUTRAL_INDUSTRIES
210 PR#7234 Company stations can serve industries with attached neutral stations.
Definition: saveload.h:296
@ SLV_73
73 10903
Definition: saveload.h:130
@ SLV_EXTEND_INDUSTRY_CARGO_SLOTS
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
Definition: saveload.h:286
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:46
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
Definition: saveload.h:332
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:395
@ SLV_GS_INDUSTRY_CONTROL
287 PR#7912 and PR#8115 GS industry control.
Definition: saveload.h:324
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:31
@ SLV_76
76 11139
Definition: saveload.h:134
@ SLV_78
78 11176
Definition: saveload.h:136
@ SLV_161
161 22567
Definition: saveload.h:236
@ SLV_INDUSTRY_CARGO_REORGANISE
315 PR#10853 Industry accepts/produced data reorganised.
Definition: saveload.h:358
@ SLV_82
82 11410
Definition: saveload.h:141
@ SLV_70
70 10541
Definition: saveload.h:127
@ SLV_31
31 5999
Definition: saveload.h:80
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
Definition: saveload.h:882
@ REF_TOWN
Load/save a reference to a town.
Definition: saveload.h:600
@ REF_STATION
Load/save a reference to a station.
Definition: saveload.h:599
@ REF_STORAGE
Load/save a reference to a persistent storage.
Definition: saveload.h:606
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition: saveload.h:1143
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:975
Handlers and description of chunk.
Definition: saveload.h:459
Industry builder.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void FixPointers() const override
Fix the pointers.
Industry-type build data.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
uint32_t wanted_inds
Number of wanted industries (bits 31-16), and a fraction (bits 15-0).
Definition: industry.h:324
IndustryTypeBuildData builddata[NUM_INDUSTRYTYPES]
Industry build data for every industry type.
Definition: industry.h:323
Data for managing the number of industries of a single industry type.
Definition: industry.h:307
void Reset()
Reset the entry.
CargoID cargo
Cargo type.
Definition: industry.h:79
std::array< ProducedHistory, 25 > history
History of cargo produced and transported for this month and 24 previous months.
Definition: industry.h:82
Defines the internal data of a functional industry.
Definition: industry.h:66
IndustryType type
type of industry.
Definition: industry.h:102
PersistentStorage * psa
Persistent storage for NewGRF industries.
Definition: industry.h:123
ProducedCargoes produced
produced cargo slots
Definition: industry.h:97
AcceptedCargoes accepted
accepted cargo slots
Definition: industry.h:98
static void ResetIndustryCounts()
Resets industry counts.
Definition: industry.h:280
static void IncIndustryTypeCount(IndustryType type)
Increment the count of industries for this type.
Definition: industry.h:251
Class for persistent storage of data.
StorageType storage
Memory for the storage array.
Class for pooled persistent storage of data.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:309
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:388
SaveLoad type struct.
Definition: saveload.h:711