summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2020-12-25 19:57:13 +0100
committerGitHub <noreply@github.com>2020-12-25 19:57:13 +0100
commite6e91a345c1d802f0bb1da04e1d6f4ed843e4c8a (patch)
treecc3649ae4a42c48fea007e48c0e1a8f795350f7d /src/ai
parentf66baa444ff5575b2b40e3bfd514cdb463f6f560 (diff)
downloadopenttd-e6e91a345c1d802f0bb1da04e1d6f4ed843e4c8a.tar.xz
Fix f66baa44: index was off by one (#8433)
i++ in the 3rd part of a for() is post, not pre. Oops.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_gui.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 078bde4e1..23d1e81b7 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -127,7 +127,7 @@ struct AIListWindow : public Window {
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_LEFT, y + WD_MATRIX_TOP, this->slot == OWNER_DEITY ? STR_AI_CONFIG_NONE : STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_ORANGE);
y += this->line_height;
}
- int i = 1;
+ int i = 0;
for (const auto &item : *this->info_list) {
i++;
if (this->vscroll->IsVisible(i)) {
@@ -139,7 +139,7 @@ struct AIListWindow : public Window {
}
case WID_AIL_INFO_BG: {
AIInfo *selected_info = nullptr;
- int i = 1;
+ int i = 0;
for (const auto &item : *this->info_list) {
i++;
if (this->selected == i - 1) selected_info = static_cast<AIInfo *>(item.second);