10 #include "../stdafx.h"
16 #include "../engine_base.h"
17 #include "../string_func.h"
19 #include "../safeguards.h"
21 static const SaveLoad _engine_desc[] = {
44 static std::vector<Engine*> _temp_engine;
53 uint8_t *zero = CallocT<uint8_t>(
sizeof(
Engine));
72 if (index < _temp_engine.size()) {
73 return _temp_engine[index];
74 }
else if (index == _temp_engine.size()) {
76 return _temp_engine[index];
90 SlSetArrayIndex(e->index);
104 Engine *e = GetTempDataEngine(index);
124 if (e->index >= _temp_engine.size())
break;
126 const Engine *se = GetTempDataEngine(e->index);
137 e->flags = se->
flags;
146 ResetTempEngineData();
149 void ResetTempEngineData()
152 for (std::vector<Engine*>::iterator it = _temp_engine.begin(); it != _temp_engine.end(); ++it) {
155 _temp_engine.clear();
171 Engine *e = GetTempDataEngine(engine);
194 SlSetArrayIndex(index);
204 _engine_mngr.clear();
@ INVALID_COMPANY
An invalid company.
static Engine * CallocEngine()
Allocate an Engine structure, but not using the pools.
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.
static void FreeEngine(Engine *e)
Deallocate an Engine constructed by CallocEngine.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
Loading for engine chunks before table headers were added.
const SaveLoadCompat _engine_id_mapping_sl_compat[]
Original field order for _engine_id_mapping_desc.
const SaveLoadCompat _engine_sl_compat[]
Original field order for _engine_desc.
uint16_t EngineID
Unique identification number of an engine.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Functions/types related to saving and loading games.
@ CH_READONLY
Chunk is never saved.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler 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.
@ SL_MAX_VERSION
Highest possible saveload version.
@ SL_MIN_VERSION
First savegame version.
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Declaration of functions used in more save/load files.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
#define lengthof(array)
Return the length of an fixed size array.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Handlers and description of chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
uint16_t reliability_spd_dec
Speed of reliability decay between services (per day).
uint16_t reliability_start
Initial reliability of the engine.
TimerGameCalendar::Date intro_date
Date of introduction of the engine.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
uint16_t reliability_max
Maximal reliability of the engine.
uint16_t reliability_final
Final reliability of the engine.
CompanyID preview_company
Company which is currently being offered a preview INVALID_COMPANY means no company.
uint16_t duration_phase_3
Third reliability phase in months, decaying to reliability_final.
uint16_t duration_phase_2
Second reliability phase in months, keeping reliability_max.
uint8_t preview_wait
Daily countdown timer for timeout of offering the engine to the preview_company company.
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company.
uint16_t reliability
Current reliability of the engine.
CompanyMask preview_asked
Bit for each company which has already been offered a preview.
int32_t age
Age of the engine in months.
std::string name
Custom name of engine.
uint16_t duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
uint8_t flags
Flags of the engine.
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.