From 4dd4b46f2a0340c812fa11bfffc46372bbcfa948 Mon Sep 17 00:00:00 2001 From: ac_stef Date: Mon, 15 Sep 2008 15:06:54 +0000 Subject: [PATCH] ktf cleanup; demo playback fixes git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2628 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 10 +++++----- source/src/clients2c.cpp | 4 ++-- source/src/entities.cpp | 8 ++++---- source/src/protocol.h | 5 ++--- source/src/renderhud.cpp | 10 +++++----- source/src/scoreboard.cpp | 8 +++++--- source/src/server.cpp | 13 +++++++------ 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 6ffad527..f3f077ce 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -386,7 +386,7 @@ void findplayerstart(playerent *d, bool mapcenter, int arenaspawn) loopi(arenaspawn + 1) x = findentity(PLAYERSTART, x+1, type); if(x >= 0) e = &ents[x]; } - else if((m_teammode || m_arena) && !(m_ktf || m_tktf)) // ktf uses ffa spawns + else if((m_teammode || m_arena) && !m_ktf) // ktf uses ffa spawns { loopi(r) spawncycle = findentity(PLAYERSTART, spawncycle+1, type); if(spawncycle >= 0) e = &ents[spawncycle]; @@ -397,7 +397,7 @@ void findplayerstart(playerent *d, bool mapcenter, int arenaspawn) loopi(r) { - spawncycle = (m_ktf || m_tktf) && numspawn[2] > 5 ? findentity(PLAYERSTART, spawncycle+1, 100) : findentity(PLAYERSTART, spawncycle+1); + spawncycle = m_ktf && numspawn[2] > 5 ? findentity(PLAYERSTART, spawncycle+1, 100) : findentity(PLAYERSTART, spawncycle+1); if(spawncycle < 0) continue; float dist = nearestenemy(vec(ents[spawncycle].x, ents[spawncycle].y, ents[spawncycle].z), d->team); if(!e || dist < 0 || (bestdist >= 0 && dist > bestdist)) { e = &ents[spawncycle]; bestdist = dist; } @@ -605,7 +605,7 @@ void preparectf(bool cleanonly=false) f.actor = NULL; f.actor_cn = -1; f.team = i; - f.state = m_ktf || m_tktf ? CTFF_IDLE : CTFF_INBASE; + f.state = m_ktf ? CTFF_IDLE : CTFF_INBASE; } loopv(ents) { @@ -654,7 +654,7 @@ void startmap(const char *name) // called just after a map load showscores(false); intermission = false; minutesremaining = -1; - bool noflags = (m_ctf || m_ktf || m_tktf) && (!numflagspawn[0] || !numflagspawn[1]); + bool noflags = (m_ctf || m_ktf) && (!numflagspawn[0] || !numflagspawn[1]); if(*clientmap) conoutf("game mode is \"%s\"%s", modestr(gamemode, modeacronyms > 0), noflags ? " - \f2but there are no flag bases on this map" : ""); // run once @@ -693,7 +693,7 @@ void flagmsg(int flag, int message, int actor, int flagtime) bool own = flag == team_int(player1->team); bool firstperson = actor == getclientnum(); bool teammate = !act ? true : isteam(player1->team, act->team); - const char *teamstr = m_ktf || m_tktf ? "the" : own ? "your" : "the enemy"; + const char *teamstr = m_ktf ? "the" : own ? "your" : "the enemy"; switch(message) { diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 749effc8..af294b15 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -627,11 +627,11 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_FORCETEAM: { - int team = getint(p); + int team = getint(p), oldteam = team_int(player1->team); int attr = getint(p); bool respawn = (attr & 1) == 1; changeteam(team, respawn); - if(attr & 2) hudoutf("you got forced to team %s", team_string(team)); + if(attr & 2) hudoutf("you %s team %s", team == oldteam ? "stay in" : "got forced to", team_string(team)); break; } diff --git a/source/src/entities.cpp b/source/src/entities.cpp index d0e84494..3ee14839 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -36,7 +36,7 @@ void renderentities() static int lastsparkle = 0; if(lastmillis - lastsparkle >= 20) { - lastsparkle = lastmillis - (lastmillis%20); + lastsparkle = lastmillis - (lastmillis%20); loopv(ents) { entity &e = ents[i]; @@ -72,7 +72,7 @@ void renderentities() case CTFF_STOLEN: if(f.actor && f.actor != player1) { - s_sprintfd(path)("pickups/flags/small_%s%s", m_ktf || m_tktf ? "" : team_string(i), m_htf ? "_htf" : m_ktf || m_tktf ? "ktf" : ""); + s_sprintfd(path)("pickups/flags/small_%s%s", m_ktf ? "" : team_string(i), m_htf ? "_htf" : m_ktf ? "ktf" : ""); rendermodel(path, ANIM_FLAG|ANIM_START|ANIM_DYNALLOC, 0, 0, vec(f.actor->o).add(vec(0, 0, 0.3f+(sinf(lastmillis/100.0f)+1)/10)), lastmillis/2.5f, 0, 120.0f); } break; @@ -81,7 +81,7 @@ void renderentities() case CTFF_DROPPED: { entity &e = *f.flagent; - s_sprintfd(path)("pickups/flags/%s%s", m_ktf || m_tktf ? "" : team_string(i), m_htf ? "_htf" : m_ktf || m_tktf ? "ktf" : ""); + s_sprintfd(path)("pickups/flags/%s%s", m_ktf ? "" : team_string(i), m_htf ? "_htf" : m_ktf ? "ktf" : ""); rendermodel(path, ANIM_FLAG|ANIM_LOOP, 0, 0, vec(e.x, e.y, f.state==CTFF_INBASE ? (float)S(e.x, e.y)->floor : e.z), (float)((e.attr1+7)-(e.attr1+7)%15), 0, 120.0f); break; } @@ -171,7 +171,7 @@ void trypickupflag(int flag, playerent *d) if(f.state == CTFF_DROPPED) flagscore(f.team); // may not count! } } - else if(m_ktf || m_tktf) + else if(m_ktf) { if(f.state != CTFF_INBASE) return; flagpickup(flag); diff --git a/source/src/protocol.h b/source/src/protocol.h index c9a9b2a5..5ac02ee5 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -87,8 +87,7 @@ enum #define m_lss (gamemode==9) #define m_osok (gamemode>=10 && gamemode<=12) #define m_htf (gamemode==13) -#define m_tktf (gamemode==14) -#define m_ktf (gamemode==15) +#define m_ktf (gamemode==14 || gamemode==15) #define m_noitems (m_lms || m_osok) #define m_noitemsnade (m_lss) @@ -102,4 +101,4 @@ enum #define m_valid(mode) (((mode)>=0 && (mode)<=15) || (mode) == -3) #define m_mp(mode) (m_valid(mode) && (mode)!=7 && (mode)!=8 && (mode)!=12) #define m_demo (gamemode==-3) -#define m_flags (m_ctf || m_htf || m_ktf || m_tktf) +#define m_flags (m_ctf || m_htf || m_ktf) diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 3588c5e6..33ce9e37 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -42,7 +42,7 @@ void drawctficon(float x, float y, float s, int col, int row, float ts) { if(htftex) drawicon(htftex, x, y, s, col, row, ts); } - else if(m_ktf || m_tktf) + else if(m_ktf) { if(ktftex) drawicon(ktftex, x, y, s, col, row, ts); } @@ -379,16 +379,16 @@ void drawradar(playerent *p, int w, int h) entity *e = f.flagent; if(!e) continue; float yaw = showmap ? 0 : p->yaw; - if((m_ktf || m_tktf) && f.state == CTFF_IDLE) continue; + if(m_ktf && f.state == CTFF_IDLE) continue; if(f.state==CTFF_STOLEN) { bool tm = i != team_int(p->team); if(m_htf) tm = !tm; - else if(m_ktf || m_tktf) tm = true; + else if(m_ktf) tm = true; if(f.actor && tm && insideradar(centerpos, res/2, f.actor->o)) - drawradarent(f.actor->o.x*coordtrans+iconsize/2, f.actor->o.y*coordtrans+iconsize/2, yaw, 3, m_ktf || m_tktf ? 2 : f.team, iconsize, true); // draw near flag thief + drawradarent(f.actor->o.x*coordtrans+iconsize/2, f.actor->o.y*coordtrans+iconsize/2, yaw, 3, m_ktf ? 2 : f.team, iconsize, true); // draw near flag thief } - else if(insideradar(centerpos, res/2, vec(e->x, e->y, centerpos.z))) drawradarent(e->x*coordtrans, e->y*coordtrans, yaw, 3, m_ktf || m_tktf ? 2 : f.team, iconsize, false); // draw on entitiy pos + else if(insideradar(centerpos, res/2, vec(e->x, e->y, centerpos.z))) drawradarent(e->x*coordtrans, e->y*coordtrans, yaw, 3, m_ktf ? 2 : f.team, iconsize, false); // draw on entitiy pos } } diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 4a25c98b..df41bfb0 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -115,6 +115,8 @@ void renderteamscore(void *menu, teamscore *t) loopv(t->teammembers) renderscore(menu, t->teammembers[i]); } +extern bool watchingdemo; + void renderscores(void *menu, bool init) { static string modeline, serverline; @@ -124,7 +126,7 @@ void renderscores(void *menu, bool init) scorelines.setsize(0); vector scores; - scores.add(player1); + if(!watchingdemo) scores.add(player1); loopv(players) if(players[i]) scores.add(players[i]); scores.sort(scorecmp); @@ -166,7 +168,7 @@ void renderscores(void *menu, bool init) if(!players[i]) continue; teamscores[team_int(players[i]->team)].addscore(players[i]); } - teamscores[team_int(player1->team)].addscore(player1); + if(!watchingdemo) teamscores[team_int(player1->team)].addscore(player1); loopi(2) teamscores[i].teammembers.sort(scorecmp); int sort = teamscorecmp(&teamscores[TEAM_CLA], &teamscores[TEAM_RVSF]); @@ -196,7 +198,7 @@ void consolescores() scoreratio sr; vector scores; - scores.add(player1); + if(!watchingdemo) scores.add(player1); loopv(players) if(players[i]) scores.add(players[i]); scores.sort(scorecmp); diff --git a/source/src/server.cpp b/source/src/server.cpp index 8cabcdd1..a1534f4f 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -742,6 +742,7 @@ void enddemoplayback() sendpacket(clients[i]->clientnum, 1, packet); if(!packet->referenceCount) enet_packet_destroy(packet); } + interm = gamemillis - 1; } void setupdemoplayback() @@ -915,7 +916,7 @@ void flagaction(int flag, int action, int actor) break; } } - else if(m_ktf || m_tktf) // f: active flag, of: idle flag + else if(m_ktf) // f: active flag, of: idle flag { switch(action) { @@ -1006,7 +1007,7 @@ void flagaction(int flag, int action, int actor) void ctfreset() { - int idleflag = m_ktf || m_tktf ? rnd(2) : -1; + int idleflag = m_ktf ? rnd(2) : -1; loopi(2) { sflaginfos[i].actor_cn = -1; @@ -1326,7 +1327,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib, logger->writeline(log::info, "[%s] %s suicided", actor->hostname, actor->name); } sendf(-1, 1, "ri4", gib ? SV_GIBDIED : SV_DIED, target->clientnum, actor->clientnum, actor->state.frags); - if((suic || tk) && (m_htf || m_ktf || m_tktf) && targethasflag >= 0) + if((suic || tk) && (m_htf || m_ktf) && targethasflag >= 0) { actor->state.flagscore--; sendf(-1, 1, "riii", SV_FLAGCNT, actor->clientnum, actor->state.flagscore); @@ -1818,7 +1819,7 @@ void resetmap(const char *newname, int newmode, int newtime, bool notify) demonextmatch = false; setupdemorecord(); } - if(m_ktf || m_tktf) { sendflaginfo(0); sendflaginfo(1); } + if(m_ktf) { sendflaginfo(0); sendflaginfo(1); } } void nextcfgset(bool notify = true) // load next maprotation set @@ -2921,13 +2922,13 @@ void serverslice(uint timeout) // main server update, called from cube main lo { htf_forceflag(i); } - if((m_ktf || m_tktf) && f.state == CTFF_STOLEN && gamemillis-f.lastupdate > 15000) + if(m_ktf && f.state == CTFF_STOLEN && gamemillis-f.lastupdate > 15000) { flagaction(i, FA_SCORE, -1); } if(f.state == CTFF_INBASE || f.state == CTFF_STOLEN) ktfflagingame = true; } - if((m_ktf || m_tktf) && !ktfflagingame) flagaction(rnd(2), FA_RESET, -1); // ktf flag watchdog + if(m_ktf && !ktfflagingame) flagaction(rnd(2), FA_RESET, -1); // ktf flag watchdog if(m_arena) arenacheck(); }