Changeset - r25599:f43d9abb9af5
[Not reviewed]
master
0 2 0
Patric Stout - 3 years ago 2021-06-04 07:28:38
truebrain@openttd.org
Codechange: move SLF_NOT_IN_SAVE into settings

It is a settings-only flag, so don't pollute SaveLoad code with it.
2 files changed with 7 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/saveload/saveload.cpp
Show inline comments
 
@@ -1405,16 +1405,13 @@ static void SlDeque(void *deque, VarType
 
}
 

	
 

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

	
 
/**
 
 * Are we going to load this variable when loading a savegame or not?
 
 * @note If the variable is skipped it is skipped in the savegame
 
 * bytestream itself as well, so there is no need to skip it somewhere else
src/settings.cpp
Show inline comments
 
@@ -2020,12 +2020,14 @@ void IConsoleListSettings(const char *pr
 
 * @param object can be either nullptr in which case we load global variables or
 
 * a pointer to a struct which is getting saved
 
 */
 
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;
 
		if (osd->IsIntSetting()) {
 
			const IntSettingDesc *int_setting = osd->AsIntSetting();
 
			int_setting->MakeValueValidAndWrite(object, int_setting->Read(object));
 
@@ -2042,17 +2044,21 @@ static void LoadSettings(const SettingTa
 
static void SaveSettings(const SettingTable &settings, void *object)
 
{
 
	/* We need to write the CH_RIFF header, but unfortunately can't call
 
	 * 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);
 
	}
 
}
 

	
 
static void Load_OPTS()
0 comments (0 inline, 0 general)