OpenTTD Source 20260711-master-g3fb3006dff
engine_sl.cpp File Reference

Code handling saving and loading of engines. More...

#include "../stdafx.h"
#include "saveload.h"
#include "compat/engine_sl_compat.h"
#include "saveload_internal.h"
#include "../engine_base.h"
#include "../string_func.h"
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

struct  ENGNChunkHandler
struct  ENGSChunkHandler
struct  EIDSChunkHandler

Functions

EngineGetTempDataEngine (EngineID index, VehicleType type, uint16_t local_id)
 Get temporary engine data for loading savegame engine information.
void CopyTempEngineData ()
 Copy data from temporary engine array into the real engine pool.
void ResetTempEngineData ()
const ChunkHandlerTable _engine_chunk_handlers (engine_chunk_handlers)

Variables

static const SaveLoad _engine_desc []
static TypedIndexContainer< std::vector< Engine >, EngineID_temp_engine
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 const EIDSChunkHandler EIDS
static const ENGNChunkHandler ENGN
static const ENGSChunkHandler ENGS
static const ChunkHandlerRef engine_chunk_handlers []

Detailed Description

Code handling saving and loading of engines.

Definition in file engine_sl.cpp.

Function Documentation

◆ CopyTempEngineData()

◆ GetTempDataEngine()

Engine * GetTempDataEngine ( EngineID index,
VehicleType type,
uint16_t local_id )

Get temporary engine data for loading savegame engine information.

Parameters
indexEngine ID of data.
typeVehicle type of engine.
local_idThe local index of the engine.
Returns
A temporary engine.

Definition at line 53 of file engine_sl.cpp.

Referenced by CopyTempEngineData(), FixTTOEngines(), ENGNChunkHandler::Load(), and ENGSChunkHandler::Load().

◆ ResetTempEngineData()

void ResetTempEngineData ( )

Definition at line 131 of file engine_sl.cpp.

Variable Documentation

◆ _engine_desc

const SaveLoad _engine_desc[]
static
Initial value:
= {
SLE_VAR(Engine, reliability, VarTypes::U16),
SLE_VAR(Engine, reliability_spd_dec, VarTypes::U16),
SLE_VAR(Engine, reliability_start, VarTypes::U16),
SLE_VAR(Engine, reliability_max, VarTypes::U16),
SLE_VAR(Engine, reliability_final, VarTypes::U16),
SLE_VAR(Engine, duration_phase_1, VarTypes::U16),
SLE_VAR(Engine, duration_phase_2, VarTypes::U16),
SLE_VAR(Engine, duration_phase_3, VarTypes::U16),
SLE_VAR(Engine, preview_wait, VarTypes::U8),
}
@ I32
A 32 bit signed int.
Definition saveload.h:683
@ U16
A 16 bit unsigned int.
Definition saveload.h:682
@ U8
A 8 bit unsigned int.
Definition saveload.h:662
@ U16
A 16 bit unsigned int.
Definition saveload.h:664
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition saveload.h:958
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition saveload.h:904
@ BigDates
Saveload version: 31, SVN revision: 5999 Change date from 1920 - 2090 to 0 - 5 000 000.
Definition saveload.h:81
@ ReplaceCustomNameArray
Saveload version: 84, SVN revision: 11822 Replace single fixed size array of custom names,...
Definition saveload.h:144
@ RobustEnginePreview
Saveload version: 179, SVN revision: 24810 Make engine preview offers robust when company ranking ch...
Definition saveload.h:258
@ MoreCompanies
Saveload version: 104, SVN revision: 14735 Increase maximum number of companies to 15.
Definition saveload.h:168
@ MinVersion
First savegame version.
Definition saveload.h:31
@ MaxVersion
Highest possible saveload version.
Definition saveload.h:421
@ HideEnginesForCompany
Saveload version: 193, SVN revision: 26802 Hiding of engines for a company.
Definition saveload.h:275
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition saveload.h:1017
static constexpr VarType U16
Store a 16 bits unsigned int.
Definition saveload.h:754
static constexpr VarType U8
Store a 8 bits unsigned int.
Definition saveload.h:752
static constexpr VarType STR
Store string.
Definition saveload.h:760
static constexpr VarType I32
Store a 32 bits signed int.
Definition saveload.h:755

Definition at line 21 of file engine_sl.cpp.

◆ _engine_id_mapping_desc

const SaveLoad _engine_id_mapping_desc[]
static
Initial value:
= {
}
static constexpr VarType U32
Store a 32 bits unsigned int.
Definition saveload.h:756

Save and load the mapping between the engine id in the pool, and the grf file it came from.

Definition at line 157 of file engine_sl.cpp.

Referenced by EIDSChunkHandler::Load(), and EIDSChunkHandler::Save().

◆ _temp_engine

TypedIndexContainer<std::vector<Engine>, EngineID> _temp_engine
static

Definition at line 44 of file engine_sl.cpp.

◆ EIDS

const EIDSChunkHandler EIDS
static

Definition at line 208 of file engine_sl.cpp.

◆ engine_chunk_handlers

const ChunkHandlerRef engine_chunk_handlers[]
static
Initial value:
= {
EIDS,
ENGN,
ENGS,
}

Definition at line 211 of file engine_sl.cpp.

◆ ENGN

const ENGNChunkHandler ENGN
static

Definition at line 209 of file engine_sl.cpp.

◆ ENGS

const ENGSChunkHandler ENGS
static

Definition at line 210 of file engine_sl.cpp.