Skip to content

Commit

Permalink
numclients fix
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed Jul 20, 2010
1 parent b337454 commit ee5b558
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ namespace server
return true;
}

int numclients(int exclude, bool nospec, bool noai)
int numclients(int exclude, bool nospec, bool noai, bool priv)
{
int n = 0;
loopv(clients) if(i!=exclude && (!nospec || clients[i]->state.state!=CS_SPECTATOR) && (!noai || clients[i]->state.aitype == AI_NONE)) n++;
loopv(clients)
{
clientinfo *ci = clients[i];
if(i!=exclude && (!nospec || ci->state.state!=CS_SPECTATOR || (priv && (ci->privilege || ci->local))) && (!noai || ci->state.aitype == AI_NONE)) n++;
}
return n;
}

Expand Down Expand Up @@ -871,7 +875,7 @@ namespace server

int welcomepacket(packetbuf &p, clientinfo *ci)
{
int hasmap = (m_edit && (clients.length()>1 || (ci && ci->local))) || (smapname[0] && (gamemillis<gamelimit || (ci && ci->state.state==CS_SPECTATOR) || numclients(ci && ci->local ? ci->clientnum : -1)));
int hasmap = (m_edit && (clients.length()>1 || (ci && ci->local))) || (smapname[0] && (gamemillis<gamelimit || (ci && ci->state.state==CS_SPECTATOR && !ci->privilege && !ci->local) || numclients(ci ? ci->clientnum : -1, true, true, true)));
putint(p, N_WELCOME);
putint(p, hasmap);
if(hasmap)
Expand Down Expand Up @@ -1451,6 +1455,7 @@ namespace server
else
return false;
sendf(-1, 1, "ri3", N_SPECTATOR, spectator, val);
if(!val && mapreload && !spinfo->privilege && !spinfo->local) sendf(spectator, 1, "ri", N_MAPRELOAD);
if(spectated)
SbPy::triggerEventInt("player_spectated", spinfo->clientnum);
else if(unspectated)
Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ namespace server

extern servmode *smode;

int numclients(int exclude = -1, bool nospec = true, bool noai = true);
int numclients(int exclude = -1, bool nospec = true, bool noai = true, bool priv = false);
void sendservmsg(const char *s);
clientinfo *getinfo(int n);
void hashPassword(int cn, int sessionid, char *pass, char *dest, int len);
Expand Down

0 comments on commit ee5b558

Please sign in to comment.