15 #include "../fileio_type.h"
16 #include "../strings_type.h"
57 typedef void ChunkSaveLoadProc();
58 typedef void AutolengthProc(
void *arg);
91 #define SL_MAX_VERSION UINT16_MAX
129 SLE_VAR_I16 = 3 << 4,
130 SLE_VAR_U16 = 4 << 4,
131 SLE_VAR_I32 = 5 << 4,
132 SLE_VAR_U32 = 6 << 4,
133 SLE_VAR_I64 = 7 << 4,
134 SLE_VAR_U64 = 8 << 4,
144 SLE_VAR_CHAR = SLE_VAR_I8,
149 SLE_BOOL = SLE_FILE_I8 | SLE_VAR_BL,
150 SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
151 SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
152 SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
153 SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16,
154 SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
155 SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32,
156 SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
157 SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
158 SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
167 SLE_UINT = SLE_UINT32,
169 SLE_STRB = SLE_STRINGBUF,
170 SLE_STRBQ = SLE_STRINGBQUOTE,
172 SLE_STRQ = SLE_STRINGQUOTE,
184 typedef uint32 VarType;
231 #define SLE_GENERAL(cmd, base, variable, type, length, from, to) {false, cmd, type, length, from, to, (void*)cpp_offsetof(base, variable), cpp_sizeof(base, variable)}
241 #define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to)
251 #define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to)
262 #define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to)
273 #define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to)
283 #define SLE_CONDLST(base, variable, type, from, to) SLE_GENERAL(SL_LST, base, variable, type, 0, from, to)
291 #define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, 0, SL_MAX_VERSION)
299 #define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, 0, SL_MAX_VERSION)
308 #define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION)
317 #define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION)
325 #define SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, 0, SL_MAX_VERSION)
331 #define SLE_NULL(length) SLE_CONDNULL(length, 0, SL_MAX_VERSION)
339 #define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to)
342 #define SLE_WRITEBYTE(base, variable, value) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, value, value)
344 #define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, 0, SL_MAX_VERSION, NULL, 0}
345 #define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, 0, SL_MAX_VERSION, NULL, 0}
348 #define SLE_END() {false, SL_END, 0, 0, 0, 0, NULL, 0}
359 #define SLEG_GENERAL(cmd, variable, type, length, from, to) {true, cmd, type, length, from, to, (void*)&variable, sizeof(variable)}
368 #define SLEG_CONDVAR(variable, type, from, to) SLEG_GENERAL(SL_VAR, variable, type, 0, from, to)
377 #define SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to)
387 #define SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to)
397 #define SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to)
406 #define SLEG_CONDLST(variable, type, from, to) SLEG_GENERAL(SL_LST, variable, type, 0, from, to)
413 #define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION)
420 #define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION)
427 #define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
434 #define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
441 #define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION)
449 #define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)NULL}
452 #define SLEG_END() {true, SL_END, 0, 0, 0, 0, NULL, 0}
464 return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);
477 if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION > version_to)
return false;
522 return const_cast<byte *
>((
const byte*)(sld->
global ? NULL :
object) + (ptrdiff_t)sld->
address);
525 int64
ReadValue(
const void *ptr, VarType conv);
526 void WriteValue(
void *ptr, VarType conv, int64 val);
528 void SlSetArrayIndex(uint index);
534 size_t SlCalcObjMemberLength(
const void *
object,
const SaveLoad *sld);
541 void SlArray(
void *array,
size_t length, VarType conv);
543 bool SlObjectMember(
void *
object,
const SaveLoad *sld);