Functions/types related to saving and loading games. More...
#include "../fileio_type.h"
#include "../strings_type.h"
Go to the source code of this file.
Data Structures | |
struct | ChunkHandler |
Handlers and description of chunk. More... | |
struct | NullStruct |
struct | SaveLoad |
SaveLoad type struct. More... | |
Defines | |
#define | SIZE_MAX ((size_t)-1) |
#define | SLE_GENERAL(cmd, base, variable, type, length, from, to) {false, cmd, type, length, from, to, (void*)cpp_offsetof(base, variable)} |
Storage of simple variables, references (pointers), and arrays. | |
#define | SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to) |
Storage of a variable in some savegame versions. | |
#define | SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to) |
Storage of a reference in some savegame versions. | |
#define | SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to) |
Storage of an array in some savegame versions. | |
#define | SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to) |
Storage of a string in some savegame versions. | |
#define | SLE_CONDLST(base, variable, type, from, to) SLE_GENERAL(SL_LST, base, variable, type, 0, from, to) |
Storage of a list in some savegame versions. | |
#define | SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, 0, SL_MAX_VERSION) |
Storage of a variable in every version of a savegame. | |
#define | SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, 0, SL_MAX_VERSION) |
Storage of a reference in every version of a savegame. | |
#define | SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION) |
Storage of an array in every version of a savegame. | |
#define | SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION) |
Storage of a string in every savegame version. | |
#define | SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, 0, SL_MAX_VERSION) |
Storage of a list in every savegame version. | |
#define | SLE_NULL(length) SLE_CONDNULL(length, 0, SL_MAX_VERSION) |
Empty space in every savegame version. | |
#define | SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to) |
Empty space in some savegame versions. | |
#define | SLE_WRITEBYTE(base, variable, value) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, value, value) |
Translate values ingame to different values in the savegame and vv. | |
#define | SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, 0, SL_MAX_VERSION, NULL} |
#define | SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, 0, SL_MAX_VERSION, NULL} |
#define | SLE_END() {false, SL_END, 0, 0, 0, 0, NULL} |
End marker of a struct/class save or load. | |
#define | SLEG_GENERAL(cmd, variable, type, length, from, to) {true, cmd, type, length, from, to, (void*)&variable} |
Storage of global simple variables, references (pointers), and arrays. | |
#define | SLEG_CONDVAR(variable, type, from, to) SLEG_GENERAL(SL_VAR, variable, type, 0, from, to) |
Storage of a global variable in some savegame versions. | |
#define | SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to) |
Storage of a global reference in some savegame versions. | |
#define | SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to) |
Storage of a global array in some savegame versions. | |
#define | SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to) |
Storage of a global string in some savegame versions. | |
#define | SLEG_CONDLST(variable, type, from, to) SLEG_GENERAL(SL_LST, variable, type, 0, from, to) |
Storage of a global list in some savegame versions. | |
#define | SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION) |
Storage of a global variable in every savegame version. | |
#define | SLEG_REF(variable, type) SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION) |
Storage of a global reference in every savegame version. | |
#define | SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION) |
Storage of a global array in every savegame version. | |
#define | SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION) |
Storage of a global string in every savegame version. | |
#define | SLEG_LST(variable, type) SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION) |
Storage of a global list in every savegame version. | |
#define | SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)NULL} |
Empty global space in some savegame versions. | |
#define | SLEG_END() {true, SL_END, 0, 0, 0, 0, NULL} |
End marker of global variables save or load. | |
Typedefs | |
typedef void | ChunkSaveLoadProc () |
typedef void | AutolengthProc (void *arg) |
typedef uint32 | VarType |
typedef byte | SaveLoadType |
Save/load type. | |
typedef SaveLoad | SaveLoadGlobVarList |
Same as SaveLoad but global variables are used (for better readability);. | |
Enumerations | |
enum | SaveOrLoadResult { SL_OK = 0, SL_ERROR = 1, SL_REINIT = 2 } |
Save or load result codes. More... | |
enum | SaveOrLoadMode { SL_INVALID = -1, SL_LOAD = 0, SL_SAVE = 1, SL_OLD_LOAD = 2, SL_PNG = 3, SL_BMP = 4, SL_LOAD_CHECK = 5 } |
Save or load mode. More... | |
enum | SavegameType { SGT_TTD, SGT_TTDP1, SGT_TTDP2, SGT_OTTD, SGT_TTO, SGT_INVALID = 0xFF } |
Types of save games. More... | |
enum | SLRefType { REF_ORDER = 0, REF_VEHICLE = 1, REF_STATION = 2, REF_TOWN = 3, REF_VEHICLE_OLD = 4, REF_ROADSTOPS = 5, REF_ENGINE_RENEWS = 6, REF_CARGO_PACKET = 7, REF_ORDERLIST = 8 } |
Type of reference (SLE_REF, SLE_CONDREF). More... | |
enum | SaveLoadVersions { BEFORE_ADDING_PATCHES_SL = 185, BACK_ONE_WAY_SIGNAL_SAFE_WAITING_SL = 186, TREE_GROWTH_RATE_SL = 188, PROG_SIGS_SL = 189, DAYLENGHT_SL = 190, TOWN_CARGO_FACTOR_SL = 191, SL_RESERVATION = 192, SL_CAPACITIES = 193, SL_COMPONENTS = 194, SL_DEMANDS = 195, SL_MCF = 196, SL_FLOWMAP = 197, SL_CARGOMAP = 198, SL_EXT_RATING = 199, TIMESEP_SV = 200, MORE_HEIGHTLEVEL_SAVEGAME_VERSION = 201, KEEP_COMPATIBLE_1_SV = 202, KEEP_COMPATIBLE_2_SV = 203, KEEP_COMPATIBLE_3_SV = 204, KEEP_COMPATIBLE_4_SV = 205, KEEP_COMPATIBLE_5_SV = 206, KEEP_COMPATIBLE_6_SV = 206, KEEP_COMPATIBLE_7_SV = 206, KEEP_COMPATIBLE_8_SV = 207, INGAME_TREELINE_SV = 208, KEEP_COMPATIBLE_9_SV = 209, KEEP_COMPATIBLE_10_SV = 210, KEEP_COMPATIBLE_11_SV = 210, IS_SL = 211, EXCLUSIVE_DL_SL = 212, KEEP_COMPATIBLE_12_SV = 213, KEEP_COMPATIBLE_13_SV = 214, KEEP_COMPATIBLE_14_SV = 215, KEEP_COMPATIBLE_15_SV = 216, KEEP_COMPATIBLE_16_SV = 217, KEEP_COMPATIBLE_17_SV = 218, KEEP_COMPATIBLE_18_SV = 219, KEEP_COMPATIBLE_19_SV = 220, KEEP_COMPATIBLE_20_SV = 221, SL_IB = 222, TL_SV = 223, TOWN_GROWTH_SV = 224, DESERT_SV = 225, KEEP_COMPATIBLE_21_SV = 226, SPEED_SIGNALS_SV = 227, KEEP_COMPATIBLE_22_SV = 228, KEEP_COMPATIBLE_23_SV = 229, KEEP_COMPATIBLE_24_SV = 230, TREEDRAG_SV = 231, INFRA_MAINT_SV = 232, SL_MAX_VERSION = 255 } |
save/load versions used for the various branches / patches More... | |
enum | ChunkType { CH_RIFF = 0, CH_ARRAY = 1, CH_SPARSE_ARRAY = 2, CH_TYPE_MASK = 3, CH_LAST = 8, CH_AUTO_LENGTH = 16 } |
Flags of a chunk. More... | |
enum | VarTypes { SLE_FILE_I8 = 0, SLE_FILE_U8 = 1, SLE_FILE_I16 = 2, SLE_FILE_U16 = 3, SLE_FILE_I32 = 4, SLE_FILE_U32 = 5, SLE_FILE_I64 = 6, SLE_FILE_U64 = 7, SLE_FILE_STRINGID = 8, SLE_FILE_STRING = 9, SLE_VAR_BL = 0 << 4, SLE_VAR_I8 = 1 << 4, SLE_VAR_U8 = 2 << 4, SLE_VAR_I16 = 3 << 4, SLE_VAR_U16 = 4 << 4, SLE_VAR_I32 = 5 << 4, SLE_VAR_U32 = 6 << 4, SLE_VAR_I64 = 7 << 4, SLE_VAR_U64 = 8 << 4, SLE_VAR_NULL = 9 << 4, SLE_VAR_STRB = 10 << 4, SLE_VAR_STRBQ = 11 << 4, SLE_VAR_STR = 12 << 4, SLE_VAR_STRQ = 13 << 4, SLE_VAR_NAME = 14 << 4, SLE_VAR_CHAR = SLE_VAR_I8, SLE_BOOL = SLE_FILE_I8 | SLE_VAR_BL, SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8, SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8, SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16, SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16, SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32, SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32, SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64, SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64, SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR, SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U16, SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB, SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ, SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR, SLE_STRINGQUOTE = SLE_FILE_STRING | SLE_VAR_STRQ, SLE_NAME = SLE_FILE_STRINGID | SLE_VAR_NAME, SLE_UINT = SLE_UINT32, SLE_INT = SLE_INT32, SLE_STRB = SLE_STRINGBUF, SLE_STRBQ = SLE_STRINGBQUOTE, SLE_STR = SLE_STRING, SLE_STRQ = SLE_STRINGQUOTE, SLF_NOT_IN_SAVE = 1 << 8, SLF_NOT_IN_CONFIG = 1 << 9, SLF_NO_NETWORK_SYNC = 1 << 10 } |
VarTypes is the general bitmasked magic type that tells us certain characteristics about the variable it refers to. More... | |
enum | SaveLoadTypes { SL_VAR = 0, SL_REF = 1, SL_ARR = 2, SL_STR = 3, SL_LST = 4, SL_WRITEBYTE = 8, SL_VEH_INCLUDE = 9, SL_ST_INCLUDE = 10, SL_END = 15 } |
Type of data saved. More... | |
Functions | |
void | GenerateDefaultSaveName (char *buf, const char *last) |
Fill the buffer with the default name for a savegame *or* screenshot. | |
void | SetSaveLoadError (uint16 str) |
const char * | GetSaveLoadErrorString () |
Get the string representation of the error message. | |
SaveOrLoadResult | SaveOrLoad (const char *filename, int mode, Subdirectory sb, bool threaded=true) |
Main Save or Load function where the high-level saveload functions are handled. | |
void | WaitTillSaved () |
void | ProcessAsyncSaveFinish () |
Handle async save finishes. | |
void | DoExitSave () |
Do a save when exiting the game (_settings_client.gui.autosave_on_exit). | |
SaveOrLoadResult | SaveWithFilter (struct SaveFilter *writer, bool threaded) |
Save the game using a (writer) filter. | |
SaveOrLoadResult | LoadWithFilter (struct LoadFilter *reader) |
Load the game using a (reader) filter. | |
static bool | IsSavegameVersionBefore (uint16 major, byte minor=0) |
Checks whether the savegame is below major. | |
static bool | SlIsObjectCurrentlyValid (uint16 version_from, uint16 version_to) |
Checks if some version from/to combination falls within the range of the active savegame version. | |
static VarType | GetVarMemType (VarType type) |
Get the NumberType of a setting. | |
static VarType | GetVarFileType (VarType type) |
Get the FileType of a setting. | |
static bool | IsNumericType (VarType conv) |
Check if the given saveload type is a numeric type. | |
static void * | GetVariableAddress (const void *object, const SaveLoad *sld) |
Get the address of the variable. | |
int64 | ReadValue (const void *ptr, VarType conv) |
Return a signed-long version of the value of a setting. | |
void | WriteValue (void *ptr, VarType conv, int64 val) |
Write the value of a setting. | |
void | SlSetArrayIndex (uint index) |
int | SlIterateArray () |
Iterate through the elements of an array and read the whole thing. | |
void | SlAutolength (AutolengthProc *proc, void *arg) |
Do something of which I have no idea what it is :P. | |
size_t | SlGetFieldLength () |
Get the length of the current object. | |
void | SlSetLength (size_t length) |
Sets the length of either a RIFF object or the number of items in an array. | |
size_t | SlCalcObjMemberLength (const void *object, const SaveLoad *sld) |
size_t | SlCalcObjLength (const void *object, const SaveLoad *sld) |
Calculate the size of an object. | |
byte | SlReadByte () |
Wrapper for reading a byte from the buffer. | |
void | SlWriteByte (byte b) |
Wrapper for writing a byte to the dumper. | |
void | SlGlobList (const SaveLoadGlobVarList *sldg) |
Save or Load (a list of) global variables. | |
void | SlArray (void *array, size_t length, VarType conv) |
Save/Load an array. | |
void | SlObject (void *object, const SaveLoad *sld) |
Main SaveLoad function. | |
bool | SlObjectMember (void *object, const SaveLoad *sld) |
void NORETURN | SlError (StringID string, const char *extra_msg=NULL) |
Error handler. | |
void NORETURN | SlErrorCorrupt (const char *msg) |
Error handler for corrupt savegames. | |
bool | SaveloadCrashWithMissingNewGRFs () |
Did loading the savegame cause a crash? If so, were NewGRFs missing? | |
Variables | |
char | _savegame_format [8] |
how to compress savegames | |
bool | _do_autosave |
are we doing an autosave at the moment? |
Functions/types related to saving and loading games.
Definition in file saveload.h.
#define SLE_ARR | ( | base, | ||
variable, | ||||
type, | ||||
length | ||||
) | SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION) |
Storage of an array in every version of a savegame.
base | Name of the class or struct containing the array. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
length | Number of elements in the array. |
Definition at line 364 of file saveload.h.
#define SLE_CONDARR | ( | base, | ||
variable, | ||||
type, | ||||
length, | ||||
from, | ||||
to | ||||
) | SLE_GENERAL(SL_ARR, base, variable, type, length, from, to) |
Storage of an array in some savegame versions.
base | Name of the class or struct containing the array. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
length | Number of elements in the array. | |
from | First savegame version that has the array. | |
to | Last savegame version that has the array. |
Definition at line 318 of file saveload.h.
#define SLE_CONDLST | ( | base, | ||
variable, | ||||
type, | ||||
from, | ||||
to | ||||
) | SLE_GENERAL(SL_LST, base, variable, type, 0, from, to) |
Storage of a list in some savegame versions.
base | Name of the class or struct containing the list. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the list. | |
to | Last savegame version that has the list. |
Definition at line 339 of file saveload.h.
Referenced by GetVehicleDescription().
#define SLE_CONDNULL | ( | length, | ||
from, | ||||
to | ||||
) | SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to) |
Empty space in some savegame versions.
length | Length of the empty space. | |
from | First savegame version that has the empty space. | |
to | Last savegame version that has the empty space. |
Definition at line 395 of file saveload.h.
Referenced by GetCargoPacketDesc(), GetGoodsDesc(), and GetVehicleDescription().
#define SLE_CONDREF | ( | base, | ||
variable, | ||||
type, | ||||
from, | ||||
to | ||||
) | SLE_GENERAL(SL_REF, base, variable, type, 0, from, to) |
Storage of a reference in some savegame versions.
base | Name of the class or struct containing the variable. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Type of the reference, a value from SLRefType. | |
from | First savegame version that has the field. | |
to | Last savegame version that has the field. |
Definition at line 307 of file saveload.h.
Referenced by GetVehicleDescription().
#define SLE_CONDSTR | ( | base, | ||
variable, | ||||
type, | ||||
length, | ||||
from, | ||||
to | ||||
) | SLE_GENERAL(SL_STR, base, variable, type, length, from, to) |
Storage of a string in some savegame versions.
base | Name of the class or struct containing the string. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
length | Number of elements in the string (only used for fixed size buffers). | |
from | First savegame version that has the string. | |
to | Last savegame version that has the string. |
Definition at line 329 of file saveload.h.
Referenced by GetVehicleDescription().
#define SLE_CONDVAR | ( | base, | ||
variable, | ||||
type, | ||||
from, | ||||
to | ||||
) | SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to) |
Storage of a variable in some savegame versions.
base | Name of the class or struct containing the variable. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the field. | |
to | Last savegame version that has the field. |
Definition at line 297 of file saveload.h.
Referenced by GetCargoPacketDesc(), GetFlowStatDesc(), GetGoodsDesc(), GetLinkGraphDesc(), GetLinkStatDesc(), and GetVehicleDescription().
#define SLE_END | ( | ) | {false, SL_END, 0, 0, 0, 0, NULL} |
End marker of a struct/class save or load.
Definition at line 404 of file saveload.h.
Referenced by GetCargoPacketDesc(), GetFlowStatDesc(), GetGoodsDesc(), GetLinkGraphDesc(), GetLinkStatDesc(), and GetVehicleDescription().
#define SLE_GENERAL | ( | cmd, | ||
base, | ||||
variable, | ||||
type, | ||||
length, | ||||
from, | ||||
to | ||||
) | {false, cmd, type, length, from, to, (void*)cpp_offsetof(base, variable)} |
Storage of simple variables, references (pointers), and arrays.
cmd | Load/save type. |
base | Name of the class or struct containing the variable. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the field. | |
to | Last savegame version that has the field. |
Definition at line 287 of file saveload.h.
#define SLE_LST | ( | base, | ||
variable, | ||||
type | ||||
) | SLE_CONDLST(base, variable, type, 0, SL_MAX_VERSION) |
Storage of a list in every savegame version.
base | Name of the class or struct containing the list. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 381 of file saveload.h.
#define SLE_NULL | ( | length | ) | SLE_CONDNULL(length, 0, SL_MAX_VERSION) |
Empty space in every savegame version.
length | Length of the empty space. |
Definition at line 387 of file saveload.h.
#define SLE_REF | ( | base, | ||
variable, | ||||
type | ||||
) | SLE_CONDREF(base, variable, type, 0, SL_MAX_VERSION) |
Storage of a reference in every version of a savegame.
base | Name of the class or struct containing the variable. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Type of the reference, a value from SLRefType. |
Definition at line 355 of file saveload.h.
Referenced by GetVehicleDescription().
#define SLE_STR | ( | base, | ||
variable, | ||||
type, | ||||
length | ||||
) | SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION) |
Storage of a string in every savegame version.
base | Name of the class or struct containing the string. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. | |
length | Number of elements in the string (only used for fixed size buffers). |
Definition at line 373 of file saveload.h.
Referenced by GetVehicleDescription().
#define SLE_VAR | ( | base, | ||
variable, | ||||
type | ||||
) | SLE_CONDVAR(base, variable, type, 0, SL_MAX_VERSION) |
Storage of a variable in every version of a savegame.
base | Name of the class or struct containing the variable. | |
variable | Name of the variable in the class or struct referenced by base. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 347 of file saveload.h.
Referenced by GetCargoPacketDesc(), GetGoodsDesc(), and GetVehicleDescription().
#define SLE_WRITEBYTE | ( | base, | ||
variable, | ||||
value | ||||
) | SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, value, value) |
Translate values ingame to different values in the savegame and vv.
Definition at line 398 of file saveload.h.
Referenced by GetVehicleDescription().
#define SLEG_ARR | ( | variable, | ||
type | ||||
) | SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION) |
Storage of a global array in every savegame version.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 483 of file saveload.h.
#define SLEG_CONDARR | ( | variable, | ||
type, | ||||
length, | ||||
from, | ||||
to | ||||
) | SLEG_GENERAL(SL_ARR, variable, type, length, from, to) |
Storage of a global array in some savegame versions.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. | |
length | Number of elements in the array. | |
from | First savegame version that has the array. | |
to | Last savegame version that has the array. |
Definition at line 443 of file saveload.h.
#define SLEG_CONDLST | ( | variable, | ||
type, | ||||
from, | ||||
to | ||||
) | SLEG_GENERAL(SL_LST, variable, type, 0, from, to) |
Storage of a global list in some savegame versions.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the list. | |
to | Last savegame version that has the list. |
Definition at line 462 of file saveload.h.
Referenced by GetGoodsDesc().
#define SLEG_CONDNULL | ( | length, | ||
from, | ||||
to | ||||
) | {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)NULL} |
Empty global space in some savegame versions.
length | Length of the empty space. | |
from | First savegame version that has the empty space. | |
to | Last savegame version that has the empty space. |
Definition at line 505 of file saveload.h.
#define SLEG_CONDREF | ( | variable, | ||
type, | ||||
from, | ||||
to | ||||
) | SLEG_GENERAL(SL_REF, variable, type, 0, from, to) |
Storage of a global reference in some savegame versions.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the field. | |
to | Last savegame version that has the field. |
Definition at line 433 of file saveload.h.
#define SLEG_CONDSTR | ( | variable, | ||
type, | ||||
length, | ||||
from, | ||||
to | ||||
) | SLEG_GENERAL(SL_STR, variable, type, length, from, to) |
Storage of a global string in some savegame versions.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. | |
length | Number of elements in the string (only used for fixed size buffers). | |
from | First savegame version that has the string. | |
to | Last savegame version that has the string. |
Definition at line 453 of file saveload.h.
#define SLEG_CONDVAR | ( | variable, | ||
type, | ||||
from, | ||||
to | ||||
) | SLEG_GENERAL(SL_VAR, variable, type, 0, from, to) |
Storage of a global variable in some savegame versions.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the field. | |
to | Last savegame version that has the field. |
Definition at line 424 of file saveload.h.
Referenced by GetFlowStatDesc(), GetGoodsDesc(), GetLinkStatDesc(), and GetVehicleDescription().
#define SLEG_END | ( | ) | {true, SL_END, 0, 0, 0, 0, NULL} |
End marker of global variables save or load.
Definition at line 508 of file saveload.h.
#define SLEG_GENERAL | ( | cmd, | ||
variable, | ||||
type, | ||||
length, | ||||
from, | ||||
to | ||||
) | {true, cmd, type, length, from, to, (void*)&variable} |
Storage of global simple variables, references (pointers), and arrays.
cmd | Load/save type. |
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. | |
from | First savegame version that has the field. | |
to | Last savegame version that has the field. |
Definition at line 415 of file saveload.h.
#define SLEG_LST | ( | variable, | ||
type | ||||
) | SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION) |
Storage of a global list in every savegame version.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 497 of file saveload.h.
#define SLEG_REF | ( | variable, | ||
type | ||||
) | SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION) |
Storage of a global reference in every savegame version.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 476 of file saveload.h.
#define SLEG_STR | ( | variable, | ||
type | ||||
) | SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION) |
Storage of a global string in every savegame version.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 490 of file saveload.h.
#define SLEG_VAR | ( | variable, | ||
type | ||||
) | SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION) |
Storage of a global variable in every savegame version.
variable | Name of the global variable. | |
type | Storage of the data in memory and in the savegame. |
Definition at line 469 of file saveload.h.
typedef byte SaveLoadType |
enum ChunkType |
Flags of a chunk.
Definition at line 153 of file saveload.h.
enum SavegameType |
Types of save games.
Definition at line 43 of file saveload.h.
enum SaveLoadTypes |
Type of data saved.
SL_VAR |
Save/load a variable. |
SL_REF |
Save/load a reference. |
SL_ARR |
Save/load an array. |
SL_STR |
Save/load a string. |
SL_LST |
Save/load a list. |
Definition at line 244 of file saveload.h.
enum SaveLoadVersions |
save/load versions used for the various branches / patches
Definition at line 96 of file saveload.h.
enum SaveOrLoadMode |
Save or load mode.
SL_INVALID |
Invalid mode. |
SL_LOAD |
Load game. |
SL_SAVE |
Save game. |
SL_OLD_LOAD |
Load old game. |
SL_PNG |
Load PNG file (height map). |
SL_BMP |
Load BMP file (height map). |
SL_LOAD_CHECK |
Load for game preview. |
Definition at line 32 of file saveload.h.
enum SaveOrLoadResult |
Save or load result codes.
Definition at line 25 of file saveload.h.
enum SLRefType |
Type of reference (SLE_REF, SLE_CONDREF).
Definition at line 81 of file saveload.h.
enum VarTypes |
VarTypes is the general bitmasked magic type that tells us certain characteristics about the variable it refers to.
For example SLE_FILE_* gives the size(type) as it would be in the savegame and SLE_VAR_* the size(type) as it is in memory during runtime. These are the first 8 bits (0-3 SLE_FILE, 4-7 SLE_VAR). Bits 8-15 are reserved for various flags as explained below
Definition at line 170 of file saveload.h.
void GenerateDefaultSaveName | ( | char * | buf, | |
const char * | last | |||
) |
Fill the buffer with the default name for a savegame *or* screenshot.
buf | the buffer to write to. | |
last | the last element in the buffer. |
Definition at line 2735 of file saveload.cpp.
References _date, _local_company, _settings_client, GUISettings::date_format_in_default_names, ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), SanitizeFilename(), and SetDParam().
Referenced by DoAutosave(), SaveLoadWindow::GenerateFileName(), and MakeScreenshotName().
static VarType GetVarFileType | ( | VarType | type | ) | [inline, static] |
Get the FileType of a setting.
This describes the integer type as it is represented in a savegame/file
type | VarType holding information about the file-type | |
return | the SLE_FILE_* part of a variable-type description |
Definition at line 555 of file saveload.h.
Referenced by SlSaveLoadConv().
static void* GetVariableAddress | ( | const void * | object, | |
const SaveLoad * | sld | |||
) | [inline, static] |
Get the address of the variable.
Which one to pick depends on the object pointer. If it is NULL we are dealing with global variables so the address is taken. If non-null only the offset is stored in the union and we need to add this to the address of the object
Definition at line 576 of file saveload.h.
References SaveLoad::address, and SaveLoad::global.
Referenced by CmdChangeCompanySetting(), CmdChangeSetting(), AIGameSettings::GetValue(), HandleOldDiffCustom(), IConsoleGetSetting(), IConsoleListSettings(), IniLoadSettings(), IniSaveSettings(), LoadSettings(), GameDifficultyWindow::OnClick(), GameDifficultyWindow::OnInvalidateData(), SaveSettings(), SetCompanySetting(), SetDefaultCompanySettings(), SetSettingValue(), GameDifficultyWindow::SetStringParameters(), SlObject(), and SyncCompanySettings().
static VarType GetVarMemType | ( | VarType | type | ) | [inline, static] |
Get the NumberType of a setting.
This describes the integer type as it is represented in memory
type | VarType holding information about the variable-type |
Definition at line 544 of file saveload.h.
Referenced by IConsoleGetSetting(), IConsoleListSettings(), IniLoadSettings(), IniSaveSettings(), IsNumericType(), ReadValue(), SetSettingValue(), SlCalcStringLen(), SlString(), Write_ValidateSetting(), and WriteValue().
static bool IsNumericType | ( | VarType | conv | ) | [inline, static] |
Check if the given saveload type is a numeric type.
conv | the type to check |
Definition at line 565 of file saveload.h.
References GetVarMemType().
Referenced by LoadSettings().
static bool IsSavegameVersionBefore | ( | uint16 | major, | |
byte | minor = 0 | |||
) | [inline, static] |
Checks whether the savegame is below major.
minor.
major | Major number of the version to check against. | |
minor | Minor number of the version to check against. If minor is 0 or not specified, only the major number is checked. |
Definition at line 516 of file saveload.h.
References _sl_minor_version, and _sl_version.
Referenced by CargoPacket::AfterLoad(), AfterLoadGame(), AfterLoadVehicles(), Order::ConvertFromOldSavegame(), CopyFromOldName(), DoLoad(), HandleOldDiffCustom(), IntToReference(), Load_ANIT(), Load_CAPR(), Load_ECMY(), Load_PRIC(), Load_SIGN(), Load_VEHS(), MoveWaypointsToBaseStations(), SlCalcListLen(), SlCalcRefLen(), and SlList().
SaveOrLoadResult LoadWithFilter | ( | LoadFilter * | reader | ) |
Load the game using a (reader) filter.
reader | The filter to read the savegame from. |
Definition at line 2631 of file saveload.cpp.
References SaveLoadParams::action, ClearSaveLoadState(), and DoLoad().
Referenced by SafeLoad().
int64 ReadValue | ( | const void * | ptr, | |
VarType | conv | |||
) |
Return a signed-long version of the value of a setting.
ptr | pointer to the variable | |
conv | type of variable, can be a non-clean type, eg one with other flags because it is parsed |
Definition at line 885 of file saveload.cpp.
References GetVarMemType(), and SLE_VAR_NULL.
Referenced by CmdChangeCompanySetting(), CmdChangeSetting(), SettingEntry::DrawSetting(), CheatWindow::DrawWidget(), AIGameSettings::GetValue(), IConsoleGetSetting(), IConsoleListSettings(), IniSaveSettings(), LoadSettings(), GameSettingsWindow::OnClick(), GameDifficultyWindow::OnClick(), CheatWindow::OnClick(), GameDifficultyWindow::OnInvalidateData(), CheatWindow::OnQueryTextFinished(), SetCompanySetting(), SetSettingValue(), GameDifficultyWindow::SetStringParameters(), SlSaveLoadConv(), and SyncCompanySettings().
bool SaveloadCrashWithMissingNewGRFs | ( | ) |
Did loading the savegame cause a crash? If so, were NewGRFs missing?
Definition at line 330 of file afterload.cpp.
Referenced by HandleCrash().
SaveOrLoadResult SaveOrLoad | ( | const char * | filename, | |
int | mode, | |||
Subdirectory | sb, | |||
bool | threaded | |||
) |
Main Save or Load function where the high-level saveload functions are handled.
It opens the savegame, selects format and checks versions
filename | The name of the savegame being created/loaded | |
mode | Save or load mode. Load can also be a TTD(Patch) game. Use SL_LOAD, SL_OLD_LOAD, SL_LOAD_CHECK, or SL_SAVE. | |
sb | The sub directory to save the savegame in | |
threaded | True when threaded saving is allowed |
Definition at line 2651 of file saveload.cpp.
References _date, _date_fract, _do_autosave, _grfconfig, _network_server, _settings_client, _sl_minor_version, _sl_version, SaveLoadParams::action, AfterLoadGame(), BASE_DIR, ClearGRFConfigList(), ClearSaveLoadState(), DEBUG, DoLoad(), DoSave(), FioFOpenFile(), GamelogReset(), GamelogStartAction(), GamelogStopAction(), GetSaveLoadErrorString(), GLAT_LOAD, ClientSettings::gui, INVALID_STRING_ID, EngineOverrideManager::ResetToDefaultMapping(), SAVE_DIR, SaveLoadParams::saveinprogress, ShowErrorMessage(), SL_LOAD, SL_LOAD_CHECK, SL_OLD_LOAD, SL_REINIT, SL_SAVE, SlError(), GUISettings::threaded_saves, and WL_ERROR.
Referenced by _GenerateWorld(), DEF_CONSOLE_CMD(), DoAutosave(), DoExitSave(), SafeLoad(), StateGameLoop(), and CrashLog::WriteSavegame().
SaveOrLoadResult SaveWithFilter | ( | SaveFilter * | writer, | |
bool | threaded | |||
) |
Save the game using a (writer) filter.
writer | The filter to write the savegame to. | |
threaded | Whether to try to perform the saving asynchroniously. |
Definition at line 2473 of file saveload.cpp.
References SaveLoadParams::action, ClearSaveLoadState(), and DoSave().
Referenced by ServerNetworkGameSocketHandler::SendMap().
void SlArray | ( | void * | array, | |
size_t | length, | |||
VarType | conv | |||
) |
Save/Load an array.
array | The array being manipulated | |
length | The length of the array in elements | |
conv | VarType type of the atomic array (int, byte, uint64, etc.) |
Definition at line 1114 of file saveload.cpp.
References _sl_version, SaveLoadParams::action, BSWAP32(), SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SLA_NULL, SLA_PTRS, SLA_SAVE, SlCalcArrayLen(), SlCalcConvFileLen(), SlCalcConvMemLen(), SlCopyBytes(), SlSaveLoadConv(), and SlSetLength().
Referenced by Load_ANIT(), Load_CAPR(), Load_MAPH(), Load_NAME(), Load_PRIC(), AIInstance::LoadObjects(), Save_ANIT(), and AIInstance::SaveObject().
void SlAutolength | ( | AutolengthProc * | proc, | |
void * | arg | |||
) |
Do something of which I have no idea what it is :P.
proc | The callback procedure that is called | |
arg | The variable that will be used for the callback procedure |
Definition at line 1506 of file saveload.cpp.
References SaveLoadParams::action, SaveLoadParams::dumper, MemoryDumper::GetSize(), SaveLoadParams::need_length, SaveLoadParams::obj_len, SLA_SAVE, SlErrorCorrupt(), and SlSetLength().
Referenced by SlStubSaveProc().
size_t SlCalcObjLength | ( | const void * | object, | |
const SaveLoad * | sld | |||
) |
Calculate the size of an object.
object | to be measured | |
sld | The SaveLoad description of the object so we know how to manipulate it |
Definition at line 1361 of file saveload.cpp.
References SaveLoad::cmd.
Referenced by SlObject().
void NORETURN SlError | ( | StringID | string, | |
const char * | extra_msg | |||
) |
Error handler.
Sets everything up to show an error message and to clean up the mess of a partial savegame load.
string | The translatable error message to show. | |
extra_msg | An extra error message coming from one of the APIs. |
Definition at line 486 of file saveload.cpp.
References _load_check_data, SaveLoadParams::action, LoadCheckData::error, LoadCheckData::error_data, SaveLoadParams::error_str, SaveLoadParams::extra_msg, SLA_LOAD, SLA_LOAD_CHECK, SLA_PTRS, and SlNullPointers().
Referenced by AfterLoadGame(), DoLoad(), PacketWriter::Finish(), LZMALoadFilter::LZMALoadFilter(), LZMASaveFilter::LZMASaveFilter(), LZOLoadFilter::LZOLoadFilter(), LZOSaveFilter::LZOSaveFilter(), MoveWaypointsToBaseStations(), LZMALoadFilter::Read(), ZlibLoadFilter::Read(), LZOLoadFilter::Read(), SaveOrLoad(), SlErrorCorrupt(), FileWriter::Write(), PacketWriter::Write(), LZMASaveFilter::WriteLoop(), ZlibSaveFilter::WriteLoop(), ZlibLoadFilter::ZlibLoadFilter(), and ZlibSaveFilter::ZlibSaveFilter().
void NORETURN SlErrorCorrupt | ( | const char * | msg | ) |
Error handler for corrupt savegames.
Sets everything up to show the error message and to clean up the mess of a partial savegame load.
msg | Location the corruption has been spotted. |
Definition at line 514 of file saveload.cpp.
References SlError().
Referenced by AfterLoadGame(), AfterLoadVehicles(), ConvertOldMultiheadToNew(), IntToReference(), Load_VEHS(), LoadOldVehicle(), LZOLoadFilter::Read(), SetWaterClassDependingOnSurroundings(), SlAutolength(), SlIterateArray(), SlLoadCheckChunk(), SlLoadCheckChunks(), SlLoadChunk(), SlLoadChunks(), and SlReadSimpleGamma().
void SlGlobList | ( | const SaveLoadGlobVarList * | sldg | ) |
Save or Load (a list of) global variables.
sldg | The global variable that is being loaded or saved |
Definition at line 1496 of file saveload.cpp.
References SlObject().
Referenced by LoadSave_IBLD().
static bool SlIsObjectCurrentlyValid | ( | uint16 | version_from, | |
uint16 | version_to | |||
) | [inline, static] |
Checks if some version from/to combination falls within the range of the active savegame version.
version_from | Lowest version number that falls within the range. | |
version_to | Highest version number that falls within the range. |
Definition at line 530 of file saveload.h.
References SAVEGAME_VERSION.
Referenced by CmdChangeSetting(), GetSettingFromName(), HandleOldDiffCustom(), IConsoleListSettings(), IniLoadSettings(), IniSaveSettings(), and GameDifficultyWindow::OnInvalidateData().
int SlIterateArray | ( | ) |
Iterate through the elements of an array and read the whole thing.
Definition at line 767 of file saveload.cpp.
References SaveLoadParams::block_mode, DEBUG, ReadBuffer::GetSize(), SaveLoadParams::obj_len, SaveLoadParams::reader, and SlErrorCorrupt().
Referenced by Load_CAPA(), Load_ITBL(), Load_NAME(), Load_NewGRFMapping(), Load_SIGN(), Load_VEHS(), and SlSkipArray().
void SlObject | ( | void * | object, | |
const SaveLoad * | sld | |||
) |
Main SaveLoad function.
object | The object that is being saved or loaded | |
sld | The SaveLoad description of the object so we know how to manipulate it |
Definition at line 1478 of file saveload.cpp.
References SaveLoad::address, SaveLoad::cmd, GetVariableAddress(), SaveLoad::global, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SlCalcObjLength(), and SlSetLength().
Referenced by DoSave_LGRP(), AIInstance::Load(), Load_CAPA(), Load_ECMY(), Load_ITBL(), Load_LGRP(), Load_NewGRFMapping(), Load_SIGN(), Load_VEHS(), AIInstance::LoadEmpty(), AIInstance::LoadObjects(), AIInstance::Save(), Save_CAPA(), Save_ECMY(), Save_ITBL(), Save_NewGRFMapping(), Save_SIGN(), Save_VEHS(), AIInstance::SaveEmpty(), SaveLoad_LinkGraphComponent(), AIInstance::SaveObject(), and SlGlobList().
byte SlReadByte | ( | ) |
Wrapper for reading a byte from the buffer.
Definition at line 558 of file saveload.cpp.
References SaveLoadParams::reader.
Referenced by Load_CHTS(), Load_VEHS(), SlCopyBytes(), SlLoadCheckChunk(), SlLoadChunk(), SlReadSimpleGamma(), SlSaveLoadConv(), and SlSkipBytes().
void SlSetLength | ( | size_t | length | ) |
Sets the length of either a RIFF object or the number of items in an array.
This lets us load an object or an array of arbitrary size
length | The length of the sought object/array |
Definition at line 812 of file saveload.cpp.
References SaveLoadParams::action, SaveLoadParams::block_mode, SaveLoadParams::last_array_index, SaveLoadParams::need_length, NL_CALCLENGTH, NL_WANTLENGTH, SaveLoadParams::obj_len, and SLA_SAVE.
Referenced by Save_ANIT(), Save_CHTS(), SaveSettings(), SlArray(), SlAutolength(), SlList(), and SlObject().
void SlWriteByte | ( | byte | b | ) |
Wrapper for writing a byte to the dumper.
b | The byte to write. |
Definition at line 567 of file saveload.cpp.
References SaveLoadParams::dumper, and MemoryDumper::WriteByte().
Referenced by Save_CHTS(), SlCopyBytes(), SlSaveChunk(), SlSaveLoadConv(), and SlWriteSimpleGamma().
void WriteValue | ( | void * | ptr, | |
VarType | conv, | |||
int64 | val | |||
) |
Write the value of a setting.
ptr | pointer to the variable | |
conv | type of variable, can be a non-clean type, eg with other flags. It is parsed upon read | |
val | the new value being given to the variable |
Definition at line 909 of file saveload.cpp.
References CopyFromOldName(), GetVarMemType(), SLE_VAR_NAME, and SLE_VAR_NULL.
Referenced by CmdChangeCompanySetting(), CmdChangeSetting(), GameDifficultyWindow::OnClick(), CheatWindow::OnClick(), CheatWindow::OnQueryTextFinished(), SlSaveLoadConv(), and Write_ValidateSetting().