diff --git a/src/game/client.cc b/src/game/client.cc index 60d41d7..5b064f6 100644 --- a/src/game/client.cc +++ b/src/game/client.cc @@ -42,8 +42,6 @@ namespace game cmode = NULL; } - int lastping = 0; - bool connected = false, remote = false; int sessionid = 0; string servdesc = "", servauth = ""; @@ -229,12 +227,6 @@ namespace game messagereliable = false; messagecn = -1; } - if(totalmillis-lastping>250) - { - putint(p, N_PING); - putint(p, totalmillis); - lastping = totalmillis; - } sendclientpacket(p.finalize(), 1); } @@ -308,27 +300,6 @@ namespace game changemapserv(text, 0); break; - case N_INITCLIENT: // another client either connected or changed name/team - { - int cn = getint(p); - gameent *d = newclient(cn); - if(!d) - { - getstring(text, p); - getstring(text, p); - getint(p); - getint(p); - break; - } - getstring(text, p); - filtertext(text, text, false, false, MAXNAMELEN); - if(!text[0]) copystring(text, "unnamed"); - copystring(d->name, text, MAXNAMELEN+1); - d->playermodel = 0; - d->playercolor = 0; - break; - } - case N_CDIS: clientdisconnected(getint(p)); break; @@ -347,51 +318,6 @@ namespace game break; } - case N_SPAWNSTATE: - { - int scn = getint(p); - gameent *s = getclient(scn); - if(!s) { parsestate(NULL, p); break; } - if(s==player1) - { - if(editmode) toggleedit(); - } - s->respawn(); - parsestate(s, p); - s->state = CS_ALIVE; - if(cmode) cmode->pickspawn(s); - else findplayerspawn(s, -1, 0); - if(s == player1) - { - lasthit = 0; - } - if(cmode) cmode->respawned(s); - checkfollow(); - addmsg(N_SPAWN, "rci", s, s->lifesequence); - break; - } - - case N_RESUME: - { - for(;;) - { - int cn = getint(p); - if(p.overread() || cn<0) break; - gameent *d = (cn == player1->clientnum ? player1 : newclient(cn)); - parsestate(d, p, true); - } - break; - } - - case N_PONG: - addmsg(N_CLIENTPING, "i", player1->ping = (player1->ping*5+totalmillis-getint(p))/6); - break; - - case N_CLIENTPING: - if(!d) return; - d->ping = getint(p); - break; - case N_NEWMAP: { int size = getint(p); diff --git a/src/game/game.hh b/src/game/game.hh index 092a34a..367bf36 100644 --- a/src/game/game.hh +++ b/src/game/game.hh @@ -99,24 +99,20 @@ enum enum { - N_CONNECT = 0, N_SERVINFO, N_WELCOME, N_INITCLIENT, N_CDIS, - N_TRYSPAWN, N_SPAWNSTATE, N_SPAWN, + N_CONNECT = 0, N_SERVINFO, N_WELCOME, N_CDIS, + N_SPAWN, N_MAPCHANGE, - N_PING, N_PONG, N_CLIENTPING, N_NEWMAP, - N_RESUME, N_CLIENT, NUMMSG }; static const int msgsizes[] = // size inclusive message token, 0 for variable or not-checked sizes { - N_CONNECT, 0, N_SERVINFO, 0, N_WELCOME, 1, N_INITCLIENT, 0, N_CDIS, 2, - N_TRYSPAWN, 1, N_SPAWNSTATE, 8, N_SPAWN, 2, + N_CONNECT, 0, N_SERVINFO, 0, N_WELCOME, 1, N_CDIS, 2, + N_SPAWN, 2, N_MAPCHANGE, 0, - N_PING, 2, N_PONG, 2, N_CLIENTPING, 2, N_NEWMAP, 2, - N_RESUME, 0, N_CLIENT, 0, -1 }; diff --git a/src/game/server.cc b/src/game/server.cc index 77cca71..35910d4 100644 --- a/src/game/server.cc +++ b/src/game/server.cc @@ -63,7 +63,6 @@ namespace server vector messages; uchar *wsdata; int wslen; - int ping; string clientmap; bool warned; @@ -89,7 +88,6 @@ namespace server name[0] = 0; connected = local = false; messages.setsize(0); - ping = 0; mapchange(); } }; @@ -305,15 +303,6 @@ namespace server gs.lifesequence = (gs.lifesequence + 1)&0x7F; } - void sendspawn(clientinfo *ci) - { - servstate &gs = ci->state; - spawnstate(ci); - sendf(ci->ownernum, 1, "rii4", N_SPAWNSTATE, ci->clientnum, gs.lifesequence, - 1, 1); - gs.lastspawn = gamemillis; - } - void sendwelcome(clientinfo *ci) { packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); @@ -321,24 +310,6 @@ namespace server sendpacket(ci->clientnum, chan, p.finalize()); } - void putinitclient(clientinfo *ci, packetbuf &p) - { - putint(p, N_INITCLIENT); - putint(p, ci->clientnum); - sendstring(ci->name, p); - } - - void welcomeinitclient(packetbuf &p, int exclude = -1) - { - loopv(clients) - { - clientinfo *ci = clients[i]; - if(!ci->connected || ci->clientnum == exclude) continue; - - putinitclient(ci, p); - } - } - bool hasmap(clientinfo *ci) { return true; @@ -349,30 +320,9 @@ namespace server putint(p, N_WELCOME); putint(p, N_MAPCHANGE); sendstring(smapname, p); - if(!ci || clients.length()>1) - { - putint(p, N_RESUME); - loopv(clients) - { - clientinfo *oi = clients[i]; - if(ci && oi->clientnum==ci->clientnum) continue; - putint(p, oi->clientnum); - putint(p, oi->state.state); - sendstate(oi->state, p); - } - putint(p, -1); - welcomeinitclient(p, ci ? ci->clientnum : -1); - } return 1; } - void sendinitclient(clientinfo *ci) - { - packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); - putinitclient(ci, p); - sendpacket(-1, 1, p.finalize(), ci->clientnum); - } - void changemap(const char *s, int mode) { gamemillis = 0; @@ -494,7 +444,6 @@ namespace server ci->state.lasttimeplayed = lastmillis; sendwelcome(ci); - sendinitclient(ci); } void parsepacket(int sender, int chan, packetbuf &p) // has to parse exactly each byte of the packet @@ -519,10 +468,6 @@ namespace server break; } - case N_PING: - getint(p); - break; - default: disconnect_client(sender, DISC_MSGERR); return; @@ -551,11 +496,6 @@ namespace server int curmsg; while((curmsg = p.length()) < p.maxlen) switch(type = checktype(getint(p), ci)) { - case N_TRYSPAWN: - if(!ci || !cq || cq->state.state!=CS_DEAD || cq->state.lastspawn>=0) break; - sendspawn(cq); - break; - case N_SPAWN: { int ls = getint(p); @@ -570,21 +510,6 @@ namespace server break; } - case N_PING: - sendf(sender, 1, "i2", N_PONG, getint(p)); - break; - - case N_CLIENTPING: - { - int ping = getint(p); - if(ci) - { - ci->ping = ping; - } - QUEUE_MSG; - break; - } - case N_NEWMAP: { int size = getint(p);