OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
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();
uint16_t reliability_max
Maximal reliability of the engine.
uint16_t 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.
@ INVALID_COMPANY
An invalid company.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ SL_MIN_VERSION
First savegame version.
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_t reliability_final
Final 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.
uint8_t flags
Flags of the engine.
static Engine * CallocEngine()
Allocate an Engine structure, but not using the pools.
@ CH_READONLY
Chunk is never saved.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
TimerGameCalendar::Date intro_date
Date of introduction of the engine.
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.
#define lengthof(array)
Return the length of an fixed size array.
void Load() const override
Load the chunk.
void CopyTempEngineData()
Copy data from temporary engine array into the real engine pool.
@ SL_MAX_VERSION
Highest possible saveload version.
static void FreeEngine(Engine *e)
Deallocate an Engine constructed by CallocEngine.
uint16_t duration_phase_1
First reliability phase in months, increasing reliability from reliability_start to reliability_max.
uint8_t preview_wait
Daily countdown timer for timeout of offering the engine to the preview_company company.
uint16_t reliability
Current reliability of the engine.
uint16_t reliability_start
Initial reliability of the engine.
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.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
#define MAX_UVALUE(type)
The largest value that can be entered in a variable.
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.
uint16_t EngineID
Unique identification number of an engine.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
uint16_t duration_phase_2
Second reliability phase in months, keeping reliability_max.
uint16_t duration_phase_3
Third reliability phase in months, decaying to reliability_final.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void Save() const override
Save the chunk.
int32_t age
Age of the engine in months.