Changeset - r28265:9c3ea4152dd3
[Not reviewed]
master
0 1 0
Peter Nelson - 12 months ago 2023-12-07 19:16:33
peter1138@openttd.org
Codechange: Remove runtime variable size assertion.
1 file changed with 0 insertions and 46 deletions:
0 comments (0 inline, 0 general)
src/saveload/saveload.cpp
Show inline comments
 
@@ -1513,54 +1513,8 @@ size_t SlCalcObjMemberLength(const void 
 
	return 0;
 
}
 

	
 
/**
 
 * Check whether the variable size of the variable in the saveload configuration
 
 * matches with the actual variable size.
 
 * @param sld The saveload configuration to test.
 
 */
 
[[maybe_unused]] static bool IsVariableSizeRight(const SaveLoad &sld)
 
{
 
	if (GetVarMemType(sld.conv) == SLE_VAR_NULL) return true;
 

	
 
	switch (sld.cmd) {
 
		case SL_VAR:
 
			switch (GetVarMemType(sld.conv)) {
 
				case SLE_VAR_BL:
 
					return sld.size == sizeof(bool);
 
				case SLE_VAR_I8:
 
				case SLE_VAR_U8:
 
					return sld.size == sizeof(int8_t);
 
				case SLE_VAR_I16:
 
				case SLE_VAR_U16:
 
					return sld.size == sizeof(int16_t);
 
				case SLE_VAR_I32:
 
				case SLE_VAR_U32:
 
					return sld.size == sizeof(int32_t);
 
				case SLE_VAR_I64:
 
				case SLE_VAR_U64:
 
					return sld.size == sizeof(int64_t);
 
				case SLE_VAR_NAME:
 
					return sld.size == sizeof(std::string);
 
				default:
 
					return sld.size == sizeof(void *);
 
			}
 
		case SL_REF:
 
			/* These should all be pointer sized. */
 
			return sld.size == sizeof(void *);
 

	
 
		case SL_STDSTR:
 
			/* These should be all pointers to std::string. */
 
			return sld.size == sizeof(std::string);
 

	
 
		default:
 
			return true;
 
	}
 
}
 

	
 
static bool SlObjectMember(void *object, const SaveLoad &sld)
 
{
 
	assert(IsVariableSizeRight(sld));
 

	
 
	if (!SlIsObjectValidInSavegame(sld)) return false;
 

	
 
	VarType conv = GB(sld.conv, 0, 8);
0 comments (0 inline, 0 general)