summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-04 09:28:38 +0200
committerPatric Stout <github@truebrain.nl>2021-06-06 21:45:01 +0200
commit414e12d26be88043000aa7fe540edc974244dcc8 (patch)
tree0b77f714795982ffc0c8cab3d369e3a8778fb5c1
parent7572603c9d97215afe62cd79e25048237a637616 (diff)
downloadopenttd-414e12d26be88043000aa7fe540edc974244dcc8.tar.xz
Codechange: move SLF_NOT_IN_SAVE into settings
It is a settings-only flag, so don't pollute SaveLoad code with it.
-rw-r--r--src/saveload/saveload.cpp5
-rw-r--r--src/settings.cpp6
2 files changed, 7 insertions, 4 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 3c95e61e2..427a19aa9 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1408,10 +1408,7 @@ static void SlDeque(void *deque, VarType conv)
/** Are we going to save this object or not? */
static inline bool SlIsObjectValidInSavegame(const SaveLoad &sld)
{
- if (_sl_version < sld.version_from || _sl_version >= sld.version_to) return false;
- if (sld.conv & SLF_NOT_IN_SAVE) return false;
-
- return true;
+ return (_sl_version >= sld.version_from && _sl_version < sld.version_to);
}
/**
diff --git a/src/settings.cpp b/src/settings.cpp
index 60ae20d82..93caff15d 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -2023,6 +2023,8 @@ void IConsoleListSettings(const char *prefilter)
static void LoadSettings(const SettingTable &settings, void *object)
{
for (auto &osd : settings) {
+ if (osd->save.conv & SLF_NOT_IN_SAVE) continue;
+
void *ptr = GetVariableAddress(object, osd->save);
if (!SlObjectMember(ptr, osd->save)) continue;
@@ -2045,11 +2047,15 @@ static void SaveSettings(const SettingTable &settings, void *object)
* SlCalcLength() because we have a different format. So do this manually */
size_t length = 0;
for (auto &sd : settings) {
+ if (sd->save.conv & SLF_NOT_IN_SAVE) continue;
+
length += SlCalcObjMemberLength(object, sd->save);
}
SlSetLength(length);
for (auto &sd : settings) {
+ if (sd->save.conv & SLF_NOT_IN_SAVE) continue;
+
void *ptr = GetVariableAddress(object, sd->save);
SlObjectMember(ptr, sd->save);
}