diff options
author | peter1138 <peter1138@openttd.org> | 2017-03-12 16:33:40 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2017-03-12 16:33:40 +0000 |
commit | c55f586df8ea121ee02f4d7a8e3d9aec6aaabec0 (patch) | |
tree | ba0722c7c07b6b7fe2041bf33eecaaf1e60fef22 | |
parent | 3aad5abfe953cd7641e74b6ff5b159f7a58013f2 (diff) | |
download | openttd-c55f586df8ea121ee02f4d7a8e3d9aec6aaabec0.tar.xz |
(svn r27786) -Fix [FS#6479]: AI configuration changed incorrect parameter when some parameters are hidden.
-rw-r--r-- | src/ai/ai_gui.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
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(); } |