From 0666067f2efad9f3a8173f86b227e4c06030dd10 Mon Sep 17 00:00:00 2001 From: sireus Date: Fri, 13 Apr 2012 11:39:11 +0000 Subject: [PATCH] more spectator cleanup (just use switchteam, and auto-kill player on server side) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6784 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 2 +- source/src/clients2c.cpp | 16 +--------------- source/src/protocol.cpp | 2 +- source/src/protocol.h | 2 +- source/src/server.cpp | 19 +------------------ source/src/server.h | 2 +- 6 files changed, 6 insertions(+), 37 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 1773b542..1c9cbc24 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1694,7 +1694,7 @@ playerent *updatefollowplayer(int shiftdirection) void spectate() { if(m_demo) return; - if(!team_isspect(player1->team)) addmsg(SV_SPECTATE, "ri", player1->clientnum); + if(!team_isspect(player1->team)) addmsg(SV_SWITCHTEAM, "ri", TEAM_SPECT); else tryrespawn(); } diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index b7ea6359..8fed1e0a 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -698,21 +698,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } - case SV_SPECTATE: - { - int cn = getint(p); - playerent *s = getclient(cn); - if(!s) break; - s->state = CS_SPECTATE; - s->team = TEAM_SPECT; - if(s == player1) - { - showscores(false); - spectatemode(SM_FLY); - } - break; - } - case SV_SHOTFX: { int scn = getint(p), gun = getint(p); @@ -1180,6 +1165,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) } else if(d->team != fnt && ftr == FTR_PLAYERWISH) conoutf(_("%s changed to active play"), you ? _("you") : colorname(d)); d->team = fnt; + if(team_isspect(d->team)) d->state = CS_SPECTATE; } break; } diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index e09c289d..8e17ba9e 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -337,7 +337,7 @@ static const int msgsizes[] = // size inclusive message token, 0 f SV_SETTEAM, 3, SV_TEAMDENY, 2, SV_SERVERMODE, 2, SV_WHOIS, 2, SV_WHOISINFO, 3, SV_LISTDEMOS, 1, SV_SENDDEMOLIST, 0, SV_GETDEMO, 2, SV_SENDDEMO, 0, SV_DEMOPLAYBACK, 3, - SV_CONNECT, 0, SV_SPECTATE, 2, + SV_CONNECT, 0, SV_SWITCHNAME, 0, SV_SWITCHSKIN, 0, SV_SWITCHTEAM, 0, SV_CLIENT, 0, SV_EXTENSION, 0, diff --git a/source/src/protocol.h b/source/src/protocol.h index 58d88a0d..6c6f8d94 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -36,7 +36,7 @@ enum SV_SETTEAM, SV_TEAMDENY, SV_SERVERMODE, SV_WHOIS, SV_WHOISINFO, SV_LISTDEMOS, SV_SENDDEMOLIST, SV_GETDEMO, SV_SENDDEMO, SV_DEMOPLAYBACK, - SV_CONNECT, SV_SPECTATE, + SV_CONNECT, SV_SWITCHNAME, SV_SWITCHSKIN, SV_SWITCHTEAM, SV_CLIENT, SV_EXTENSION, diff --git a/source/src/server.cpp b/source/src/server.cpp index 51680788..62bd3658 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1604,11 +1604,7 @@ bool updateclientteam(int cln, int newteam, int ftr) if(m_teammode && autoteam && teamsizes[newteam] > teamsizes[team_opposite(newteam)]) return false; // don't switch to an already bigger team } } - else - { - if(team_isactive(cl.team) && cl.state.state != CS_DEAD) return false; // you need to be dead to change to spectator - if(mastermode != MM_MATCH || !m_teammode) newteam = TEAM_SPECT; // only match mode (team) has more than one spect team - } + else if(mastermode != MM_MATCH || !m_teammode) newteam = TEAM_SPECT; // only match mode (team) has more than one spect team } if(cl.team == newteam && ftr != FTR_AUTOTEAM) return true; // no change if(cl.team != newteam) sdropflag(cl.clientnum); @@ -3030,19 +3026,6 @@ void process(ENetPacket *packet, int sender, int chan) break; } - case SV_SPECTATE: - { - getint(p); // clientnum - if(team_isspect(cl->team)) break; - - if(cl->state.state == CS_ALIVE) serverdamage(cl, cl, INT_MAX, GUN_KNIFE, false); // suicide if alive - cl->state.state = CS_SPECTATE; - cl->team = TEAM_SPECT; - - sendf(-1, 1, "rii", SV_SPECTATE, cl->clientnum); - break; - } - case SV_SUICIDE: { gameevent &suicide = cl->addevent(); diff --git a/source/src/server.h b/source/src/server.h index fcaba6f8..0546fdf6 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -432,7 +432,7 @@ const char *messagenames[SV_NUM] = "SV_SETTEAM", "SV_TEAMDENY", "SV_SERVERMODE", "SV_WHOIS", "SV_WHOISINFO", "SV_LISTDEMOS", "SV_SENDDEMOLIST", "SV_GETDEMO", "SV_SENDDEMO", "SV_DEMOPLAYBACK", - "SV_CONNECT", "SV_SPECTATE", + "SV_CONNECT", "SV_SWITCHNAME", "SV_SWITCHSKIN", "SV_SWITCHTEAM", "SV_CLIENT", "SV_EXTENSION",