Mercurial > hg > openttd
changeset 4824:531e1dd73992 draft
(svn r6748) -Codechange: Use already existing function to count active players.
author | Darkvater <Darkvater@openttd.org> |
---|---|
date | Thu, 12 Oct 2006 11:42:57 +0000 |
parents | b5d7b0d208fb |
children | f2794bdce207 |
files | main_gui.c player.h players.c |
diffstat | 3 files changed, 12 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/main_gui.c +++ b/main_gui.c @@ -531,12 +531,7 @@ static void UpdatePlayerMenuHeight(Window *w) { - uint num = 0; - const Player *p; - - FOR_ALL_PLAYERS(p) { - if (p->is_active) num++; - } + byte num = ActivePlayerCount(); // Increase one to fit in PlayerList in the menu when in network if (_networking && WP(w,menu_d).main_button == 9) num++;
--- a/player.h +++ b/player.h @@ -216,7 +216,17 @@ // NOSAVE: can be determined from player structs VARDEF byte _player_colors[MAX_PLAYERS]; -byte ActivePlayerCount(void); +static inline byte ActivePlayerCount(void) +{ + const Player *p; + byte count = 0; + + FOR_ALL_PLAYERS(p) { + if (p->is_active) count++; + } + + return count; +} static inline Player* GetPlayer(PlayerID i) {