(svn r6748) -Codechange: Use already existing function to count active players.
This commit is contained in:
@@ -531,12 +531,7 @@ static int GetPlayerIndexFromMenu(int index)
|
|||||||
|
|
||||||
static void UpdatePlayerMenuHeight(Window *w)
|
static void UpdatePlayerMenuHeight(Window *w)
|
||||||
{
|
{
|
||||||
uint num = 0;
|
byte num = ActivePlayerCount();
|
||||||
const Player *p;
|
|
||||||
|
|
||||||
FOR_ALL_PLAYERS(p) {
|
|
||||||
if (p->is_active) num++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase one to fit in PlayerList in the menu when in network
|
// Increase one to fit in PlayerList in the menu when in network
|
||||||
if (_networking && WP(w,menu_d).main_button == 9) num++;
|
if (_networking && WP(w,menu_d).main_button == 9) num++;
|
||||||
|
12
player.h
12
player.h
@@ -216,7 +216,17 @@ VARDEF Player _players[MAX_PLAYERS];
|
|||||||
// NOSAVE: can be determined from player structs
|
// NOSAVE: can be determined from player structs
|
||||||
VARDEF byte _player_colors[MAX_PLAYERS];
|
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)
|
static inline Player* GetPlayer(PlayerID i)
|
||||||
{
|
{
|
||||||
|
12
players.c
12
players.c
@@ -192,18 +192,6 @@ void DrawPlayerFace(uint32 face, int color, int x, int y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
byte ActivePlayerCount(void)
|
|
||||||
{
|
|
||||||
const Player *p;
|
|
||||||
byte count = 0;
|
|
||||||
|
|
||||||
FOR_ALL_PLAYERS(p) {
|
|
||||||
if (p->is_active) count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InvalidatePlayerWindows(const Player *p)
|
void InvalidatePlayerWindows(const Player *p)
|
||||||
{
|
{
|
||||||
PlayerID pid = p->index;
|
PlayerID pid = p->index;
|
||||||
|
Reference in New Issue
Block a user