OpenTTD Source  12.0-beta2
engine_sl.cpp File Reference
#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 <vector>
#include "../safeguards.h"

Go to the source code of this file.

Data Structures

struct  ENGNChunkHandler
 
struct  ENGSChunkHandler
 
struct  EIDSChunkHandler
 

Functions

static EngineCallocEngine ()
 Allocate an Engine structure, but not using the pools. More...
 
static void FreeEngine (Engine *e)
 Deallocate an Engine constructed by CallocEngine. More...
 
EngineGetTempDataEngine (EngineID index)
 
void CopyTempEngineData ()
 Copy data from temporary engine array into the real engine pool.
 
void ResetTempEngineData ()
 

Variables

static const SaveLoad _engine_desc []
 
static std::vector< Engine * > _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. More...
 
static const EIDSChunkHandler EIDS
 
static const ENGNChunkHandler ENGN
 
static const ENGSChunkHandler ENGS
 
static const ChunkHandlerRef engine_chunk_handlers []
 
const ChunkHandlerTable _engine_chunk_handlers (engine_chunk_handlers)
 

Detailed Description

Code handling saving and loading of engines

Definition in file engine_sl.cpp.

Function Documentation

◆ CallocEngine()

static Engine* CallocEngine ( )
static

Allocate an Engine structure, but not using the pools.

The allocated Engine must be freed using FreeEngine;

Returns
Allocated engine.

Definition at line 52 of file engine_sl.cpp.

◆ FreeEngine()

static void FreeEngine ( Engine e)
static

Deallocate an Engine constructed by CallocEngine.

Parameters
eEngine to free.

Definition at line 63 of file engine_sl.cpp.

References free().

Variable Documentation

◆ _engine_desc

const SaveLoad _engine_desc[]
static
Initial value:
= {
SLE_CONDVAR(Engine, intro_date, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
SLE_CONDVAR(Engine, intro_date, SLE_INT32, SLV_31, SL_MAX_VERSION),
SLE_CONDVAR(Engine, age, SLE_FILE_U16 | SLE_VAR_I32, SL_MIN_VERSION, SLV_31),
SLE_VAR(Engine, reliability, SLE_UINT16),
SLE_VAR(Engine, reliability_spd_dec, SLE_UINT16),
SLE_VAR(Engine, reliability_start, SLE_UINT16),
SLE_VAR(Engine, reliability_max, SLE_UINT16),
SLE_VAR(Engine, reliability_final, SLE_UINT16),
SLE_VAR(Engine, duration_phase_1, SLE_UINT16),
SLE_VAR(Engine, duration_phase_2, SLE_UINT16),
SLE_VAR(Engine, duration_phase_3, SLE_UINT16),
SLE_VAR(Engine, flags, SLE_UINT8),
SLE_CONDVAR(Engine, preview_asked, SLE_UINT16, SLV_179, SL_MAX_VERSION),
SLE_CONDVAR(Engine, preview_company, SLE_UINT8, SLV_179, SL_MAX_VERSION),
SLE_VAR(Engine, preview_wait, SLE_UINT8),
SLE_CONDVAR(Engine, company_avail, SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_104),
SLE_CONDVAR(Engine, company_avail, SLE_UINT16, SLV_104, SL_MAX_VERSION),
SLE_CONDVAR(Engine, company_hidden, SLE_UINT16, SLV_193, SL_MAX_VERSION),
}

Definition at line 22 of file engine_sl.cpp.

◆ _engine_id_mapping_desc

const SaveLoad _engine_id_mapping_desc[]
static
Initial value:
= {
SLE_VAR(EngineIDMapping, grfid, SLE_UINT32),
SLE_VAR(EngineIDMapping, internal_id, SLE_UINT16),
SLE_VAR(EngineIDMapping, type, SLE_UINT8),
SLE_VAR(EngineIDMapping, substitute_id, SLE_UINT8),
}

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

Definition at line 179 of file engine_sl.cpp.

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

◆ engine_chunk_handlers

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

Definition at line 217 of file engine_sl.cpp.

SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition: saveload.h:35
SLE_CONDSSTR
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition: saveload.h:744
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition: saveload.h:702
SLV_84
@ SLV_84
84 11822
Definition: saveload.h:147
SLE_STR
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:798
SLV_104
@ SLV_104
104 14735
Definition: saveload.h:171
Engine
Definition: engine_base.h:27
SLV_179
@ SLV_179
179 24810
Definition: saveload.h:261
SLV_31
@ SLV_31
31 5999
Definition: saveload.h:84
Window::flags
WindowFlags flags
Window flags.
Definition: window_gui.h:305
EngineIDMapping
Definition: engine_base.h:167
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition: saveload.h:342
SLE_VAR
#define SLE_VAR(base, variable, type)
Storage of a variable in every version of a savegame.
Definition: saveload.h:772
SLV_193
@ SLV_193
193 26802
Definition: saveload.h:279