OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
16 #include "../engine_base.h"
17 #include "../string_func.h"
20 #include "../safeguards.h"
22 static const SaveLoad _engine_desc[] = {
45 static std::vector<Engine*> _temp_engine;
54 uint8 *zero = CallocT<uint8>(
sizeof(
Engine));
73 if (index < _temp_engine.size()) {
74 return _temp_engine[index];
75 }
else if (index == _temp_engine.size()) {
77 return _temp_engine[index];
91 SlSetArrayIndex(e->index);
105 Engine *e = GetTempDataEngine(index);
125 if (e->index >= _temp_engine.size())
break;
127 const Engine *se = GetTempDataEngine(e->index);
138 e->flags = se->
flags;
147 ResetTempEngineData();
150 void ResetTempEngineData()
153 for (std::vector<Engine*>::iterator it = _temp_engine.begin(); it != _temp_engine.end(); ++it) {
156 _temp_engine.clear();
172 Engine *e = GetTempDataEngine(engine);
195 SlSetArrayIndex(index);
205 _engine_mngr.clear();
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.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
CompanyMask company_avail
Bit for each company whether the engine is available for that company.
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
#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.
void Load() const override
Load the chunk.
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.
uint16 EngineID
Unique identification number of an engine.
static Engine * CallocEngine()
Allocate an Engine structure, but not using the pools.
A trimmed down version of what std::span will be in C++20.
@ CH_READONLY
Chunk is never saved.
const SaveLoadCompat _engine_sl_compat[]
Original field order for _engine_desc.
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 Load() const override
Load the chunk.
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.
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.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
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.
const SaveLoadCompat _engine_id_mapping_sl_compat[]
Original field order for _engine_id_mapping_desc.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
@ INVALID_COMPANY
An invalid company.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
byte flags
Flags of the engine.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
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.
void Save() const override
Save the chunk.