diff options
author | rubidium <rubidium@openttd.org> | 2009-12-08 23:32:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-08 23:32:32 +0000 |
commit | 7d33e62d7bda071f4cc5c713c8a1b802e6915778 (patch) | |
tree | 12633add87ae1fc22c513e59d763990fa15bc547 /src | |
parent | e7810f8061a74e2da0e4537bac22e2179cb0a4b3 (diff) | |
download | openttd-7d33e62d7bda071f4cc5c713c8a1b802e6915778.tar.xz |
(svn r18436) -Fix [FS#3357]: unselect an AI in the AI Settings window when it falls out of the range of active AIs
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/ai_gui.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 21338040b..bf65e62cf 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -594,10 +594,7 @@ struct AIConfigWindow : public Window { } case AIC_WIDGET_LIST: { // Select a slot - uint slot = (pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height + this->vscroll.GetPosition(); - - if (slot == 0 || slot > _settings_newgame.difficulty.max_no_competitors) slot = INVALID_COMPANY; - this->selected_slot = (CompanyID)slot; + this->selected_slot = (CompanyID)((pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height + this->vscroll.GetPosition()); this->InvalidateData(); break; } @@ -628,6 +625,10 @@ struct AIConfigWindow : public Window { virtual void OnInvalidateData(int data) { + if (this->selected_slot == 0 || this->selected_slot > _settings_newgame.difficulty.max_no_competitors) { + this->selected_slot = INVALID_COMPANY; + } + this->SetWidgetDisabledState(AIC_WIDGET_DECREASE, _settings_newgame.difficulty.max_no_competitors == 0); this->SetWidgetDisabledState(AIC_WIDGET_INCREASE, _settings_newgame.difficulty.max_no_competitors == MAX_COMPANIES - 1); this->SetWidgetDisabledState(AIC_WIDGET_CHANGE, this->selected_slot == INVALID_COMPANY); |