Codechange: move SLF_NOT_IN_SAVE into settings

It is a settings-only flag, so don't pollute SaveLoad code with it.
This commit is contained in:
Patric Stout 2021-06-04 09:28:38 +02:00 committed by Patric Stout
parent 7572603c9d
commit 414e12d26b
2 changed files with 7 additions and 4 deletions

View File

@ -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);
}
/**

View File

@ -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);
}