Go to the documentation of this file.
10 #include "../stdafx.h"
12 #include "../engine_base.h"
13 #include "../string_func.h"
16 #include "../safeguards.h"
18 static const SaveLoad _engine_desc[] = {
49 static std::vector<Engine*> _temp_engine;
58 uint8 *zero = CallocT<uint8>(
sizeof(
Engine));
77 if (index < _temp_engine.size()) {
78 return _temp_engine[index];
79 }
else if (index == _temp_engine.size()) {
81 return _temp_engine[index];
87 static void Save_ENGN()
90 SlSetArrayIndex(e->index);
95 static void Load_ENGN()
102 Engine *e = GetTempDataEngine(index);
121 if (e->
index >= _temp_engine.size())
break;
143 ResetTempEngineData();
146 void ResetTempEngineData()
149 for (std::vector<Engine*>::iterator it = _temp_engine.begin(); it != _temp_engine.end(); ++it) {
152 _temp_engine.clear();
155 static void Load_ENGS()
165 Engine *e = GetTempDataEngine(engine);
179 static void Save_EIDS()
183 SlSetArrayIndex(index);
189 static void Load_EIDS()
191 _engine_mngr.clear();
200 {
'EIDS', Save_EIDS, Load_EIDS,
nullptr,
nullptr, CH_ARRAY },
201 {
'ENGN', Save_ENGN, Load_ENGN,
nullptr,
nullptr, CH_ARRAY },
202 {
'ENGS',
nullptr, Load_ENGS,
nullptr,
nullptr, CH_RIFF |
CH_LAST },
uint16 reliability_max
Maximal reliability of the engine.
uint16 duration_phase_3
Third reliability phase in months, decaying to reliability_final.
@ SL_MIN_VERSION
First savegame version.
uint16 reliability_spd_dec
Speed of reliability decay between services (per day).
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
Tindex index
Index of this pool item.
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
uint16 duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
uint16 reliability_start
Initial reliability of the engine.
@ CH_LAST
Last chunk in this array.
CompanyID preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
Handlers and description of chunk.
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company.
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
uint16 EngineID
Unique identification number of an engine.
static Engine * CallocEngine()
Allocate an Engine structure, but not using the pools.
#define SLE_END()
End marker of a struct/class save or load.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
static void FreeEngine(Engine *e)
Deallocate an Engine constructed by CallocEngine.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
uint16 reliability_final
Final reliability of the engine.
@ SL_MAX_VERSION
Highest possible saveload version.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
std::string name
Custom name of engine.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
static const SaveLoad _engine_id_mapping_desc[]
Save and load the mapping between the engine id in the pool, and the grf file it came from.
byte preview_wait
Daily countdown timer for timeout of offering the engine to the preview_company company.
#define lengthof(x)
Return the length of an fixed size array.
@ INVALID_COMPANY
An invalid company.
byte flags
Flags of the engine.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
void SlArray(void *array, size_t length, VarType conv)
Save/Load an array.
Date intro_date
Date of introduction of the engine.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
uint16 reliability
Current reliability of the engine.
uint16 duration_phase_2
Second reliability phase in months, keeping reliability_max.