Skip to content

Commit

Permalink
display time remaining in minutes:seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
greghaynes committed Jul 20, 2010
1 parent a34d07a commit f023ab2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/fpsgame/capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ struct captureservmode : servmode

void movebases(const char *team, const vec &oldpos, bool oldclip, const vec &newpos, bool newclip)
{
if(!team[0] || minremain<=0) return;
if(!team[0] || gamemillis>=gamelimit) return;
loopv(bases)
{
baseinfo &b = bases[i];
Expand Down Expand Up @@ -810,7 +810,7 @@ struct captureservmode : servmode

void update()
{
if(minremain<=0) return;
if(gamemillis>=gamelimit) return;
endcheck();
int t = gamemillis/1000 - (gamemillis-curtime)/1000;
if(t<1) return;
Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/ctf.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ struct ctfclientmode : clientmode

void update()
{
if(minremain<=0 || notgotflags) return;
if(gamemillis>=gamelimit || notgotflags) return;
loopv(flags)
{
flag &f = flags[i];
Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/extinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
putint(p, m_teammode ? 0 : 1);
putint(p, gamemode);
putint(p, minremain);
putint(p, max((gamelimit - gamemillis)/1000, 0));
if(!m_teammode) return;

vector<teamscore> scores;
Expand Down
3 changes: 1 addition & 2 deletions src/fpsgame/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,8 @@ namespace game
// fps
extern int gamemode, nextmode;
extern string clientmap;
extern int minremain;
extern bool intermission;
extern int maptime, maprealtime;
extern int maptime, maprealtime, maplimit;
extern fpsent *player1;
extern vector<fpsent *> players, clients;
extern int lastspawnattempt;
Expand Down
34 changes: 14 additions & 20 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace server
bool gamepaused = false;

string smapname = "";
int interm = 0, minremain = 0;
int interm = 0;
bool mapreload = false;
enet_uint32 lastsend = 0;
int mastermode = MM_OPEN, mastermask = MM_PRIVSERV;
Expand Down Expand Up @@ -212,7 +212,7 @@ namespace server

bool pickup(int i, int sender) // server side item pickup, acknowledge first client that gets it
{
if(minremain<=0 || !sents.inrange(i) || !sents[i].spawned) return false;
if(gamemillis>=gamelimit || !sents.inrange(i) || !sents[i].spawned) return false;
clientinfo *ci = getinfo(sender);
if(!ci || (!ci->local && !ci->state.canpickup(sents[i].type))) return false;
sents[i].spawned = false;
Expand Down Expand Up @@ -871,7 +871,7 @@ namespace server

int welcomepacket(packetbuf &p, clientinfo *ci)
{
int hasmap = (m_edit && (clients.length()>1 || (ci && ci->local))) || (smapname[0] && (minremain>0 || (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) || numclients(ci && ci->local ? ci->clientnum : -1)));
putint(p, N_WELCOME);
putint(p, hasmap);
if(hasmap)
Expand All @@ -883,7 +883,7 @@ namespace server
if(!ci || (m_timed && smapname[0]))
{
putint(p, N_TIMEUP);
putint(p, minremain);
putint(p, max((gamelimit - gamemillis)/1000, 0));
}
if(!notgotitems)
{
Expand Down Expand Up @@ -1002,8 +1002,7 @@ namespace server
mapreload = false;
gamemode = mode;
gamemillis = 0;
minremain = m_overtime ? 15 : 10;
gamelimit = minremain*60000;
gamelimit = (m_overtime ? 15 : 10)*60000;
interm = 0;
copystring(smapname, s);
resetitems();
Expand All @@ -1024,7 +1023,7 @@ namespace server
else smode = NULL;
if(smode) smode->reset(false);

if(m_timed && smapname[0]) sendf(-1, 1, "ri2", N_TIMEUP, minremain);
if(m_timed && smapname[0]) sendf(-1, 1, "ri2", N_TIMEUP, max((gamelimit - gamemillis)/1000, 0));
loopv(clients)
{
clientinfo *ci = clients[i];
Expand Down Expand Up @@ -1089,16 +1088,11 @@ namespace server

void checkintermission()
{
if(minremain>0)
if(gamemillis >= gamelimit && !interm)
{
minremain = gamemillis>=gamelimit ? 0 : (gamelimit - gamemillis + 60000 - 1)/60000;
sendf(-1, 1, "ri2", N_TIMEUP, minremain);
if(!minremain && smode) smode->intermission();
}
if(!interm && minremain<=0)
{
SbPy::triggerEvent("intermission_begin", 0);
interm = gamemillis+10000;
sendf(-1, 1, "ri2", N_TIMEUP, 0);
if(smode) smode->intermission();
interm = gamemillis + 10000;
}
}

Expand Down Expand Up @@ -1318,7 +1312,7 @@ namespace server
if(!gamepaused) gamemillis += curtime;

if(m_demo) readdemo();
else if(!gamepaused && minremain>0)
else if(!gamepaused && gamemillis < gamelimit)
{
processevents();
if(curtime)
Expand Down Expand Up @@ -2327,9 +2321,9 @@ namespace server

putint(p, numclients(-1, false, true));
putint(p, 5); // number of attrs following
putint(p, PROTOCOL_VERSION); // a // generic attributes, passed back below
putint(p, gamemode); // b
putint(p, minremain); // c
putint(p, PROTOCOL_VERSION); // generic attributes, passed back below
putint(p, gamemode);
putint(p, max((gamelimit - gamemillis)/1000, 0));
putint(p, maxclients);
putint(p, serverpass[0] ? MM_PASSWORD : (!m_mp(gamemode) ? MM_PRIVATE : (mastermode || mastermask&MM_AUTOAPPROVE ? mastermode : MM_AUTH)));
sendstring(smapname, p);
Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ namespace server
int len;
};

extern int gamelimit;
extern int gamemillis;
extern vector<clientinfo *> connects, clients, bots;
extern int mastermode;
Expand All @@ -353,7 +354,6 @@ namespace server
extern int gamemode;
extern bool gamepaused;
extern bool allow_modevote;
extern int minremain;
extern int port;
extern bool demonextmatch;
extern vector<demofile> demos;
Expand Down
2 changes: 1 addition & 1 deletion src/pycontrol/servermodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ static PyObject *serverPassword(PyObject *self, PyObject *args)

static PyObject *minRemain(PyObject *self, PyObject *args)
{
return Py_BuildValue("i", server::minremain);
return Py_BuildValue("i", max((server::gamelimit - server::gamemillis)/1000, 0));
}

static PyObject *setTeam(PyObject *self, PyObject *args)
Expand Down

0 comments on commit f023ab2

Please sign in to comment.