From c55f586df8ea121ee02f4d7a8e3d9aec6aaabec0 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sun, 12 Mar 2017 16:33:40 +0000 Subject: (svn r27786) -Fix [FS#6479]: AI configuration changed incorrect parameter when some parameters are hidden. --- src/ai/ai_gui.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/ai') diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index a0720e2ea..dd1de4dc2 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -531,21 +531,23 @@ struct AISettingsWindow : public Window { virtual void OnQueryTextFinished(char *str) { if (StrEmpty(str)) return; - ScriptConfigItemList::const_iterator it = this->ai_config->GetConfigList()->begin(); + VisibleSettingsList::const_iterator it = this->visible_settings.begin(); for (int i = 0; i < this->clicked_row; i++) it++; - if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (it->flags & SCRIPTCONFIG_INGAME) == 0) return; + const ScriptConfigItem config_item = **it; + if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; int32 value = atoi(str); - this->ai_config->SetSetting((*it).name, value); + this->ai_config->SetSetting(config_item.name, value); this->SetDirty(); } virtual void OnDropdownSelect(int widget, int index) { assert(this->clicked_dropdown); - ScriptConfigItemList::const_iterator it = this->ai_config->GetConfigList()->begin(); + VisibleSettingsList::const_iterator it = this->visible_settings.begin(); for (int i = 0; i < this->clicked_row; i++) it++; - if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (it->flags & SCRIPTCONFIG_INGAME) == 0) return; - this->ai_config->SetSetting((*it).name, index); + const ScriptConfigItem config_item = **it; + if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return; + this->ai_config->SetSetting(config_item.name, index); this->SetDirty(); } -- cgit v1.2.3-70-g09d2