Merge branch 'master' into jgrpp
# Conflicts: # CMakeLists.txt # src/bootstrap_gui.cpp
This commit is contained in:
@@ -446,7 +446,7 @@ static bool FixTTOEngines()
|
||||
e->preview_company = INVALID_COMPANY;
|
||||
e->preview_asked = (CompanyMask)-1;
|
||||
e->preview_wait = 0;
|
||||
e->name = nullptr;
|
||||
e->name = std::string{};
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1941,7 +1941,7 @@ void SlObject(void *object, const SaveLoad *sld)
|
||||
}
|
||||
|
||||
for (; sld->cmd != SL_END; sld++) {
|
||||
void *ptr = sld->global ? sld->address : GetVariableAddress(object, sld);
|
||||
void *ptr = GetVariableAddress(object, sld);
|
||||
SlObjectMember(ptr, sld);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1038,7 +1038,18 @@ static inline bool IsNumericType(VarType conv)
|
||||
*/
|
||||
static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
|
||||
{
|
||||
return const_cast<byte *>((const byte*)(sld->global ? nullptr : object) + (ptrdiff_t)sld->address);
|
||||
/* Entry is a global address. */
|
||||
if (sld->global) return sld->address;
|
||||
|
||||
/* Entry is a null-variable, mostly used to read old savegames etc. */
|
||||
if (GetVarMemType(sld->conv) == SLE_VAR_NULL) {
|
||||
assert(sld->address == nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Everything else should be a non-null pointer. */
|
||||
assert(object != nullptr);
|
||||
return const_cast<byte *>((const byte *)object + (ptrdiff_t)sld->address);
|
||||
}
|
||||
|
||||
int64 ReadValue(const void *ptr, VarType conv);
|
||||
|
||||
Reference in New Issue
Block a user