|
@@ -91,13 +91,14 @@ enum ChunkType {
|
|
|
CH_SPARSE_ARRAY = 2,
|
|
|
CH_TYPE_MASK = 3,
|
|
|
CH_LAST = 8,
|
|
|
CH_AUTO_LENGTH = 16,
|
|
|
};
|
|
|
|
|
|
/** VarTypes is the general bitmasked magic type that tells us
|
|
|
/**
|
|
|
* 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 */
|
|
|
enum VarTypes {
|
|
@@ -248,30 +249,33 @@ typedef SaveLoad SaveLoadGlobVarList;
|
|
|
#define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION)
|
|
|
|
|
|
#define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to, (void*)NULL}
|
|
|
|
|
|
#define SLEG_END() {true, SL_END, 0, 0, 0, 0, NULL}
|
|
|
|
|
|
/** Checks if the savegame is below major.minor.
|
|
|
/**
|
|
|
* Checks if the savegame is below major.minor.
|
|
|
*/
|
|
|
static inline bool CheckSavegameVersionOldStyle(uint16 major, byte minor)
|
|
|
{
|
|
|
extern uint16 _sl_version;
|
|
|
extern byte _sl_minor_version;
|
|
|
return (_sl_version < major) || (_sl_version == major && _sl_minor_version < minor);
|
|
|
}
|
|
|
|
|
|
/** Checks if the savegame is below version.
|
|
|
/**
|
|
|
* Checks if the savegame is below version.
|
|
|
*/
|
|
|
static inline bool CheckSavegameVersion(uint16 version)
|
|
|
{
|
|
|
extern uint16 _sl_version;
|
|
|
return _sl_version < version;
|
|
|
}
|
|
|
|
|
|
/** Checks if some version from/to combination falls within the range of the
|
|
|
/**
|
|
|
* Checks if some version from/to combination falls within the range of the
|
|
|
* active savegame version */
|
|
|
static inline bool SlIsObjectCurrentlyValid(uint16 version_from, uint16 version_to)
|
|
|
{
|
|
|
extern const uint16 SAVEGAME_VERSION;
|
|
|
if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION > version_to) return false;
|
|
|
|
|
@@ -307,13 +311,14 @@ static inline VarType GetVarFileType(Var
|
|
|
*/
|
|
|
static inline bool IsNumericType(VarType conv)
|
|
|
{
|
|
|
return GetVarMemType(conv) <= SLE_VAR_U64;
|
|
|
}
|
|
|
|
|
|
/** Get the address of the variable. Which one to pick depends on the object
|
|
|
/**
|
|
|
* 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 */
|
|
|
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
|
|
|
{
|
|
|
return (byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address;
|