Last active
December 4, 2020 21:10
-
-
Save TrueBrain/bca0eff23d5ef5ea958cd22a44f0c55a to your computer and use it in GitHub Desktop.
News crash fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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