From 7f33bb0da14107cf0fc184b73aaaed6713ba6227 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Thu, 18 Sep 2008 16:59:21 +0000 Subject: [PATCH] lastmillis -> totalmillis git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2691 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 20 ++++++++++---------- source/src/clientgame.cpp | 10 +++++----- source/src/clients2c.cpp | 8 ++++---- source/src/console.cpp | 4 ++-- source/src/rendergl.cpp | 4 ++-- source/src/renderhud.cpp | 10 +++++----- source/src/worldio.cpp | 5 +++-- 7 files changed, 31 insertions(+), 30 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index b1bd3255..d26738bc 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -99,7 +99,7 @@ void connects(char *servername, char *serverport, char *password) { connpeer = enet_host_connect(clienthost, &address, 3); enet_host_flush(clienthost); - connmillis = lastmillis; + connmillis = totalmillis; connattempts = 0; if(!m_mp(gamemode)) gamemode = GMODE_TEAMDEATHMATCH; } @@ -131,7 +131,7 @@ void disconnect(int onlyclean, int async) { enet_peer_disconnect(curpeer, DISC_NONE); enet_host_flush(clienthost); - discmillis = lastmillis; + discmillis = totalmillis; } if(curpeer->state!=ENET_PEER_STATE_DISCONNECTED) { @@ -266,7 +266,7 @@ extern string masterpwd; void c2sinfo(playerent *d) // send update to the server { if(d->clientnum<0) return; // we haven't had a welcome message from the server yet - if(lastmillis-lastupdate<40) return; // don't update faster than 25fps + if(totalmillis-lastupdate<40) return; // don't update faster than 25fps if(d->state==CS_ALIVE || d->state==CS_EDITING) { @@ -291,7 +291,7 @@ void c2sinfo(playerent *d) // send update to the server sendpackettoserv(0, packet); } - if(senditemstoserver || !c2sinit || messages.length() || lastmillis-lastping>250) + if(senditemstoserver || !c2sinit || messages.length() || totalmillis-lastping>250) { ENetPacket *packet = enet_packet_create (NULL, MAXTRANS, 0); ucharbuf p(packet->data, packet->dataLength); @@ -333,11 +333,11 @@ void c2sinfo(playerent *d) // send update to the server i += 2 + len; } messages.remove(0, i); - if(lastmillis-lastping>250) + if(totalmillis-lastping>250) { putint(p, SV_PING); - putint(p, lastmillis); - lastping = lastmillis; + putint(p, totalmillis); + lastping = totalmillis; } if(!p.length()) enet_packet_destroy(packet); else @@ -348,7 +348,7 @@ void c2sinfo(playerent *d) // send update to the server } if(clienthost) enet_host_flush(clienthost); - lastupdate = lastmillis; + lastupdate = totalmillis; } void sendintro() @@ -368,10 +368,10 @@ void gets2c() // get updates from the server { ENetEvent event; if(!clienthost) return; - if(connpeer && lastmillis/3000 > connmillis/3000) + if(connpeer && totalmillis/3000 > connmillis/3000) { conoutf("attempting to connect..."); - connmillis = lastmillis; + connmillis = totalmillis; ++connattempts; if(connattempts > 3) { diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 34971ae1..5bc9b217 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -173,7 +173,7 @@ void spawnstate(playerent *d) // reset player state not persistent playerent *newplayerent() // create a new blank player { playerent *d = new playerent; - d->lastupdate = lastmillis; + d->lastupdate = totalmillis; setskin(d, rnd(6)); weapon::equipplayer(d); // flowtron : avoid overwriting d->spawnstate(gamemode) stuff from the following line (this used to be called afterwards) spawnstate(d); @@ -183,7 +183,7 @@ playerent *newplayerent() // create a new blank player botent *newbotent() // create a new blank player { botent *d = new botent; - d->lastupdate = lastmillis; + d->lastupdate = totalmillis; setskin(d, rnd(6)); spawnstate(d); weapon::equipplayer(d); @@ -260,7 +260,7 @@ void moveotherplayers() loopv(players) if(players[i] && players[i]->type==ENT_PLAYER) { playerent *d = players[i]; - const int lagtime = lastmillis-d->lastupdate; + const int lagtime = totalmillis-d->lastupdate; if(!lagtime || intermission) continue; else if(lagtime>1000 && d->state==CS_ALIVE) { @@ -806,7 +806,7 @@ votedisplayinfo *newvotedisplayinfo(playerent *owner, int type, char *arg1, char votedisplayinfo *v = new votedisplayinfo(); v->owner = owner; v->type = type; - v->millis = lastmillis + (30+10)*1000; + v->millis = totalmillis + (30+10)*1000; char *votedesc = votestring(type, arg1, arg2); s_strcpy(v->desc, votedesc); DELETEA(votedesc); @@ -910,7 +910,7 @@ void voteresult(int v) if(curvote && v >= 0 && v < VOTE_NUM) { curvote->result = v; - curvote->millis = lastmillis + 5000; + curvote->millis = totalmillis + 5000; conoutf("vote %s", v == VOTE_YES ? "passed" : "failed"); if(multiplayer(false)) playsound(v == VOTE_YES ? S_VOTEPASS : S_VOTEFAIL, SP_HIGH); } diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index af294b15..eeb397c9 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -48,11 +48,11 @@ void updatepos(playerent *d) void updatelagtime(playerent *d) { - int lagtime = lastmillis-d->lastupdate; + int lagtime = totalmillis-d->lastupdate; if(lagtime) { if(d->state!=CS_SPAWNING && d->lastupdate) d->plag = (d->plag*5+lagtime)/6; - d->lastupdate = lastmillis; + d->lastupdate = totalmillis; } } @@ -507,7 +507,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_PONG: { int millis = getint(p); - addmsg(SV_CLIENTPING, "i", player1->ping = max(0, (player1->ping*5+lastmillis-millis)/6)); + addmsg(SV_CLIENTPING, "i", player1->ping = max(0, (player1->ping*5+totalmillis-millis)/6)); break; } @@ -760,7 +760,7 @@ void receivefile(uchar *data, int len) case SV_SENDDEMO: { systemtime(); - s_sprintfd(fname)("demos/%d.dmo", now_utc); //lastmillis); + s_sprintfd(fname)("demos/%d.dmo", now_utc); //totalmillis); path(fname); FILE *demo = openfile(fname, "wb"); if(!demo) diff --git a/source/src/console.cpp b/source/src/console.cpp index 0a242807..c01faac9 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -22,7 +22,7 @@ struct console : consolebuffer int fullconsole; void toggleconsole() { fullconsole = ++fullconsole % 3; } - void addline(const char *sf, bool highlight) { consolebuffer::addline(sf, highlight, lastmillis); } + void addline(const char *sf, bool highlight) { consolebuffer::addline(sf, highlight, totalmillis); } vector visible; @@ -39,7 +39,7 @@ struct console : consolebuffer else if(consize) { visible.setsizenodelete(0); - loopv(conlines) if(conskip ? i>=conskip-1 || i>=conlines.length()-consize : (!confade || lastmillis-conlines[i].millis=conskip-1 || i>=conlines.length()-consize : (!confade || totalmillis-conlines[i].millis=consize) break; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index e781d36e..85282c32 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -379,7 +379,7 @@ void fixresizedscreen() static int lastcheck = 0; #define screenproc(n,t) n##ess32##t #define px_datprop(scr, t) ((scr).szExe##F##t) - if((lastcheck!=0 && lastmillis-lastcheck<3000)) return; + if((lastcheck!=0 && totalmillis-lastcheck<3000)) return; #define get_screenproc screenproc(Proc, First) #define next_screenproc screenproc(Proc, Next) @@ -397,7 +397,7 @@ void fixresizedscreen() memcpy(&pxfixed[0], &pxfixed[1], 1); } } - lastcheck = lastmillis; + lastcheck = totalmillis; CloseHandle(screen); #endif } diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 33ce9e37..9f62a2d7 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -261,11 +261,11 @@ void drawradarent(float x, float y, float yaw, int col, int row, float iconsize, struct hudmessages : consolebuffer { - void addline(const char *sf) { consolebuffer::addline(sf, false, lastmillis); } + void addline(const char *sf) { consolebuffer::addline(sf, false, totalmillis); } void editlastline(const char *sf) { if(!conlines.length()) return; - conlines[0].millis = lastmillis; + conlines[0].millis = totalmillis; s_strcpy(conlines[0].cref, sf); } void render() @@ -274,11 +274,11 @@ struct hudmessages : consolebuffer glLoadIdentity(); glOrtho(0, VIRTW*0.8f, VIRTH*0.8f, 0, -1, 1); int dispmillis = arenaintermission ? 6000 : 3000; - loopi(min(conlines.length(), 3)) if(lastmillis-conlines[i].millis VIRTW*0.8f ? 0 : (VIRTW*0.8f-tw)/2), int(((VIRTH*0.8f)/4*3)+FONTH*i+pow((lastmillis-c.millis)/(float)dispmillis, 4)*VIRTH*0.8f/4.0f)); + draw_text(c.cref, int(tw > VIRTW*0.8f ? 0 : (VIRTW*0.8f-tw)/2), int(((VIRTH*0.8f)/4*3)+FONTH*i+pow((totalmillis-c.millis)/(float)dispmillis, 4)*VIRTH*0.8f/4.0f)); } } }; @@ -490,7 +490,7 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat { extern votedisplayinfo *curvote; - if(curvote && curvote->millis >= lastmillis) + if(curvote && curvote->millis >= totalmillis) { const int left = 20*2, top = VIRTH; draw_textf("%s called a vote:", left, top+240, curvote->owner ? colorname(curvote->owner) : ""); diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 345cc1b1..40df74fe 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -29,7 +29,7 @@ void setnames(char *name) } systemtime(); s_sprintf(cgzname)("packages/%s/%s.cgz", pakname, mapname); - s_sprintf(bakname)("packages/%s/%s_%d.BAK", pakname, mapname, now_utc); //lastmillis); + s_sprintf(bakname)("packages/%s/%s_%d.BAK", pakname, mapname, now_utc); //totalmillis); s_sprintf(pcfname)("packages/%s/package.cfg", pakname); s_sprintf(mcfname)("packages/%s/%s.cfg", pakname, mapname); @@ -265,6 +265,7 @@ int numspawn[3], maploaded = 0, numflagspawn[2]; bool load_world(char *mname) // still supports all map formats that have existed since the earliest cube betas! { + int loadmillis = SDL_GetTicks(); preparectf(true); cleardynlights(); pruneundos(); @@ -419,7 +420,7 @@ bool load_world(char *mname) // still supports all map formats that have gzclose(f); c2skeepalive(); calclight(); - conoutf("read map %s (%d milliseconds)", cgzname, SDL_GetTicks()-lastmillis); + conoutf("read map %s (%d milliseconds)", cgzname, SDL_GetTicks()-loadmillis); conoutf("%s", hdr.maptitle); startmap(mname);