summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_core.cpp1
-rw-r--r--src/game/game_core.cpp2
-rw-r--r--src/script/script_config.cpp9
-rw-r--r--src/script/script_config.hpp10
4 files changed, 22 insertions, 0 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index 8ad3e67df..3f4381b0c 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -47,6 +47,7 @@
/* Load default data and store the name in the settings */
config->Change(info->GetName(), -1, false, true);
}
+ config->AnchorUnchangeableSettings();
Backup<CompanyByte> cur_company(_current_company, company, FILE_LINE);
Company *c = Company::Get(company);
diff --git a/src/game/game_core.cpp b/src/game/game_core.cpp
index e1a21872a..9fd47a4c8 100644
--- a/src/game/game_core.cpp
+++ b/src/game/game_core.cpp
@@ -71,6 +71,8 @@
GameInfo *info = config->GetInfo();
if (info == NULL) return;
+ config->AnchorUnchangeableSettings();
+
Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
cur_company.Change(OWNER_DEITY);
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
@@ -108,6 +108,16 @@ public:
};
/**
+ * 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
* level).