Skip to content

Commit

Permalink
inform clients of current master and master mode
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed Jul 20, 2010
1 parent 666c7cb commit 369d2ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/fpsgame/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f
N_TIMEUP, 2, N_MAPRELOAD, 1, N_FORCEINTERMISSION, 1,
N_SERVMSG, 0, N_ITEMLIST, 0, N_RESUME, 0,
N_EDITMODE, 2, N_EDITENT, 11, N_EDITF, 16, N_EDITT, 16, N_EDITM, 16, N_FLIP, 14, N_COPY, 14, N_PASTE, 14, N_ROTATE, 15, N_REPLACE, 16, N_DELCUBE, 14, N_REMIP, 1, N_NEWMAP, 2, N_GETMAP, 1, N_SENDMAP, 0, N_EDITVAR, 0,
N_MASTERMODE, 2, N_KICK, 2, N_CLEARBANS, 1, N_CURRENTMASTER, 3, N_SPECTATOR, 3, N_SETMASTER, 0, N_SETTEAM, 0,
N_MASTERMODE, 2, N_KICK, 2, N_CLEARBANS, 1, N_CURRENTMASTER, 4, N_SPECTATOR, 3, N_SETMASTER, 0, N_SETTEAM, 0,
N_BASES, 0, N_BASEINFO, 0, N_BASESCORE, 0, N_REPAMMO, 1, N_BASEREGEN, 6, N_ANNOUNCE, 2,
N_LISTDEMOS, 1, N_SENDDEMOLIST, 0, N_GETDEMO, 2, N_SENDDEMO, 0,
N_DEMOPLAYBACK, 3, N_RECORDDEMO, 2, N_STOPDEMO, 1, N_CLEARDEMOS, 2,
Expand Down
21 changes: 9 additions & 12 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace server
enet_uint32 lastsend = 0;
int mastermode = MM_OPEN, mastermask = MM_PRIVSERV;
int currentmaster = -1;
bool masterupdate = false;
stream *mapdata = NULL;

vector<uint> allowedips;
Expand Down Expand Up @@ -601,7 +600,7 @@ namespace server
{
currentmaster = -1;
}
masterupdate = true;
sendf(-1, 1, "ri4", N_CURRENTMASTER, currentmaster, currentmaster >= 0 ? ci->privilege : 0, mastermode);
}

void setciadmin(clientinfo *ci)
Expand All @@ -610,7 +609,6 @@ namespace server
loopv(clients) if(ci!=clients[i] && clients[i]->privilege<=PRIV_MASTER) revokemaster(clients[i]);
ci->privilege = PRIV_ADMIN;
currentmaster = ci->clientnum;
masterupdate = true;
SbPy::triggerEventInt("player_claimed_admin", ci->clientnum);
}

Expand All @@ -622,7 +620,6 @@ namespace server
else
SbPy::triggerEventInt("player_released_admin", ci->clientnum);
ci->privilege = PRIV_NONE;
masterupdate = true;
currentmaster = -1;
}

Expand Down Expand Up @@ -899,6 +896,14 @@ namespace server
putint(p, -1);
}
}
if(currentmaster >= 0 || mastermode != MM_OPEN)
{
putint(p, N_CURRENTMASTER);
putint(p, currentmaster);
clientinfo *m = currentmaster >= 0 ? getinfo(currentmaster) : NULL;
putint(p, m ? m->privilege : 0);
putint(p, mastermode);
}
if(gamepaused)
{
putint(p, N_PAUSEGAME);
Expand Down Expand Up @@ -1339,13 +1344,6 @@ namespace server

loopv(connects) if(totalmillis-connects[i]->connectmillis>15000) disconnect_client(connects[i]->clientnum, DISC_TIMEOUT);

if(masterupdate)
{
clientinfo *m = currentmaster>=0 ? getinfo(currentmaster) : NULL;
sendf(-1, 1, "ri3", N_CURRENTMASTER, currentmaster, m ? m->privilege : 0);
masterupdate = false;
}

SbPy::update();

if(!gamepaused && m_timed && smapname[0] && gamemillis-curtime>0 && gamemillis/60000!=(gamemillis-curtime)/60000) checkintermission();
Expand Down Expand Up @@ -1646,7 +1644,6 @@ namespace server
ci->connected = true;
ci->connectmillis = totalmillis;
if(mastermode>=MM_LOCKED) ci->state.state = CS_SPECTATOR;
if(currentmaster>=0) masterupdate = true;
ci->state.lasttimeplayed = lastmillis;

const char *worst = m_teammode ? chooseworstteam(text, ci) : NULL;
Expand Down
1 change: 0 additions & 1 deletion src/fpsgame/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ namespace server

extern int gamemillis;
extern vector<clientinfo *> connects, clients, bots;
extern bool masterupdate;
extern int mastermode;
extern int mastermask;
extern char smapname[260];
Expand Down

0 comments on commit 369d2ef

Please sign in to comment.