From cb53fed229b3cbf404028316dfada54360c6071e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 7 Dec 2023 19:16:14 +0000 Subject: [PATCH] Codechange: Move VarType helpers to allow earlier use. --- src/saveload/saveload.h | 64 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 980d017973..6f49cda7ed 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -709,6 +709,38 @@ struct SaveLoadCompat { SaveLoadVersion version_to; ///< Save/load the variable before this savegame version. }; +/** + * Get the NumberType of a setting. This describes the integer type + * as it is represented in memory + * @param type VarType holding information about the variable-type + * @return the SLE_VAR_* part of a variable-type description + */ +static inline constexpr VarType GetVarMemType(VarType type) +{ + return GB(type, 4, 4) << 4; +} + +/** + * Get the FileType of a setting. This describes the integer type + * as it is represented in a savegame/file + * @param type VarType holding information about the file-type + * @return the SLE_FILE_* part of a variable-type description + */ +static inline constexpr VarType GetVarFileType(VarType type) +{ + return GB(type, 0, 4); +} + +/** + * Check if the given saveload type is a numeric type. + * @param conv the type to check + * @return True if it's a numeric type. + */ +static inline constexpr bool IsNumericType(VarType conv) +{ + return GetVarMemType(conv) <= SLE_VAR_U64; +} + /** * Storage of simple variables, references (pointers), and arrays. * @param cmd Load/save type. @see SaveLoadType @@ -1133,38 +1165,6 @@ static inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLo return version_from <= SAVEGAME_VERSION && SAVEGAME_VERSION < version_to; } -/** - * Get the NumberType of a setting. This describes the integer type - * as it is represented in memory - * @param type VarType holding information about the variable-type - * @return the SLE_VAR_* part of a variable-type description - */ -static inline VarType GetVarMemType(VarType type) -{ - return GB(type, 4, 4) << 4; -} - -/** - * Get the FileType of a setting. This describes the integer type - * as it is represented in a savegame/file - * @param type VarType holding information about the file-type - * @return the SLE_FILE_* part of a variable-type description - */ -static inline VarType GetVarFileType(VarType type) -{ - return GB(type, 0, 4); -} - -/** - * Check if the given saveload type is a numeric type. - * @param conv the type to check - * @return True if it's a numeric type. - */ -static inline bool IsNumericType(VarType conv) -{ - return GetVarMemType(conv) <= SLE_VAR_U64; -} - /** * Get the address of the variable. Null-variables don't have an address, * everything else has a callback function that returns the address based