Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
News crash fix
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index a3f73d729..055979951 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -255,7 +255,7 @@ NewsDisplay NewsTypeData::GetDisplay() const
uint index;
const SettingDesc *sd = GetSettingFromName(this->name, &index);
assert(sd != nullptr);
- void *ptr = GetVariableAddress(nullptr, &sd->save);
+ void *ptr = GetVariableAddress(&_settings_game, &sd->save);
return (NewsDisplay)ReadValue(ptr, sd->save.conv);
}
diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h
index abd58ea04..fc9c1cee9 100644
--- a/src/saveload/saveload.h
+++ b/src/saveload/saveload.h
@@ -873,7 +873,8 @@ 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);
+ if (sld->global) return sld->address;
+ return const_cast<byte *>((const byte*)object + (ptrdiff_t)sld->address);
}
int64 ReadValue(const void *ptr, VarType conv);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment