Changeset - r28263:572687aa6ba8
[Not reviewed]
master
0 1 0
Peter Nelson - 12 months ago 2023-12-07 19:16:14
peter1138@openttd.org
Codechange: Move VarType helpers to allow earlier use.
1 file changed with 32 insertions and 32 deletions:
0 comments (0 inline, 0 general)
src/saveload/saveload.h
Show inline comments
 
@@ -710,6 +710,38 @@ struct SaveLoadCompat {
 
};
 

	
 
/**
 
 * 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
 
 * @param name     Field name for table chunks.
 
@@ -1134,38 +1166,6 @@ static inline bool SlIsObjectCurrentlyVa
 
}
 

	
 
/**
 
 * 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
 
 * on the saveload data and the current object for non-globals.
0 comments (0 inline, 0 general)