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
 
@@ -1408,10 +1408,7 @@ 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);
 
}
 

	
 
/**
src/settings.cpp
Show inline comments
 
@@ -2023,6 +2023,8 @@ void IConsoleListSettings(const char *pr
 
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 SettingTa
 
	 * 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);
 
	}
0 comments (0 inline, 0 general)