From cde65455acbc10a3f64bb9d43c03b37cdf9b1c55 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 18 Jul 2008 16:40:29 +0000 Subject: (svn r13731) -Codechange: make a pool of the array of players. --- src/toolbar_gui.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/toolbar_gui.cpp') diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 101008e2c..9f2266b9e 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1482,7 +1482,7 @@ static int GetPlayerIndexFromMenu(int index) const Player *p; FOR_ALL_PLAYERS(p) { - if (p->is_active && --index < 0) return p->index; + if (--index < 0) return p->index; } } return -1; @@ -1558,19 +1558,18 @@ struct ToolbarPlayerMenuWindow : Window { sel--; } - const Player *p; - FOR_ALL_PLAYERS(p) { - if (p->is_active) { - if (p->index == sel) { + for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) { + if (IsValidPlayerID(p)) { + if (p == sel) { GfxFillRect(x, y, x + 238, y + 9, 0); } - DrawPlayerIcon(p->index, x + 2, y + 1); + DrawPlayerIcon(p, x + 2, y + 1); - SetDParam(0, p->index); - SetDParam(1, p->index); + SetDParam(0, p); + SetDParam(1, p); - TextColour color = (p->index == sel) ? TC_WHITE : TC_BLACK; + TextColour color = (p == sel) ? TC_WHITE : TC_BLACK; if (gray & 1) color = TC_GREY; DrawString(x + 19, y, STR_7021, color); -- cgit v1.2.3-70-g09d2