From 81ce9ad1897819c94099e3c542bb7f480ba0f57b Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 12 Jul 2013 18:54:27 +0000 Subject: (svn r25592) -Fix [FS#5644]: Changing the script difficulty level in-game would also change the settings using the default even though they were not allowed to change in-game --- src/script/script_config.cpp | 9 +++++++++ src/script/script_config.hpp | 10 ++++++++++ 2 files changed, 19 insertions(+) (limited to 'src/script') diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp index 7260febdf..a46f5f392 100644 --- a/src/script/script_config.cpp +++ b/src/script/script_config.cpp @@ -84,6 +84,15 @@ void ScriptConfig::ClearConfigList() this->settings.clear(); } +void ScriptConfig::AnchorUnchangeableSettings() +{ + for (ScriptConfigItemList::const_iterator it = this->GetConfigList()->begin(); it != this->GetConfigList()->end(); it++) { + if (((*it).flags & SCRIPTCONFIG_INGAME) == 0) { + this->SetSetting((*it).name, this->GetSetting((*it).name)); + } + } +} + int ScriptConfig::GetSetting(const char *name) const { SettingValueList::const_iterator it = this->settings.find(name); diff --git a/src/script/script_config.hpp b/src/script/script_config.hpp index 23822de88..0350f8ded 100644 --- a/src/script/script_config.hpp +++ b/src/script/script_config.hpp @@ -107,6 +107,16 @@ public: SSS_FORCE_GAME, ///< Get the Script config from the current game }; + /** + * As long as the default of a setting has not been changed, the value of + * the setting is not stored. This to allow changing the difficulty setting + * without having to reset the script's config. However, when a setting may + * not be changed in game, we must "anchor" this value to what the setting + * would be at the time of starting. Otherwise changing the difficulty + * setting would change the setting's value (which isn't allowed). + */ + void AnchorUnchangeableSettings(); + /** * Get the value of a setting for this config. It might fallback to his * 'info' to find the default value (if not set or if not-custom difficulty -- cgit v1.2.3-70-g09d2