File diff r25600:a0060616e61f → r25601:747c128b2f85
src/saveload/saveload.h
Show inline comments
 
@@ -476,29 +476,26 @@ enum VarTypes {
 
	SLE_STRINGQUOTE  = SLE_FILE_STRING   | SLE_VAR_STRQ,
 
	SLE_NAME         = SLE_FILE_STRINGID | SLE_VAR_NAME,
 

	
 
	/* Shortcut values */
 
	SLE_UINT  = SLE_UINT32,
 
	SLE_INT   = SLE_INT32,
 
	SLE_STRB  = SLE_STRINGBUF,
 
	SLE_STR   = SLE_STRING,
 
	SLE_STRQ  = SLE_STRINGQUOTE,
 

	
 
	/* 8 bits allocated for a maximum of 8 flags
 
	 * Flags directing saving/loading of a variable */
 
	SLF_NOT_IN_SAVE     = 1 <<  8, ///< do not save with savegame, basically client-based
 
	SLF_NOT_IN_CONFIG   = 1 <<  9, ///< do not save to config file
 
	SLF_NO_NETWORK_SYNC = 1 << 10, ///< do not synchronize over network (but it is saved if SLF_NOT_IN_SAVE is not set)
 
	SLF_ALLOW_CONTROL   = 1 << 11, ///< allow control codes in the strings
 
	SLF_ALLOW_NEWLINE   = 1 << 12, ///< allow new lines in the strings
 
	SLF_ALLOW_CONTROL   = 1 << 8, ///< Allow control codes in the strings.
 
	SLF_ALLOW_NEWLINE   = 1 << 9, ///< Allow new lines in the strings.
 
};
 

	
 
typedef uint32 VarType;
 

	
 
/** Type of data saved. */
 
enum SaveLoadType : byte {
 
	SL_VAR         =  0, ///< Save/load a variable.
 
	SL_REF         =  1, ///< Save/load a reference.
 
	SL_ARR         =  2, ///< Save/load an array.
 
	SL_STR         =  3, ///< Save/load a string.
 
	SL_LST         =  4, ///< Save/load a list.
 
	SL_DEQUE       =  5, ///< Save/load a deque.
 
@@ -664,25 +661,25 @@ using SaveLoadTable = span<const SaveLoa
 
/**
 
 * Empty space in every savegame version.
 
 * @param length Length of the empty space.
 
 */
 
#define SLE_NULL(length) SLE_CONDNULL(length, SL_MIN_VERSION, SL_MAX_VERSION)
 

	
 
/**
 
 * Empty space in some savegame versions.
 
 * @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.
 
 */
 
#define SLE_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, 0, nullptr, 0}
 
#define SLE_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL, length, from, to, 0, nullptr, 0}
 

	
 
/** 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, 0)
 

	
 
#define SLE_VEH_INCLUDE() {SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0, [] (void *b, size_t) { return b; }, 0}
 
#define SLE_ST_INCLUDE() {SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0, [] (void *b, size_t) { return b; }, 0}
 

	
 
/**
 
 * Storage of global simple variables, references (pointers), and arrays.
 
 * @param cmd      Load/save type. @see SaveLoadType
 
 * @param variable Name of the global variable.
 
 * @param type     Storage of the data in memory and in the savegame.
 
@@ -788,25 +785,25 @@ using SaveLoadTable = span<const SaveLoa
 
 * Storage of a global list 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_LST(variable, type) SLEG_CONDLST(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
 

	
 
/**
 
 * Empty global space in some savegame versions.
 
 * @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.
 
 */
 
#define SLEG_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, 0, nullptr, 0}
 
#define SLEG_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL, length, from, to, 0, nullptr, 0}
 

	
 
/**
 
 * Checks whether the savegame is below \a major.\a minor.
 
 * @param major Major number of the version to check against.
 
 * @param minor Minor number of the version to check against. If \a minor is 0 or not specified, only the major number is checked.
 
 * @return Savegame version is earlier than the specified version.
 
 */
 
static inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0)
 
{
 
	extern SaveLoadVersion _sl_version;
 
	extern byte            _sl_minor_version;
 
	return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);