OpenTTD Source  14.0-beta3
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  {
42  size_t len = SlGetStructListLength(i->accepted.size());
43 
44  for (auto &a : i->accepted) {
45  if (--len > i->accepted.size()) break; // unsigned so wraps after hitting zero.
46  SlObject(&a, this->GetDescription());
47  }
48  }
49 
50  /* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
51  static CargoID old_cargo[INDUSTRY_NUM_INPUTS];
52  static uint16_t old_waiting[INDUSTRY_NUM_INPUTS];
53  static TimerGameEconomy::Date old_last_accepted[INDUSTRY_NUM_INPUTS];
54 };
55 
56 /* static */ CargoID SlIndustryAccepted::old_cargo[INDUSTRY_NUM_INPUTS];
57 /* static */ uint16_t SlIndustryAccepted::old_waiting[INDUSTRY_NUM_INPUTS];
58 /* static */ TimerGameEconomy::Date SlIndustryAccepted::old_last_accepted[INDUSTRY_NUM_INPUTS];
59 
60 class SlIndustryProducedHistory : public DefaultSaveLoadHandler<SlIndustryProducedHistory, Industry::ProducedCargo> {
61 public:
62  inline static const SaveLoad description[] = {
63  SLE_VAR(Industry::ProducedHistory, production, SLE_UINT16),
64  SLE_VAR(Industry::ProducedHistory, transported, SLE_UINT16),
65  };
66  inline const static SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
67 
68  void Save(Industry::ProducedCargo *p) const override
69  {
70  if (!IsValidCargoID(p->cargo)) {
71  /* Don't save any history if cargo slot isn't used. */
73  return;
74  }
75 
76  SlSetStructListLength(p->history.size());
77 
78  for (auto &h : p->history) {
79  SlObject(&h, this->GetDescription());
80  }
81  }
82 
83  void Load(Industry::ProducedCargo *p) const override
84  {
85  size_t len = SlGetStructListLength(p->history.size());
86 
87  for (auto &h : p->history) {
88  if (--len > p->history.size()) break; // unsigned so wraps after hitting zero.
89  SlObject(&h, this->GetDescription());
90  }
91  }
92 };
93 
94 class SlIndustryProduced : public DefaultSaveLoadHandler<SlIndustryProduced, Industry> {
95 public:
96  inline static const SaveLoad description[] = {
97  SLE_VAR(Industry::ProducedCargo, cargo, SLE_UINT8),
98  SLE_VAR(Industry::ProducedCargo, waiting, SLE_UINT16),
99  SLE_VAR(Industry::ProducedCargo, rate, SLE_UINT8),
101  };
102  inline const static SaveLoadCompatTable compat_description = _industry_produced_sl_compat;
103 
104  void Save(Industry *i) const override
105  {
106  SlSetStructListLength(i->produced.size());
107 
108  for (auto &p : i->produced) {
109  SlObject(&p, this->GetDescription());
110  }
111  }
112 
113  void Load(Industry *i) const override
114  {
115  size_t len = SlGetStructListLength(i->produced.size());
116 
117  for (auto &p : i->produced) {
118  if (--len > i->produced.size()) break; // unsigned so wraps after hitting zero.
119  SlObject(&p, this->GetDescription());
120  }
121  }
122 
123  /* Old array structure used for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
124  static CargoID old_cargo[INDUSTRY_NUM_OUTPUTS];
125  static uint16_t old_waiting[INDUSTRY_NUM_OUTPUTS];
126  static uint8_t old_rate[INDUSTRY_NUM_OUTPUTS];
127  static uint16_t old_this_month_production[INDUSTRY_NUM_OUTPUTS];
128  static uint16_t old_this_month_transported[INDUSTRY_NUM_OUTPUTS];
129  static uint16_t old_last_month_production[INDUSTRY_NUM_OUTPUTS];
130  static uint16_t old_last_month_transported[INDUSTRY_NUM_OUTPUTS];
131 };
132 
133 /* static */ CargoID SlIndustryProduced::old_cargo[INDUSTRY_NUM_OUTPUTS];
134 /* static */ uint16_t SlIndustryProduced::old_waiting[INDUSTRY_NUM_OUTPUTS];
135 /* static */ uint8_t SlIndustryProduced::old_rate[INDUSTRY_NUM_OUTPUTS];
136 /* static */ uint16_t SlIndustryProduced::old_this_month_production[INDUSTRY_NUM_OUTPUTS];
137 /* static */ uint16_t SlIndustryProduced::old_this_month_transported[INDUSTRY_NUM_OUTPUTS];
138 /* static */ uint16_t SlIndustryProduced::old_last_month_production[INDUSTRY_NUM_OUTPUTS];
139 /* static */ uint16_t SlIndustryProduced::old_last_month_transported[INDUSTRY_NUM_OUTPUTS];
140 
141 static const SaveLoad _industry_desc[] = {
142  SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
143  SLE_CONDVAR(Industry, location.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
144  SLE_VAR(Industry, location.w, SLE_FILE_U8 | SLE_VAR_U16),
145  SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16),
146  SLE_REF(Industry, town, REF_TOWN),
148  SLEG_CONDARR("produced_cargo", SlIndustryProduced::old_cargo, SLE_UINT8, 2, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
149  SLEG_CONDARR("produced_cargo", SlIndustryProduced::old_cargo, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
150  SLEG_CONDARR("incoming_cargo_waiting", SlIndustryAccepted::old_waiting, SLE_UINT16, 3, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
151  SLEG_CONDARR("incoming_cargo_waiting", SlIndustryAccepted::old_waiting, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
152  SLEG_CONDARR("produced_cargo_waiting", SlIndustryProduced::old_waiting, SLE_UINT16, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
153  SLEG_CONDARR("produced_cargo_waiting", SlIndustryProduced::old_waiting, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
154  SLEG_CONDARR("production_rate", SlIndustryProduced::old_rate, SLE_UINT8, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
155  SLEG_CONDARR("production_rate", SlIndustryProduced::old_rate, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
156  SLEG_CONDARR("accepts_cargo", SlIndustryAccepted::old_cargo, SLE_UINT8, 3, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
157  SLEG_CONDARR("accepts_cargo", SlIndustryAccepted::old_cargo, SLE_UINT8, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
158  SLE_VAR(Industry, prod_level, SLE_UINT8),
159  SLEG_CONDARR("this_month_production", SlIndustryProduced::old_this_month_production, SLE_UINT16, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
160  SLEG_CONDARR("this_month_production", SlIndustryProduced::old_this_month_production, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
161  SLEG_CONDARR("this_month_transported", SlIndustryProduced::old_this_month_transported, SLE_UINT16, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
162  SLEG_CONDARR("this_month_transported", SlIndustryProduced::old_this_month_transported, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
163  SLEG_CONDARR("last_month_production", SlIndustryProduced::old_last_month_production, SLE_UINT16, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
164  SLEG_CONDARR("last_month_production", SlIndustryProduced::old_last_month_production, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
165  SLEG_CONDARR("last_month_transported", SlIndustryProduced::old_last_month_transported, SLE_UINT16, 2, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
166  SLEG_CONDARR("last_month_transported", SlIndustryProduced::old_last_month_transported, SLE_UINT16, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
167 
168  SLE_VAR(Industry, counter, SLE_UINT16),
169 
170  SLE_VAR(Industry, type, SLE_UINT8),
171  SLE_VAR(Industry, owner, SLE_UINT8),
172  SLE_VAR(Industry, random_colour, SLE_UINT8),
173  SLE_CONDVAR(Industry, last_prod_year, SLE_FILE_U8 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
174  SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, SLV_31, SL_MAX_VERSION),
175  SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8),
177 
178  SLE_CONDVAR(Industry, founder, SLE_UINT8, SLV_70, SL_MAX_VERSION),
179  SLE_CONDVAR(Industry, construction_date, SLE_INT32, SLV_70, SL_MAX_VERSION),
180  SLE_CONDVAR(Industry, construction_type, SLE_UINT8, SLV_70, SL_MAX_VERSION),
181  SLEG_CONDVAR("last_cargo_accepted_at[0]", SlIndustryAccepted::old_last_accepted[0], SLE_INT32, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
182  SLEG_CONDARR("last_cargo_accepted_at", SlIndustryAccepted::old_last_accepted, SLE_INT32, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
183  SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, SLV_73, SL_MAX_VERSION),
184  SLE_CONDVAR(Industry, exclusive_supplier, SLE_UINT8, SLV_GS_INDUSTRY_CONTROL, SL_MAX_VERSION),
185  SLE_CONDVAR(Industry, exclusive_consumer, SLE_UINT8, SLV_GS_INDUSTRY_CONTROL, SL_MAX_VERSION),
186 
187  SLEG_CONDARR("storage", _old_ind_persistent_storage.storage, SLE_UINT32, 16, SLV_76, SLV_161),
189 
190  SLE_CONDVAR(Industry, random, SLE_UINT16, SLV_82, SL_MAX_VERSION),
192 
195 };
196 
198  INDYChunkHandler() : ChunkHandler('INDY', CH_TABLE) {}
199 
200  void Save() const override
201  {
202  SlTableHeader(_industry_desc);
203 
204  /* Write the industries */
205  for (Industry *ind : Industry::Iterate()) {
206  SlSetArrayIndex(ind->index);
207  SlObject(ind, _industry_desc);
208  }
209  }
210 
211  void LoadMoveAcceptsProduced(Industry *i) const
212  {
213  for (uint j = 0; j != INDUSTRY_NUM_INPUTS; ++j) {
214  auto &a = i->accepted[j];
215  a.cargo = SlIndustryAccepted::old_cargo[j];
216  a.waiting = SlIndustryAccepted::old_waiting[j];
217  a.last_accepted = SlIndustryAccepted::old_last_accepted[j];
218  }
219 
220  for (uint j = 0; j != INDUSTRY_NUM_OUTPUTS; ++j) {
221  auto &p = i->produced[j];
222  p.cargo = SlIndustryProduced::old_cargo[j];
223  p.waiting = SlIndustryProduced::old_waiting[j];
224  p.rate = SlIndustryProduced::old_rate[j];
225  p.history[THIS_MONTH].production = SlIndustryProduced::old_this_month_production[j];
226  p.history[THIS_MONTH].transported = SlIndustryProduced::old_this_month_transported[j];
227  p.history[LAST_MONTH].production = SlIndustryProduced::old_last_month_production[j];
228  p.history[LAST_MONTH].transported = SlIndustryProduced::old_last_month_transported[j];
229  }
230  }
231 
232  void Load() const override
233  {
234  const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_desc, _industry_sl_compat);
235 
236  int index;
237 
239 
240  while ((index = SlIterateArray()) != -1) {
241  Industry *i = new (index) Industry();
242  SlObject(i, slt);
243 
244  /* Before savegame version 161, persistent storages were not stored in a pool. */
246  /* Store the old persistent storage. The GRFID will be added later. */
248  i->psa = new PersistentStorage(0, 0, 0);
249  std::copy(std::begin(_old_ind_persistent_storage.storage), std::end(_old_ind_persistent_storage.storage), std::begin(i->psa->storage));
250  }
251  if (IsSavegameVersionBefore(SLV_INDUSTRY_CARGO_REORGANISE)) LoadMoveAcceptsProduced(i);
253  }
254  }
255 
256  void FixPointers() const override
257  {
258  for (Industry *i : Industry::Iterate()) {
259  SlObject(i, _industry_desc);
260  }
261  }
262 };
263 
265  IIDSChunkHandler() : NewGRFMappingChunkHandler('IIDS', _industry_mngr) {}
266 };
267 
269  TIDSChunkHandler() : NewGRFMappingChunkHandler('TIDS', _industile_mngr) {}
270 };
271 
274  SLEG_VAR("wanted_inds", _industry_builder.wanted_inds, SLE_UINT32),
275 };
276 
279  IBLDChunkHandler() : ChunkHandler('IBLD', CH_TABLE) {}
280 
281  void Save() const override
282  {
284 
285  SlSetArrayIndex(0);
287  }
288 
289  void Load() const override
290  {
291  const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_builder_desc, _industry_builder_sl_compat);
292 
294  SlGlobList(slt);
295  if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many IBLD entries");
296  }
297 };
298 
301  SLE_VAR(IndustryTypeBuildData, probability, SLE_UINT32),
302  SLE_VAR(IndustryTypeBuildData, min_number, SLE_UINT8),
303  SLE_VAR(IndustryTypeBuildData, target_count, SLE_UINT16),
304  SLE_VAR(IndustryTypeBuildData, max_wait, SLE_UINT16),
305  SLE_VAR(IndustryTypeBuildData, wait_count, SLE_UINT16),
306 };
307 
310  ITBLChunkHandler() : ChunkHandler('ITBL', CH_TABLE) {}
311 
312  void Save() const override
313  {
315 
316  for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
317  SlSetArrayIndex(i);
319  }
320  }
321 
322  void Load() const override
323  {
325 
326  for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
328  }
329  int index;
330  while ((index = SlIterateArray()) != -1) {
331  if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas");
332  SlObject(_industry_builder.builddata + index, slt);
333  }
334  }
335 };
336 
337 static const INDYChunkHandler INDY;
338 static const IIDSChunkHandler IIDS;
339 static const TIDSChunkHandler TIDS;
340 static const IBLDChunkHandler IBLD;
341 static const ITBLChunkHandler ITBL;
342 static const ChunkHandlerRef industry_chunk_handlers[] = {
343  INDY,
344  IIDS,
345  TIDS,
346  IBLD,
347  ITBL,
348 };
349 
350 extern const ChunkHandlerTable _industry_chunk_handlers(industry_chunk_handlers);
TIDSChunkHandler
Definition: industry_sl.cpp:268
SLEG_CONDSTRUCTLIST
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition: saveload.h:1116
NUM_INDUSTRYTYPES
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
IndustryBuildData::wanted_inds
uint32_t wanted_inds
Number of wanted industries (bits 31-16), and a fraction (bits 15-0).
Definition: industry.h:293
DefaultSaveLoadHandler
Default handler for saving/loading an object to/from disk.
Definition: saveload.h:560
INDUSTRY_NUM_OUTPUTS
static const int INDUSTRY_NUM_OUTPUTS
Number of cargo types an industry can produce.
Definition: industry_type.h:39
SLV_73
@ SLV_73
73 10903
Definition: saveload.h:130
NewGRFMappingChunkHandler
Definition: newgrf_sl.h:15
SLV_70
@ SLV_70
70 10541
Definition: saveload.h:127
_industry_builder_sl_compat
const SaveLoadCompat _industry_builder_sl_compat[]
Original field order for _industry_builder_desc.
Definition: industry_sl_compat.h:77
REF_TOWN
@ REF_TOWN
Load/save a reference to a town.
Definition: saveload.h:583
IndustryBuildData::builddata
IndustryTypeBuildData builddata[NUM_INDUSTRYTYPES]
Industry build data for every industry type.
Definition: industry.h:292
SLE_CONDSSTR
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition: saveload.h:909
Industry::ProducedCargo::history
std::array< ProducedHistory, 2 > history
History of cargo produced and transported.
Definition: industry.h:84
INDUSTRY_NUM_INPUTS
static const int INDUSTRY_NUM_INPUTS
Number of cargo types an industry can accept.
Definition: industry_type.h:38
ChunkHandlerRef
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition: saveload.h:488
IBLDChunkHandler
Industry builder.
Definition: industry_sl.cpp:278
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:31
_industrytype_builder_desc
static const SaveLoad _industrytype_builder_desc[]
Description of the data to save and load in IndustryTypeBuildData.
Definition: industry_sl.cpp:300
Industry::ProducedCargo::cargo
CargoID cargo
Cargo type.
Definition: industry.h:81
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:844
SlErrorCorrupt
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
Definition: saveload.cpp:362
saveload.h
SlIndustryProducedHistory
Definition: industry_sl.cpp:60
Industry::produced
ProducedCargoArray produced
INDUSTRY_NUM_OUTPUTS production cargo slots.
Definition: industry.h:99
SaveLoadCompatTable
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
Definition: saveload.h:497
industry_sl_compat.h
StrongType::Typedef
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition: strong_typedef_type.hpp:150
SLV_SERVE_NEUTRAL_INDUSTRIES
@ SLV_SERVE_NEUTRAL_INDUSTRIES
210 PR#7234 Company stations can serve industries with attached neutral stations.
Definition: saveload.h:296
ChunkHandler
Handlers and description of chunk.
Definition: saveload.h:442
Industry
Defines the internal data of a functional industry.
Definition: industry.h:68
INDYChunkHandler::Load
void Load() const override
Load the chunk.
Definition: industry_sl.cpp:232
_industrytype_builder_sl_compat
const SaveLoadCompat _industrytype_builder_sl_compat[]
Original field order for _industrytype_builder_desc.
Definition: industry_sl_compat.h:82
INDYChunkHandler
Definition: industry_sl.cpp:197
SLV_6
@ SLV_6
6.0 1721 6.1 1768
Definition: saveload.h:46
SLE_REF
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
Definition: saveload.h:965
SlGlobList
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
Definition: saveload.cpp:1897
REF_STATION
@ REF_STATION
Load/save a reference to a station.
Definition: saveload.h:582
SLF_ALLOW_CONTROL
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
Definition: saveload.h:667
IIDSChunkHandler
Definition: industry_sl.cpp:264
IndustryTypeBuildData::Reset
void Reset()
Reset the entry.
Definition: industry_cmd.cpp:2402
ITBLChunkHandler
Industry-type build data.
Definition: industry_sl.cpp:309
Industry::type
IndustryType type
type of industry.
Definition: industry.h:104
IsSavegameVersionBefore
bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:1203
SLV_EXTEND_INDUSTRY_CARGO_SLOTS
@ SLV_EXTEND_INDUSTRY_CARGO_SLOTS
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
Definition: saveload.h:286
PersistentStorage
Class for pooled persistent storage of data.
Definition: newgrf_storage.h:199
SLEG_VAR
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
Definition: saveload.h:1124
_industry_sl_compat
const SaveLoadCompat _industry_sl_compat[]
Original field order for _industry_desc.
Definition: industry_sl_compat.h:33
SLV_GS_INDUSTRY_CONTROL
@ SLV_GS_INDUSTRY_CONTROL
287 PR#7912 and PR#8115 GS industry control.
Definition: saveload.h:324
_industry_builder_desc
static const SaveLoad _industry_builder_desc[]
Description of the data to save and load in IndustryBuildData.
Definition: industry_sl.cpp:273
SlIndustryProduced
Definition: industry_sl.cpp:94
Industry::accepted
AcceptedCargoArray accepted
INDUSTRY_NUM_INPUTS input cargo slots.
Definition: industry.h:100
SLV_INDUSTRY_TEXT
@ SLV_INDUSTRY_TEXT
289 PR#8576 v1.11.0-RC1 Additional GS text for industries.
Definition: saveload.h:326
REF_STORAGE
@ REF_STORAGE
Load/save a reference to a persistent storage.
Definition: saveload.h:589
INDYChunkHandler::Save
void Save() const override
Save the chunk.
Definition: industry_sl.cpp:200
Industry::ResetIndustryCounts
static void ResetIndustryCounts()
Resets industry counts.
Definition: industry.h:249
SLE_CONDREF
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
Definition: saveload.h:865
SLV_31
@ SLV_31
31 5999
Definition: saveload.h:80
SLV_RIFF_TO_ARRAY
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
Definition: saveload.h:332
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:379
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
SlIndustryAccepted
Definition: industry_sl.cpp:22
Industry::AcceptedCargo
Definition: industry.h:87
SourceType::Industry
@ Industry
Source/destination is an industry.
ITBLChunkHandler::Load
void Load() const override
Load the chunk.
Definition: industry_sl.cpp:322
SlGetStructListLength
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
Definition: saveload.cpp:1639
Industry::ProducedCargo
Definition: industry.h:80
ITBLChunkHandler::Save
void Save() const override
Save the chunk.
Definition: industry_sl.cpp:312
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:948
Pool::PoolItem<&_industry_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:384
SLEG_CONDVAR
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition: saveload.h:1047
Industry::ProducedHistory
Definition: industry.h:69
SLV_78
@ SLV_78
78 11176
Definition: saveload.h:136
Industry::IncIndustryTypeCount
static void IncIndustryTypeCount(IndustryType type)
Increment the count of industries for this type.
Definition: industry.h:220
SLEG_CONDARR
#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:1068
DefaultSaveLoadHandler< SlIndustryAccepted, Industry >::GetDescription
SaveLoadTable GetDescription() const override
Definition: saveload.h:562
Pool::PoolItem<&_persistent_storage_pool >::CanAllocateItem
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Definition: pool_type.hpp:305
ChunkHandlerTable
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
Definition: saveload.h:491
IndustryTypeBuildData
Data for managing the number of industries of a single industry type.
Definition: industry.h:276
SLV_82
@ SLV_82
82 11410
Definition: saveload.h:141
PersistentStorageArray::storage
StorageType storage
Memory for the storage array.
Definition: newgrf_storage.h:70
IBLDChunkHandler::Save
void Save() const override
Save the chunk.
Definition: industry_sl.cpp:281
SlCompatTableHeader
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
Definition: saveload.cpp:1843
IsValidCargoID
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
Definition: cargo_type.h:103
SLV_161
@ SLV_161
161 22567
Definition: saveload.h:236
_industry_builder
IndustryBuildData _industry_builder
In-game manager of industries.
Definition: industry_cmd.cpp:70
INDYChunkHandler::FixPointers
void FixPointers() const override
Fix the pointers.
Definition: industry_sl.cpp:256
SLV_76
@ SLV_76
76 11139
Definition: saveload.h:134
IBLDChunkHandler::Load
void Load() const override
Load the chunk.
Definition: industry_sl.cpp:289
SlObject
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Definition: saveload.cpp:1652
SlTableHeader
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Definition: saveload.cpp:1705
Industry::psa
PersistentStorage * psa
Persistent storage for NewGRF industries.
Definition: industry.h:125
SlSetStructListLength
void SlSetStructListLength(size_t length)
Set the length of this list.
Definition: saveload.cpp:1623
SaveLoad
SaveLoad type struct.
Definition: saveload.h:694
newgrf_sl.h
SlIterateArray
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition: saveload.cpp:647
SLV_INDUSTRY_CARGO_REORGANISE
@ SLV_INDUSTRY_CARGO_REORGANISE
315 PR#10853 Industry accepts/produced data reorganised.
Definition: saveload.h:358
PersistentStorageArray
Class for persistent storage of data.
Definition: newgrf_storage.h:67
SLEG_STRUCTLIST
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
Definition: saveload.h:1178