SaveLoad: Add support for saving/loading from a std::deque<T *>

This commit is contained in:
Jonathan G Rennison
2016-09-12 22:49:52 +01:00
parent 27ee2da1f7
commit c752da3a9e
2 changed files with 52 additions and 7 deletions

View File

@@ -205,6 +205,7 @@ enum SaveLoadTypes {
SL_ARR = 2, ///< Save/load an array.
SL_STR = 3, ///< Save/load a string.
SL_LST = 4, ///< Save/load a list.
SL_DEQ = 5, ///< Save/load a deque.
/* non-normal save-load types */
SL_WRITEBYTE = 8,
SL_VEH_INCLUDE = 9,
@@ -310,6 +311,18 @@ typedef SaveLoad SaveLoadGlobVarList;
#define SLE_CONDLST_X(base, variable, type, from, to, extver) SLE_GENERAL_X(SL_LST, base, variable, type, 0, from, to, extver)
#define SLE_CONDLST(base, variable, type, from, to) SLE_CONDLST_X(base, variable, type, from, to, SlXvFeatureTest())
/**
* Storage of a deque in some savegame versions.
* @param base Name of the class or struct containing the list.
* @param variable Name of the variable in the class or struct referenced by \a base.
* @param type Storage of the data in memory and in the savegame.
* @param from First savegame version that has the list.
* @param to Last savegame version that has the list.
* @param extver SlXvFeatureTest to test (along with from and to) which savegames have the field
*/
#define SLE_CONDDEQ_X(base, variable, type, from, to, extver) SLE_GENERAL_X(SL_DEQ, base, variable, type, 0, from, to, extver)
#define SLE_CONDDEQ(base, variable, type, from, to) SLE_CONDDEQ_X(base, variable, type, from, to, SlXvFeatureTest())
/**
* Storage of a variable in every version of a savegame.
* @param base Name of the class or struct containing the variable.
@@ -352,6 +365,14 @@ typedef SaveLoad SaveLoadGlobVarList;
*/
#define SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, 0, SL_MAX_VERSION)
/**
* Storage of a deque in every savegame version.
* @param base Name of the class or struct containing the list.
* @param variable Name of the variable in the class or struct referenced by \a base.
* @param type Storage of the data in memory and in the savegame.
*/
#define SLE_DEQ(base, variable, type) SLE_CONDDEQ(base, variable, type, 0, SL_MAX_VERSION)
/**
* Empty space in every savegame version.
* @param length Length of the empty space.
@@ -447,6 +468,17 @@ typedef SaveLoad SaveLoadGlobVarList;
#define SLEG_CONDLST_X(variable, type, from, to, extver) SLEG_GENERAL_X(SL_LST, variable, type, 0, from, to, extver)
#define SLEG_CONDLST(variable, type, from, to) SLEG_CONDLST_X(variable, type, from, to, SlXvFeatureTest())
/**
* Storage of a global deque in some savegame versions.
* @param variable Name of the global variable.
* @param type Storage of the data in memory and in the savegame.
* @param from First savegame version that has the list.
* @param to Last savegame version that has the list.
* @param extver SlXvFeatureTest to test (along with from and to) which savegames have the field
*/
#define SLEG_CONDDEQ_X(variable, type, from, to, extver) SLEG_GENERAL_X(SL_DEQ, variable, type, 0, from, to, extver)
#define SLEG_CONDDEQ(variable, type, from, to) SLEG_CONDDEQ_X(variable, type, from, to, SlXvFeatureTest())
/**
* Storage of a global variable in every savegame version.
* @param variable Name of the global variable.
@@ -482,6 +514,13 @@ typedef SaveLoad SaveLoadGlobVarList;
*/
#define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION)
/**
* Storage of a global deque in every savegame version.
* @param variable Name of the global variable.
* @param type Storage of the data in memory and in the savegame.
*/
#define SLEG_DEQ(variable, type) SLEG_CONDDEQ(variable, type, 0, SL_MAX_VERSION)
/**
* Empty global space in some savegame versions.
* @param length Length of the empty space.