mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Remove runtime variable size assertion.
parent
9f853c10b0
commit
10f94fb0dd
|
@ -1513,54 +1513,8 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld)
|
||||||
return 0;
|
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)
|
static bool SlObjectMember(void *object, const SaveLoad &sld)
|
||||||
{
|
{
|
||||||
assert(IsVariableSizeRight(sld));
|
|
||||||
|
|
||||||
if (!SlIsObjectValidInSavegame(sld)) return false;
|
if (!SlIsObjectValidInSavegame(sld)) return false;
|
||||||
|
|
||||||
VarType conv = GB(sld.conv, 0, 8);
|
VarType conv = GB(sld.conv, 0, 8);
|
||||||
|
|
Loading…
Reference in New Issue