diff --git a/src/sl/saveload.cpp b/src/sl/saveload.cpp index 7f85345a47..5f26856071 100644 --- a/src/sl/saveload.cpp +++ b/src/sl/saveload.cpp @@ -2277,7 +2277,7 @@ std::vector SlTableHeader(const NamedSaveLoadTable &slt, TableHeaderSp } /* We don't know this field, so read to nothing. */ - saveloads.push_back({ true, saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0, SlXvFeatureTest() }); + saveloads.push_back({ true, saveload_type, ((VarType)type & SLE_FILE_TYPE_MASK) | SLE_VAR_NULL, 1, SL_MIN_VERSION, SL_MAX_VERSION, SLTAG_TABLE_UNKNOWN, nullptr, 0, SlXvFeatureTest() }); continue; } diff --git a/src/sl/saveload.h b/src/sl/saveload.h index cb344d7df8..ce842a2043 100644 --- a/src/sl/saveload.h +++ b/src/sl/saveload.h @@ -501,7 +501,7 @@ inline constexpr void *SlVarWrapper(void* ptr) * @param extver SlXvFeatureTest to test (along with from and to) which savegames have the field * @note In general, it is better to use one of the SLE_* macros below. */ -#define SLE_GENERAL_X(cmd, base, variable, type, length, from, to, extver) SaveLoad {false, cmd, type, length, from, to, SlVarWrapper((void*)cpp_offsetof(base, variable)), sizeof(base::variable), extver} +#define SLE_GENERAL_X(cmd, base, variable, type, length, from, to, extver) SaveLoad {false, cmd, type, length, from, to, SLTAG_DEFAULT, SlVarWrapper((void*)cpp_offsetof(base, variable)), sizeof(base::variable), extver} #define SLE_GENERAL(cmd, base, variable, type, length, from, to) SLE_GENERAL_X(cmd, base, variable, type, length, from, to, SlXvFeatureTest()) /** @@ -719,8 +719,8 @@ inline constexpr void *SlVarWrapper(void* ptr) /** Translate values ingame to different values in the savegame and vv. */ #define SLE_WRITEBYTE(base, variable) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION) -#define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0, SlXvFeatureTest()} -#define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0, SlXvFeatureTest()} +#define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, SLTAG_DEFAULT, nullptr, 0, SlXvFeatureTest()} +#define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, SLTAG_DEFAULT, nullptr, 0, SlXvFeatureTest()} /** * Storage of global simple variables, references (pointers), and arrays. @@ -732,7 +732,7 @@ inline constexpr void *SlVarWrapper(void* ptr) * @param extver SlXvFeatureTest to test (along with from and to) which savegames have the field * @note In general, it is better to use one of the SLEG_* macros below. */ -#define SLEG_GENERAL_X(cmd, variable, type, length, from, to, extver) SaveLoad {true, cmd, type, length, from, to, SlVarWrapper((void*)&variable), sizeof(variable), extver} +#define SLEG_GENERAL_X(cmd, variable, type, length, from, to, extver) SaveLoad {true, cmd, type, length, from, to, SLTAG_DEFAULT, SlVarWrapper((void*)&variable), sizeof(variable), extver} #define SLEG_GENERAL(cmd, variable, type, length, from, to) SLEG_GENERAL_X(cmd, variable, type, length, from, to, SlXvFeatureTest()) /** @@ -896,9 +896,8 @@ inline constexpr void *SlVarWrapper(void* ptr) * @param length Length of the empty space. * @param from First savegame version that has the empty space. * @param to Last savegame version that has the empty space. - * @param extver SlXvFeatureTest to test (along with from and to) which savegames have empty space */ -#define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL, length, from, to, (void*)nullptr, SlXvFeatureTest()} +#define SLEG_CONDNULL(length, from, to) SaveLoad {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL, length, from, to, SLTAG_DEFAULT, nullptr, SlXvFeatureTest()} /** * Checks whether the savegame is below \a major.\a minor. diff --git a/src/sl/saveload_types.h b/src/sl/saveload_types.h index afeb1501f3..0928cfc781 100644 --- a/src/sl/saveload_types.h +++ b/src/sl/saveload_types.h @@ -131,6 +131,7 @@ struct SaveLoad { uint16_t length; ///< (conditional) length of the variable (eg. arrays) (max array size is 65536 elements) SaveLoadVersion version_from; ///< save/load the variable starting from this savegame version SaveLoadVersion version_to; ///< save/load the variable until this savegame version + uint16_t label_tag; ///< for labelling purposes /* NOTE: This element either denotes the address of the variable for a global * variable, or the offset within a struct which is then bound to a variable * during runtime. Decision on which one to use is controlled by the function @@ -140,6 +141,18 @@ struct SaveLoad { SlXvFeatureTest ext_feature_test; ///< extended feature test }; +inline constexpr SaveLoad SLTAG(uint16_t label_tag, SaveLoad save_load) +{ + save_load.label_tag = label_tag; + return save_load; +} + +enum SaveLoadTags { + SLTAG_DEFAULT, + SLTAG_TABLE_UNKNOWN, + SLTAG_CUSTOM_START, +}; + enum NamedSaveLoadFlags : uint8_t { NSLF_NONE = 0, NSLF_TABLE_ONLY = 1 << 0,