File diff r25600:a0060616e61f → r25601:747c128b2f85
src/settings.cpp
Show inline comments
 
@@ -588,13 +588,13 @@ static void IniSaveSettings(IniFile *ini
 
	char buf[512];
 

	
 
	for (auto &sd : settings_table) {
 
		/* If the setting is not saved to the configuration
 
		 * file, just continue with the next setting */
 
		if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue;
 
		if (sd->save.conv & SLF_NOT_IN_CONFIG) continue;
 
		if (sd->flags & SF_NOT_IN_CONFIG) continue;
 

	
 
		/* XXX - wtf is this?? (group override?) */
 
		std::string s{ sd->name };
 
		auto sc = s.find('.');
 
		if (sc != std::string::npos) {
 
			group = ini->GetGroup(s.substr(0, sc));
 
@@ -738,13 +738,13 @@ void IniSaveWindowSettings(IniFile *ini,
 
 * Check whether the setting is editable in the current gamemode.
 
 * @param do_command true if this is about checking a command from the server.
 
 * @return true if editable.
 
 */
 
bool SettingDesc::IsEditable(bool do_command) const
 
{
 
	if (!do_command && !(this->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server && !(this->flags & SF_PER_COMPANY)) return false;
 
	if (!do_command && !(this->flags & SF_NO_NETWORK_SYNC) && _networking && !_network_server && !(this->flags & SF_PER_COMPANY)) return false;
 
	if ((this->flags & SF_NETWORK_ONLY) && !_networking && _game_mode != GM_MENU) return false;
 
	if ((this->flags & SF_NO_NETWORK) && _networking) return false;
 
	if ((this->flags & SF_NEWGAME_ONLY) &&
 
			(_game_mode == GM_NORMAL ||
 
			(_game_mode == GM_EDITOR && !(this->flags & SF_SCENEDIT_TOO)))) return false;
 
	if ((this->flags & SF_SCENEDIT_ONLY) && _game_mode != GM_EDITOR) return false;
 
@@ -755,13 +755,13 @@ bool SettingDesc::IsEditable(bool do_com
 
 * Return the type of the setting.
 
 * @return type of setting
 
 */
 
SettingType SettingDesc::GetType() const
 
{
 
	if (this->flags & SF_PER_COMPANY) return ST_COMPANY;
 
	return (this->save.conv & SLF_NOT_IN_SAVE) ? ST_CLIENT : ST_GAME;
 
	return (this->flags & SF_NOT_IN_SAVE) ? ST_CLIENT : ST_GAME;
 
}
 

	
 
/**
 
 * Get the setting description of this setting as an integer setting.
 
 * @return The integer setting description.
 
 */
 
@@ -1841,13 +1841,13 @@ bool SetSettingValue(const IntSettingDes
 
	}
 

	
 
	/* If an item is company-based, we do not send it over the network
 
	 * (if any) to change. Also *hack*hack* we update the _newgame version
 
	 * of settings because changing a company-based setting in a game also
 
	 * changes its defaults. At least that is the convention we have chosen */
 
	if (setting->save.conv & SLF_NO_NETWORK_SYNC) {
 
	if (setting->flags & SF_NO_NETWORK_SYNC) {
 
		if (_game_mode != GM_MENU) {
 
			setting->ChangeValue(&_settings_newgame, value);
 
		}
 
		setting->ChangeValue(&GetGameSettings(), value);
 
		return true;
 
	}
 
@@ -1896,13 +1896,13 @@ void SyncCompanySettings()
 
 * @param value the value to write
 
 * @param force_newgame force the newgame settings
 
 * @note Strings WILL NOT be synced over the network
 
 */
 
bool SetSettingValue(const StringSettingDesc *sd, std::string value, bool force_newgame)
 
{
 
	assert(sd->save.conv & SLF_NO_NETWORK_SYNC);
 
	assert(sd->flags & SF_NO_NETWORK_SYNC);
 

	
 
	if (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ && value.compare("(null)") == 0) {
 
		value.clear();
 
	}
 

	
 
	const void *object = (_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game;
 
@@ -2020,16 +2020,16 @@ 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;
 
		if (osd->flags & SF_NOT_IN_SAVE) continue;
 

	
 
		SaveLoad sl = osd->save;
 
		if ((osd->save.conv & SLF_NO_NETWORK_SYNC) && _networking && !_network_server) {
 
		if ((osd->flags & SF_NO_NETWORK_SYNC) && _networking && !_network_server) {
 
			/* We don't want to read this setting, so we do need to skip over it. */
 
			sl = SLE_NULL(static_cast<uint16>(SlCalcConvMemLen(osd->save.conv) * osd->save.length));
 
		}
 

	
 
		void *ptr = GetVariableAddress(object, sl);
 
		if (!SlObjectMember(ptr, sl)) continue;
 
@@ -2050,20 +2050,20 @@ 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;
 
		if (sd->flags & SF_NOT_IN_SAVE) continue;
 

	
 
		length += SlCalcObjMemberLength(object, sd->save);
 
	}
 
	SlSetLength(length);
 

	
 
	for (auto &sd : settings) {
 
		if (sd->save.conv & SLF_NOT_IN_SAVE) continue;
 
		if (sd->flags & SF_NOT_IN_SAVE) continue;
 

	
 
		void *ptr = GetVariableAddress(object, sd->save);
 
		SlObjectMember(ptr, sd->save);
 
	}
 
}