OpenTTD Source 20241224-master-gf74b0cf984
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
20static OldPersistentStorage _old_ind_persistent_storage;
21
22class SlIndustryAccepted : public VectorSaveLoadHandler<SlIndustryAccepted, Industry, Industry::AcceptedCargo, INDUSTRY_NUM_INPUTS> {
23public:
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 std::vector<Industry::AcceptedCargo> &GetVector(Industry *i) const override { return i->accepted; }
32
33 /* Old array structure used by INDYChunkHandler for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
34 static inline std::array<CargoID, INDUSTRY_NUM_INPUTS> old_cargo;
35 static inline std::array<uint16_t, INDUSTRY_NUM_INPUTS> old_waiting;
36 static inline std::array<TimerGameEconomy::Date, INDUSTRY_NUM_INPUTS> old_last_accepted;
37
38 static void ResetOldStructure()
39 {
40 SlIndustryAccepted::old_cargo.fill(INVALID_CARGO);
41 SlIndustryAccepted::old_waiting.fill(0);
42 SlIndustryAccepted::old_last_accepted.fill(0);
43 }
44};
45
46class SlIndustryProducedHistory : public DefaultSaveLoadHandler<SlIndustryProducedHistory, Industry::ProducedCargo> {
47public:
48 inline static const SaveLoad description[] = {
49 SLE_VAR(Industry::ProducedHistory, production, SLE_UINT16),
50 SLE_VAR(Industry::ProducedHistory, transported, SLE_UINT16),
51 };
52 inline const static SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
53
54 void Save(Industry::ProducedCargo *p) const override
55 {
56 if (!IsValidCargoID(p->cargo)) {
57 /* Don't save any history if cargo slot isn't used. */
59 return;
60 }
61
63
64 for (auto &h : p->history) {
65 SlObject(&h, this->GetDescription());
66 }
67 }
68
69 void Load(Industry::ProducedCargo *p) const override
70 {
71 size_t len = SlGetStructListLength(p->history.size());
72
73 for (auto &h : p->history) {
74 if (--len > p->history.size()) break; // unsigned so wraps after hitting zero.
75 SlObject(&h, this->GetDescription());
76 }
77 }
78};
79
80class SlIndustryProduced : public VectorSaveLoadHandler<SlIndustryProduced, Industry, Industry::ProducedCargo, INDUSTRY_NUM_OUTPUTS> {
81public:
82 inline static const SaveLoad description[] = {
83 SLE_VAR(Industry::ProducedCargo, cargo, SLE_UINT8),
84 SLE_VAR(Industry::ProducedCargo, waiting, SLE_UINT16),
85 SLE_VAR(Industry::ProducedCargo, rate, SLE_UINT8),
87 };
88 inline const static SaveLoadCompatTable compat_description = _industry_produced_sl_compat;
89
90 std::vector<Industry::ProducedCargo> &GetVector(Industry *i) const override { return i->produced; }
91
92 /* Old array structure used by INDYChunkHandler for savegames before SLV_INDUSTRY_CARGO_REORGANISE. */
93 static inline std::array<CargoID, INDUSTRY_NUM_OUTPUTS> old_cargo;
94 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_waiting;
95 static inline std::array<uint8_t, INDUSTRY_NUM_OUTPUTS> old_rate;
96 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_production;
97 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_this_month_transported;
98 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_production;
99 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS> old_last_month_transported;
100
101 static void ResetOldStructure()
102 {
103 SlIndustryProduced::old_cargo.fill(INVALID_CARGO);
104 SlIndustryProduced::old_waiting.fill(0);
105 SlIndustryProduced::old_rate.fill(0);
106 SlIndustryProduced::old_this_month_production.fill(0);
107 SlIndustryProduced::old_this_month_transported.fill(0);
108 SlIndustryProduced::old_last_month_production.fill(0);
109 SlIndustryProduced::old_this_month_production.fill(0);
110 }
111};
112
113static const SaveLoad _industry_desc[] = {
114 SLE_CONDVAR(Industry, location.tile, SLE_FILE_U16 | SLE_VAR_U32, SL_MIN_VERSION, SLV_6),
115 SLE_CONDVAR(Industry, location.tile, SLE_UINT32, SLV_6, SL_MAX_VERSION),
116 SLE_VAR(Industry, location.w, SLE_FILE_U8 | SLE_VAR_U16),
117 SLE_VAR(Industry, location.h, SLE_FILE_U8 | SLE_VAR_U16),
118 SLE_REF(Industry, town, REF_TOWN),
120 SLEG_CONDARR("produced_cargo", SlIndustryProduced::old_cargo, SLE_UINT8, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
121 SLEG_CONDARR("produced_cargo", SlIndustryProduced::old_cargo, SLE_UINT8, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
122 SLEG_CONDARR("incoming_cargo_waiting", SlIndustryAccepted::old_waiting, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_INPUTS, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
123 SLEG_CONDARR("incoming_cargo_waiting", SlIndustryAccepted::old_waiting, SLE_UINT16, INDUSTRY_NUM_INPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
124 SLEG_CONDARR("produced_cargo_waiting", SlIndustryProduced::old_waiting, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
125 SLEG_CONDARR("produced_cargo_waiting", SlIndustryProduced::old_waiting, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
126 SLEG_CONDARR("production_rate", SlIndustryProduced::old_rate, SLE_UINT8, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
127 SLEG_CONDARR("production_rate", SlIndustryProduced::old_rate, SLE_UINT8, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
128 SLEG_CONDARR("accepts_cargo", SlIndustryAccepted::old_cargo, SLE_UINT8, INDUSTRY_ORIGINAL_NUM_INPUTS, SLV_78, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
129 SLEG_CONDARR("accepts_cargo", SlIndustryAccepted::old_cargo, SLE_UINT8, INDUSTRY_NUM_INPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
130 SLE_VAR(Industry, prod_level, SLE_UINT8),
131 SLEG_CONDARR("this_month_production", SlIndustryProduced::old_this_month_production, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
132 SLEG_CONDARR("this_month_production", SlIndustryProduced::old_this_month_production, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
133 SLEG_CONDARR("this_month_transported", SlIndustryProduced::old_this_month_transported, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
134 SLEG_CONDARR("this_month_transported", SlIndustryProduced::old_this_month_transported, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
135 SLEG_CONDARR("last_month_production", SlIndustryProduced::old_last_month_production, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
136 SLEG_CONDARR("last_month_production", SlIndustryProduced::old_last_month_production, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
137 SLEG_CONDARR("last_month_transported", SlIndustryProduced::old_last_month_transported, SLE_UINT16, INDUSTRY_ORIGINAL_NUM_OUTPUTS, SL_MIN_VERSION, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
138 SLEG_CONDARR("last_month_transported", SlIndustryProduced::old_last_month_transported, SLE_UINT16, INDUSTRY_NUM_OUTPUTS, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
139
140 SLE_VAR(Industry, counter, SLE_UINT16),
141
142 SLE_VAR(Industry, type, SLE_UINT8),
143 SLE_VAR(Industry, owner, SLE_UINT8),
144 SLE_VAR(Industry, random_colour, SLE_UINT8),
145 SLE_CONDVAR(Industry, last_prod_year, SLE_FILE_U8 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
146 SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, SLV_31, SL_MAX_VERSION),
147 SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8),
149
150 SLE_CONDVAR(Industry, founder, SLE_UINT8, SLV_70, SL_MAX_VERSION),
151 SLE_CONDVAR(Industry, construction_date, SLE_INT32, SLV_70, SL_MAX_VERSION),
152 SLE_CONDVAR(Industry, construction_type, SLE_UINT8, SLV_70, SL_MAX_VERSION),
153 SLEG_CONDVAR("last_cargo_accepted_at[0]", SlIndustryAccepted::old_last_accepted[0], SLE_INT32, SLV_70, SLV_EXTEND_INDUSTRY_CARGO_SLOTS),
154 SLEG_CONDARR("last_cargo_accepted_at", SlIndustryAccepted::old_last_accepted, SLE_INT32, 16, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_INDUSTRY_CARGO_REORGANISE),
155 SLE_CONDVAR(Industry, selected_layout, SLE_UINT8, SLV_73, SL_MAX_VERSION),
156 SLE_CONDVAR(Industry, exclusive_supplier, SLE_UINT8, SLV_GS_INDUSTRY_CONTROL, SL_MAX_VERSION),
157 SLE_CONDVAR(Industry, exclusive_consumer, SLE_UINT8, SLV_GS_INDUSTRY_CONTROL, SL_MAX_VERSION),
158
159 SLEG_CONDARR("storage", _old_ind_persistent_storage.storage, SLE_UINT32, 16, SLV_76, SLV_161),
161
162 SLE_CONDVAR(Industry, random, SLE_UINT16, SLV_82, SL_MAX_VERSION),
164
167};
168
170 INDYChunkHandler() : ChunkHandler('INDY', CH_TABLE) {}
171
172 void Save() const override
173 {
174 SlTableHeader(_industry_desc);
175
176 /* Write the industries */
177 for (Industry *ind : Industry::Iterate()) {
178 SlSetArrayIndex(ind->index);
179 SlObject(ind, _industry_desc);
180 }
181 }
182
183 void LoadMoveAcceptsProduced(Industry *i, uint inputs, uint outputs) const
184 {
185 i->accepted.reserve(inputs);
186 for (uint j = 0; j != inputs; ++j) {
187 auto &a = i->accepted.emplace_back();
188 a.cargo = SlIndustryAccepted::old_cargo[j];
189 a.waiting = SlIndustryAccepted::old_waiting[j];
190 a.last_accepted = SlIndustryAccepted::old_last_accepted[j];
191 }
192
193 i->produced.reserve(outputs);
194 for (uint j = 0; j != outputs; ++j) {
195 auto &p = i->produced.emplace_back();
196 p.cargo = SlIndustryProduced::old_cargo[j];
197 p.waiting = SlIndustryProduced::old_waiting[j];
198 p.rate = SlIndustryProduced::old_rate[j];
199 p.history[THIS_MONTH].production = SlIndustryProduced::old_this_month_production[j];
200 p.history[THIS_MONTH].transported = SlIndustryProduced::old_this_month_transported[j];
201 p.history[LAST_MONTH].production = SlIndustryProduced::old_last_month_production[j];
202 p.history[LAST_MONTH].transported = SlIndustryProduced::old_last_month_transported[j];
203 }
204 }
205
206 void Load() const override
207 {
208 const std::vector<SaveLoad> slt = SlCompatTableHeader(_industry_desc, _industry_sl_compat);
209
210 int index;
211
212 SlIndustryAccepted::ResetOldStructure();
213 SlIndustryProduced::ResetOldStructure();
214
215 while ((index = SlIterateArray()) != -1) {
216 Industry *i = new (index) Industry();
217 SlObject(i, slt);
218
219 /* Before savegame version 161, persistent storages were not stored in a pool. */
221 /* Store the old persistent storage. The GRFID will be added later. */
223 i->psa = new PersistentStorage(0, 0, 0);
224 std::copy(std::begin(_old_ind_persistent_storage.storage), std::end(_old_ind_persistent_storage.storage), std::begin(i->psa->storage));
225 }
229 LoadMoveAcceptsProduced(i, INDUSTRY_NUM_INPUTS, INDUSTRY_NUM_OUTPUTS);
230 }
231 Industry::industries[i->type].push_back(i->index); // Assume savegame indices are sorted.
232 }
233 }
234
235 void FixPointers() const override
236 {
237 for (Industry *i : Industry::Iterate()) {
238 SlObject(i, _industry_desc);
239 }
240 }
241};
242
246
250
253 SLEG_VAR("wanted_inds", _industry_builder.wanted_inds, SLE_UINT32),
254};
255
258 IBLDChunkHandler() : ChunkHandler('IBLD', CH_TABLE) {}
259
260 void Save() const override
261 {
263
264 SlSetArrayIndex(0);
266 }
267
268 void Load() const override
269 {
271
273 SlGlobList(slt);
274 if (!IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY) && SlIterateArray() != -1) SlErrorCorrupt("Too many IBLD entries");
275 }
276};
277
280 SLE_VAR(IndustryTypeBuildData, probability, SLE_UINT32),
281 SLE_VAR(IndustryTypeBuildData, min_number, SLE_UINT8),
282 SLE_VAR(IndustryTypeBuildData, target_count, SLE_UINT16),
283 SLE_VAR(IndustryTypeBuildData, max_wait, SLE_UINT16),
284 SLE_VAR(IndustryTypeBuildData, wait_count, SLE_UINT16),
285};
286
289 ITBLChunkHandler() : ChunkHandler('ITBL', CH_TABLE) {}
290
291 void Save() const override
292 {
294
295 for (int i = 0; i < NUM_INDUSTRYTYPES; i++) {
296 SlSetArrayIndex(i);
298 }
299 }
300
301 void Load() const override
302 {
304
305 for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
307 }
308 int index;
309 while ((index = SlIterateArray()) != -1) {
310 if ((uint)index >= NUM_INDUSTRYTYPES) SlErrorCorrupt("Too many industry builder datas");
312 }
313 }
314};
315
316static const INDYChunkHandler INDY;
317static const IIDSChunkHandler IIDS;
318static const TIDSChunkHandler TIDS;
319static const IBLDChunkHandler IBLD;
320static const ITBLChunkHandler ITBL;
321static const ChunkHandlerRef industry_chunk_handlers[] = {
322 INDY,
323 IIDS,
324 TIDS,
325 IBLD,
326 ITBL,
327};
328
329extern 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
Default handler for saving/loading an object to/from disk.
Definition saveload.h:581
std::vector< Industry::AcceptedCargo > & GetVector(Industry *i) const override
Get instance of vector to load/save.
std::vector< Industry::ProducedCargo > & GetVector(Industry *i) const override
Get instance of vector to load/save.
Default handler for saving/loading a vector to/from disk.
Definition saveload.h:1365
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.
static const int INDUSTRY_NUM_OUTPUTS
Number of cargo types an industry can produce.
static const int INDUSTRY_NUM_INPUTS
Number of cargo types an industry can accept.
static const IndustryType NUM_INDUSTRYTYPES
total number of industry types, new and old; limited to 240 because we need some special ids like INV...
static const int INDUSTRY_ORIGINAL_NUM_OUTPUTS
Original number of produced cargo types.
Code handling saving and loading of NewGRF mappings.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition saveload.cpp:659
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
Definition saveload.cpp:351
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
void SlSetStructListLength(size_t length)
Set the length of this list.
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:1130
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
Definition saveload.h:1241
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
Definition saveload.h:688
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition saveload.h:1109
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition saveload.h:509
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
Definition saveload.h:512
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
Definition saveload.h:1186
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
Definition saveload.h:1019
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
Definition saveload.h:518
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition saveload.h:933
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition saveload.h:868
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
Definition saveload.h:1263
@ 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:399
@ 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:889
@ REF_TOWN
Load/save a reference to a town.
Definition saveload.h:604
@ REF_STATION
Load/save a reference to a station.
Definition saveload.h:603
@ REF_STORAGE
Load/save a reference to a persistent storage.
Definition saveload.h:610
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition saveload.h:1178
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition saveload.h:1002
Handlers and description of chunk.
Definition saveload.h:463
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:295
IndustryTypeBuildData builddata[NUM_INDUSTRYTYPES]
Industry build data for every industry type.
Definition industry.h:294
Data for managing the number of industries of a single industry type.
Definition industry.h:278
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 std::array< std::vector< IndustryID >, NUM_INDUSTRYTYPES > industries
List of industries of each type.
Definition industry.h:263
Class for persistent storage of data.
StorageType storage
Memory for the storage array.
Class for pooled persistent storage of data.
Tindex index
Index of this pool item.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
SaveLoad type struct.
Definition saveload.h:717