summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/script_config.cpp20
-rw-r--r--src/script/script_config.hpp5
2 files changed, 25 insertions, 0 deletions
diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp
index 8de141e66..9bb953c4c 100644
--- a/src/script/script_config.cpp
+++ b/src/script/script_config.cpp
@@ -127,6 +127,26 @@ void ScriptConfig::ResetSettings()
this->settings.clear();
}
+void ScriptConfig::ResetEditableSettings(bool yet_to_start)
+{
+ if (this->info == nullptr) return ResetSettings();
+
+ for (SettingValueList::iterator it = this->settings.begin(); it != this->settings.end();) {
+ const ScriptConfigItem *config_item = this->info->GetConfigItem(it->first);
+ assert(config_item != nullptr);
+
+ bool editable = yet_to_start || (config_item->flags & SCRIPTCONFIG_INGAME) != 0;
+ bool visible = _settings_client.gui.ai_developer_tools || (config_item->flags & SCRIPTCONFIG_DEVELOPER) == 0;
+
+ if (editable && visible) {
+ free(it->first);
+ it = this->settings.erase(it);
+ } else {
+ it++;
+ }
+ }
+}
+
void ScriptConfig::AddRandomDeviation()
{
for (const auto &item : *this->GetConfigList()) {
diff --git a/src/script/script_config.hpp b/src/script/script_config.hpp
index 31004caba..be231fcdc 100644
--- a/src/script/script_config.hpp
+++ b/src/script/script_config.hpp
@@ -135,6 +135,11 @@ public:
void ResetSettings();
/**
+ * Reset only editable and visible settings to their default value.
+ */
+ void ResetEditableSettings(bool yet_to_start);
+
+ /**
* Randomize all settings the Script requested to be randomized.
*/
virtual void AddRandomDeviation();