12 #include "../stdafx.h" 14 #include "../engine_base.h" 15 #include "../string_func.h" 18 #include "../safeguards.h" 20 static const SaveLoad _engine_desc[] = {
51 static std::vector<Engine*> _temp_engine;
60 uint8 *zero = CallocT<uint8>(
sizeof(
Engine));
79 if (index < _temp_engine.size()) {
80 return _temp_engine[index];
81 }
else if (index == _temp_engine.size()) {
83 return _temp_engine[index];
89 static void Save_ENGN()
93 SlSetArrayIndex(e->
index);
98 static void Load_ENGN()
105 Engine *e = GetTempDataEngine(index);
125 if (e->
index >= _temp_engine.size())
break;
148 for (std::vector<Engine*>::iterator it = _temp_engine.begin(); it != _temp_engine.end(); ++it) {
151 _temp_engine.clear();
154 static void Load_ENGS()
164 Engine *e = GetTempDataEngine(engine);
178 static void Save_EIDS()
183 SlSetArrayIndex(index);
184 SlObject(eid, _engine_id_mapping_desc);
188 static void Load_EIDS()
190 _engine_mngr.
Clear();
194 SlObject(eid, _engine_id_mapping_desc);
199 {
'EIDS', Save_EIDS, Load_EIDS, NULL, NULL, CH_ARRAY },
200 {
'ENGN', Save_ENGN, Load_ENGN, NULL, NULL, CH_ARRAY },
201 {
'ENGS', NULL, Load_ENGS, NULL, NULL, CH_RIFF |
CH_LAST },
#define SLE_CONDNULL(length, from, to)
Empty space in some savegame versions.
uint16 reliability_start
Initial reliability of the engine.
uint16 reliability
Current reliability of the engine.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
#define SLE_CONDSTR(base, variable, type, length, from, to)
Storage of a string in some savegame versions.
Date intro_date
Date of introduction of the engine.
char * CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
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...
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company...
void Clear()
Remove all items from the list.
const T * Begin() const
Get the pointer to the first item (const)
Tindex index
Index of this pool item.
byte flags
Flags of the engine.
const T * End() const
Get the pointer behind the last valid item (const)
uint16 duration_phase_2
Second reliability phase in months, keeping reliability_max.
T * Append(uint to_add=1)
Append an item and return it.
void SlArray(void *array, size_t length, VarType conv)
Save/Load an array.
uint16 reliability_spd_dec
Speed of reliability decay between services (per day).
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
uint16 duration_phase_3
Third reliability phase on months, decaying to reliability_final.
uint16 duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max...
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
uint16 reliability_max
Maximal reliability of the engine.
#define SL_MAX_VERSION
Highest possible savegame version.
static bool IsSavegameVersionBefore(uint16 major, byte minor=0)
Checks whether the savegame is below major.
#define lengthof(x)
Return the length of an fixed size array.
uint16 reliability_final
Final reliability of the engine.
char * name
Custom name of engine.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Handlers and description of chunk.
#define SLE_END()
End marker of a struct/class save or load.
byte preview_wait
Daily countdown timer for timeout of offering the engine to the preview_company company.
uint16 EngineID
Unique identification number of an engine.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
static Engine * CallocEngine()
Allocate an Engine structure, but not using the pools.
CompanyByte preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Declaration of functions used in more save/load files.
Last chunk in this array.
static void FreeEngine(Engine *e)
Deallocate an Engine constructed by CallocEngine.