21static OldPersistentStorage _old_ind_persistent_storage;
25 static inline const SaveLoad description[] = {
29 static inline const SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
52 for (
auto &h : history) {
53 if (--len > history.size())
break;
61 static inline const SaveLoad description[] = {
74 static inline std::array<CargoType, INDUSTRY_NUM_INPUTS>
old_cargo;
75 static inline std::array<uint16_t, INDUSTRY_NUM_INPUTS>
old_waiting;
79 static void ResetOldStructure()
89 static inline const SaveLoad description[] = {
93 static inline const SaveLoadCompatTable compat_description = _industry_produced_history_sl_compat;
115 if (--len > p->
history.size())
break;
123 static inline const SaveLoad description[] = {
135 static inline std::array<CargoType, INDUSTRY_NUM_OUTPUTS>
old_cargo;
136 static inline std::array<uint16_t, INDUSTRY_NUM_OUTPUTS>
old_waiting;
137 static inline std::array<uint8_t, INDUSTRY_NUM_OUTPUTS>
old_rate;
144 static void ResetOldStructure()
156static const SaveLoad _industry_desc[] = {
223 SlSetArrayIndex(ind->index);
228 void LoadMoveAcceptsProduced(
Industry *i, uint inputs, uint outputs)
const
231 for (uint j = 0; j != inputs; ++j) {
232 auto &a = i->
accepted.emplace_back();
239 for (uint j = 0; j != outputs; ++j) {
240 auto &p = i->
produced.emplace_back();
257 SlIndustryAccepted::ResetOldStructure();
258 SlIndustryProduced::ResetOldStructure();
269 std::copy(std::begin(_old_ind_persistent_storage.storage), std::end(_old_ind_persistent_storage.storage), std::begin(i->
psa->
storage));
279 size_t oldest_valid = LAST_MONTH;
284 for (
size_t n = LAST_MONTH; n < std::size(p.history); ++n) {
285 if (p.history[n].production == 0 && p.history[n].transported == 0)
continue;
286 oldest_valid = std::max(oldest_valid, n);
291 i->
valid_history = (std::numeric_limits<uint64_t>::max() >> (std::numeric_limits<uint64_t>::digits - (oldest_valid + 1 - LAST_MONTH))) << LAST_MONTH;
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.
Label< struct GrfIDTag > 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.
#define SLE_OBJECT_ADDRESS(base, variable)
Macro to be able to pass the variable type and construct the SaveLoad::AddressFunction given a base c...
#define SLE_GLOBAL_ADDRESS(variable)
Macro to be able to pass the variable type and construct the SaveLoad::AddressFunction given a global...
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
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...
@ 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.
@ Table
An Array with a header describing the elements.
Definition of base types and functions in a cross-platform compatible way.
@ AllowControlCode
Allow the special control codes.
ChunkHandler(ChunkId id, ChunkType type)
Create this ChunkHandler.
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.
NewGRFMappingChunkHandler(ChunkId id, OverrideManagerBase &mapping)
Create the handler.
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 SaveLoad StructList(std::string name, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a list of structs, optionally in some savegame versions.
static SaveLoad Variable(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a variable in some savegame versions.
static SaveLoad Array(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of an array in some savegame versions.
static SaveLoad Reference(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a reference to a pool element in some savegame versions.
static SaveLoad String(std::string name, AddressFunction< T > address_func, StringValidationSettings string_validation_settings={}, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a string in some savegame versions.
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.