diff options
Diffstat (limited to 'src/fpsgame/extinfo.h')
| -rw-r--r-- | src/fpsgame/extinfo.h | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/src/fpsgame/extinfo.h b/src/fpsgame/extinfo.h index 059ee27..b467a8c 100644 --- a/src/fpsgame/extinfo.h +++ b/src/fpsgame/extinfo.h @@ -15,7 +15,6 @@ A: 0 EXT_UPTIME B: 0 EXT_PLAYERSTATS cn #a client number or -1 for all players# C: 0 EXT_TEAMSCORE - Server: -------- A: 0 EXT_UPTIME EXT_ACK EXT_VERSION uptime #in seconds# @@ -23,16 +22,12 @@ EXT_PLAYERSTATS_RESP_IDS pid(s) #1 packet# EXT_PLAYERSTATS_RESP_STATS pid playerdata #1 packet for each player# C: 0 EXT_TEAMSCORE EXT_ACK EXT_VERSION 0 or 1 #error, no teammode# remaining_time gamemode loop(teamdata [numbases bases] or -1) - Errors: -------------- B:C:default: 0 command EXT_ACK EXT_VERSION EXT_ERROR */ - VAR(extinfoip, 0, 0, 1); - - void extinfoplayer(ucharbuf &p, clientinfo *ci) - { + void extinfoplayer(ucharbuf &p, clientinfo *ci) { ucharbuf q = p; putint(q, EXT_PLAYERSTATS_RESP_STATS); // send player stats following putint(q, ci->clientnum); //add player id @@ -53,91 +48,65 @@ q.put((uchar*)&ip, 3); sendserverinforeply(q); } - - static inline void extinfoteamscore(ucharbuf &p, const char *team, int score) - { + static inline void extinfoteamscore(ucharbuf &p, const char *team, int score) { sendstring(team, p); putint(p, score); putint(p,-1); //no bases follow } - - void extinfoteams(ucharbuf &p) - { + void extinfoteams(ucharbuf &p) { putint(p, m_teammode ? 0 : 1); putint(p, gamemode); putint(p, max((gamelimit - gamemillis)/1000, 0)); if(!m_teammode) return; - vector<teamscore> scores; - loopv(clients) - { + loopv(clients) { clientinfo *ci = clients[i]; - if(ci->state.state!=CS_SPECTATOR && ci->team[0] && scores.htfind(ci->team) < 0) - { + if(ci->state.state!=CS_SPECTATOR && ci->team[0] && scores.htfind(ci->team) < 0) { teaminfo *ti = teaminfos.access(ci->team); scores.add(teamscore(ci->team, ti ? ti->frags : 0)); } } loopv(scores) extinfoteamscore(p, scores[i].team, scores[i].score); } - - void extserverinforeply(ucharbuf &req, ucharbuf &p) - { + void extserverinforeply(ucharbuf &req, ucharbuf &p) { int extcmd = getint(req); // extended commands - //Build a new packet putint(p, EXT_ACK); //send ack putint(p, EXT_VERSION); //send version of extended info - - switch(extcmd) - { - case EXT_UPTIME: - { + switch(extcmd) { + case EXT_UPTIME: { putint(p, totalsecs); //in seconds break; } - - case EXT_PLAYERSTATS: - { + case EXT_PLAYERSTATS: { int cn = getint(req); //a special player, -1 for all - clientinfo *ci = NULL; - if(cn >= 0) - { + if(cn >= 0) { loopv(clients) if(clients[i]->clientnum == cn) { ci = clients[i]; break; } - if(!ci) - { + if(!ci) { putint(p, EXT_ERROR); //client requested by id was not found sendserverinforeply(p); return; } } - putint(p, EXT_NO_ERROR); //so far no error can happen anymore - ucharbuf q = p; //remember buffer position putint(q, EXT_PLAYERSTATS_RESP_IDS); //send player ids following if(ci) putint(q, ci->clientnum); else loopv(clients) putint(q, clients[i]->clientnum); sendserverinforeply(q); - if(ci) extinfoplayer(p, ci); else loopv(clients) extinfoplayer(p, clients[i]); return; } - - case EXT_TEAMSCORE: - { + case EXT_TEAMSCORE: { extinfoteams(p); break; } - - default: - { + default: { putint(p, EXT_ERROR); break; } } sendserverinforeply(p); } - |
