20static OldPersistentStorage _old_ind_persistent_storage;
24 static inline const SaveLoad description[] = {
28 static inline const SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
51 for (
auto &h : history) {
52 if (--len > history.size())
break;
60 static inline const SaveLoad description[] = {
73 static inline std::array<CargoType, INDUSTRY_NUM_INPUTS>
old_cargo;
74 static inline std::array<uint16_t, INDUSTRY_NUM_INPUTS>
old_waiting;
78 static void ResetOldStructure()
88 static inline const SaveLoad description[] = {
92 static inline const SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
114 if (--len > p->
history.size())
break;
122 static inline const SaveLoad description[] = {
134 static inline std::array<CargoType, INDUSTRY_NUM_OUTPUTS>
old_cargo;
135 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS>
old_waiting;
136 static inline std::array<uint8_t, INDUSTRY_NUM_OUTPUTS>
old_rate;
143 static void ResetOldStructure()
155static const SaveLoad _industry_desc[] = {
213struct INDYChunkHandler : ChunkHandler {
222 SlSetArrayIndex(ind->index);
227 void LoadMoveAcceptsProduced(
Industry *i, uint inputs, uint outputs)
const
230 for (uint j = 0; j != inputs; ++j) {
231 auto &a = i->
accepted.emplace_back();
238 for (uint j = 0; j != outputs; ++j) {
239 auto &p = i->
produced.emplace_back();
256 SlIndustryAccepted::ResetOldStructure();
257 SlIndustryProduced::ResetOldStructure();
268 std::copy(std::begin(_old_ind_persistent_storage.storage), std::end(_old_ind_persistent_storage.storage), std::begin(i->
psa->
storage));
278 size_t oldest_valid = LAST_MONTH;
283 for (
size_t n = LAST_MONTH; n < std::size(p.history); ++n) {
284 if (p.history[n].production == 0 && p.history[n].transported == 0)
continue;
285 oldest_valid = std::max(oldest_valid, n);
290 i->
valid_history = (std::numeric_limits<uint64_t>::max() >> (std::numeric_limits<uint64_t>::digits - (oldest_valid + 1 - LAST_MONTH))) << LAST_MONTH;
305struct IIDSChunkHandler : NewGRFMappingChunkHandler {
306 IIDSChunkHandler() : NewGRFMappingChunkHandler(
'IIDS', _industry_mngr) {}
309struct TIDSChunkHandler : NewGRFMappingChunkHandler {
310 TIDSChunkHandler() : NewGRFMappingChunkHandler(
'TIDS', _industile_mngr) {}
319struct IBLDChunkHandler : ChunkHandler {
350struct ITBLChunkHandler : ChunkHandler {
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
Default handler for saving/loading an object to/from disk.
SaveLoadTable GetDescription() const override
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
void Load(Industry::AcceptedCargo *a) const override
Load the object from disk.
void Save(Industry::AcceptedCargo *a) const override
Save the object to disk.
static std::array< uint16_t, INDUSTRY_NUM_INPUTS > old_waiting
std::vector< Industry::AcceptedCargo > & GetVector(Industry *i) const override
Get instance of vector to load/save.
static std::array< CargoType, INDUSTRY_NUM_INPUTS > old_cargo
static std::array< TimerGameEconomy::Date, INDUSTRY_NUM_INPUTS > old_last_accepted
void Save(Industry::ProducedCargo *p) const override
Save the object to disk.
void Load(Industry::ProducedCargo *p) const override
Load the object from disk.
static std::array< uint16_t, INDUSTRY_NUM_OUTPUTS > old_last_month_production
static std::array< uint16_t, INDUSTRY_NUM_OUTPUTS > old_this_month_transported
std::vector< Industry::ProducedCargo > & GetVector(Industry *i) const override
Get instance of vector to load/save.
static std::array< CargoType, INDUSTRY_NUM_OUTPUTS > old_cargo
static std::array< uint16_t, INDUSTRY_NUM_OUTPUTS > old_last_month_transported
static std::array< uint16_t, INDUSTRY_NUM_OUTPUTS > old_waiting
static std::array< uint16_t, INDUSTRY_NUM_OUTPUTS > old_this_month_production
static std::array< uint8_t, INDUSTRY_NUM_OUTPUTS > old_rate
StrongType::Typedef< int32_t, DateTag< struct Economy >, StrongType::Compare, StrongType::Integer > Date
Default handler for saving/loading a vector to/from disk.
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 IT_...
static const int INDUSTRY_ORIGINAL_NUM_OUTPUTS
Original number of produced cargo types.
@ Invalid
An invalid spec feature.
Code handling saving and loading of NewGRF mappings.
uint32_t GrfID
The unique identifier of a NewGRF.
A number of safeguards to prevent using unsafe methods.
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.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
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.
@ U32
A 32 bit unsigned int.
@ I32
A 32 bit signed int.
@ U16
A 16 bit unsigned int.
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SaveLoadType::Variable elements in some savegame versions.
@ U8
A 8 bit unsigned int.
@ U16
A 16 bit unsigned int.
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
@ Station
Load/save a reference to a station.
@ Storage
Load/save a reference to a persistent storage.
@ Town
Load/save a reference to a town.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define SLEG_VAR(name, variable, type)
Storage of a global variable in every savegame version.
#define SLE_REF(base, variable, type)
Storage of a reference in every version of a savegame.
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ BigDates
Saveload version: 31, SVN revision: 5999 Change date from 1920 - 2090 to 0 - 5 000 000.
@ StoreIndustryCargo
Saveload version: 78, SVN revision: 11176 Store an industry's cargo, so it can be customised upon bu...
@ IndustryText
Saveload version: 289, GitHub pull request: 8576, release: 1.11.0-RC1 Additional GS text for industr...
@ ProductionHistory
Saveload version: 343, GitHub pull request: 10541 Industry production history.
@ NewGRFIndustryRandomTriggers
Saveload version: 82, SVN revision: 11410 NewGRF random triggers for industries.
@ NewGRFPersistentStorage
Saveload version: 76, SVN revision: 11139 Persistently store some state of NewGRF objects/entities.
@ ExtendIndustryCargoSlots
Saveload version: 202, GitHub pull request: 6867 Increase industry cargo slots to 16 in,...
@ MultipleRoadStops
Saveload version: 6.0, SVN revision: 1721 Multi tile road stops, and some map size related fixes.
@ NewGRFIndustryLayout
Saveload version: 73, SVN revision: 10903 NewGRF provided layouts for industries.
@ MinVersion
First savegame version.
@ IndustryAcceptedHistory
Saveload version: 357, GitHub pull request: 14321 Add per-industry history of cargo delivered and wa...
@ IndustryCargoReorganise
Saveload version: 315, GitHub pull request: 10853 Industry accepts/produced data reorganised.
@ IndustryNumValidHistory
Saveload version: 356, GitHub pull request: 14416 Store number of valid history records for industri...
@ ServeNeutralIndustries
Saveload version: 210, GitHub pull request: 7234 Company stations can serve industries with attached...
@ MaxVersion
Highest possible saveload version.
@ PersistentStoragePool
Saveload version: 161, SVN revision: 22567 Store persistent storage in a pool.
@ CargoPaymentOverflow
Saveload version: 70, SVN revision: 10541 Fix overflow of cargo payment rates, plus preparation for ...
@ RiffToArray
Saveload version: 294, GitHub pull request: 9375 Changed many ChunkType::Riff chunks to ChunkType::A...
@ GSIndustryControl
Saveload version: 287, GitHub pull request: 7912 and 8115 GS industry control.
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
@ Table
An Array with a header describing the elements.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition of base types and functions in a cross-platform compatible way.
@ AllowControlCode
Allow the special control codes.
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.
Data for managing the number of industries of a single industry type.
CargoType cargo
Cargo type.
HistoryData< AcceptedHistory > & GetOrCreateHistory()
Get history data, creating it if necessary.
std::unique_ptr< HistoryData< AcceptedHistory > > history
History of accepted and waiting cargo.
CargoType cargo
Cargo type.
HistoryData< ProducedHistory > history
History of cargo produced and transported for this month and 24 previous months.
Defines the internal data of a functional industry.
IndustryType type
type of industry.
PersistentStorage * psa
Persistent storage for NewGRF industries.
ValidHistoryMask valid_history
Mask of valid history records.
ProducedCargoes produced
produced cargo slots
AcceptedCargoes accepted
accepted cargo slots
static std::array< FlatSet< IndustryID >, NUM_INDUSTRYTYPES > industries
List of industries of each type.
StorageType storage
Memory for the storage array.
static Pool::IterateWrapper< Industry > Iterate(size_t from=0)
static T * Create(Targs &&... args)
static T * CreateAtIndex(IndustryID index, Targs &&... args)
static bool CanAllocateItem(size_t n=1)
static constexpr VarType U16
Store a 16 bits unsigned int.
static constexpr VarType U8
Store a 8 bits unsigned int.
static constexpr VarType STR
Store string.
static constexpr VarType U64
Store a 64 bits unsigned int.
static constexpr VarType U32
Store a 32 bits unsigned int.
static constexpr VarType I32
Store a 32 bits signed int.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.