From 34588e3ba4ce368789020efaf02d55ee6fd6e116 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 11 Apr 2007 08:56:11 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@954 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 60 +------------------------ source/src/clients2c.cpp | 25 +++++++++-- source/src/cube.h | 1 - source/src/protocol.cpp | 1 + source/src/protocol.h | 1 + source/src/protos.h | 2 +- source/src/server.cpp | 93 +++++++++++++++++++++++++++++++-------- source/src/serverms.cpp | 2 +- source/src/weapon.cpp | 2 +- 9 files changed, 103 insertions(+), 84 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 09cb1f27..9c1ff1b1 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -198,64 +198,6 @@ void arenacount(playerent *d, int &alive, int &dead, char *&lastteam, char *&las } } -bool arenajoin = false; -int arenarespawnwait = 0; -int arenadetectwait = 0; - -void arenarespawn() -{ - if(!m_arena || intermission) return; - - if(arenajoin) - { - if(player1->state!=CS_DEAD) arenajoin = false; - else loopv(players) if(players[i]) arenajoin = false; - if(arenajoin) return; - } - - if(arenarespawnwait) - { - if(arenarespawnwaitstate==CS_DEAD) || (dead>0 && (alive<=1 || (m_teammode && oneteam)))) - { - conoutf("arena round is over! next round in 5 seconds..."); - if(alive) - { - if(m_botmode && player1->state==CS_DEAD) - conoutf("the bots have won the round!"); - else if(m_teammode) - conoutf("team %s has won the round", lastteam); - else - conoutf("%s is the survivor!", lastname); - } - else conoutf("everyone died!"); - arenarespawnwait = lastmillis+5000; - arenadetectwait = lastmillis+10000; - player1->roll = 0; - } - } -} - - void checkakimbo() { if(player1->akimbo && player1->akimbomillis && player1->akimbomillis<=lastmillis) @@ -317,7 +259,7 @@ void updateworld(int curtime, int lastmillis) // main game update loop checkakimbo(); checkweaponswitch(); //if(m_arena) arenarespawn(); - arenarespawn(); + //arenarespawn(); moveprojectiles((float)curtime); demoplaybackstep(); if(!demoplayback) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 4c5a5ba1..7386d931 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -1,6 +1,7 @@ // client processing of the incoming network stream #include "cube.h" +#include "bot/bot.h" extern bool c2sinit, senditemstoserver; extern string clientpassword; @@ -153,11 +154,10 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_MAPCHANGE: getstring(text, p); changemapserv(text, getint(p)); - if(joining>1 && m_arena) + if(m_arena && joining>2) { deathstate(player1); showscores(true); - arenajoin = true; } mapchanged = true; break; @@ -475,6 +475,25 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } + case SV_ARENAWIN: + { + int alive = getint(p); + getstring(text, p); + conoutf("arena round is over! next round in 5 seconds..."); + if(!alive) conoutf("everyone died!"); + else if(m_botmode && player1->state==CS_DEAD) conoutf("the bots have won the round!"); + else if(m_teammode) conoutf("team %s has won the round!", text); + else conoutf("%s is the survivor!", text); + break; + } + + case SV_ARENASPAWN: + conoutf("new round starting... fight!"); + respawnself(); + if(m_botmode) BotManager.RespawnBots(); + clearbounceents(); + break; + case SV_MASTERINFO: { loopv(players) { if(players[i]) players[i]->ismaster = false; } @@ -524,7 +543,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_FORCETEAM: { changeteam(getint(p)); - if(!m_arena || joining<=1) spawnplayer(player1); + if(!m_arena || joining<=2) spawnplayer(player1); break; } diff --git a/source/src/cube.h b/source/src/cube.h index 351f21d0..14796aec 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -85,7 +85,6 @@ extern int xtraverts; extern bool minimap, reflecting, refracting; extern bool demoplayback; extern bool intermission; -extern bool arenajoin; extern int maxclients; extern bool hasoverbright, hasmultitexture; diff --git a/source/src/protocol.cpp b/source/src/protocol.cpp index 8f658d5c..d11da2d9 100644 --- a/source/src/protocol.cpp +++ b/source/src/protocol.cpp @@ -94,6 +94,7 @@ char msgsizesl[] = // size inclusive message token, 0 for variable SV_SENDMAP, 0, SV_RECVMAP, 1, SV_SERVMSG, 0, SV_ITEMLIST, 0, SV_WEAPCHANGE, 2, SV_MODELSKIN, 2, SV_FLAGPICKUP, 2, SV_FLAGDROP, 2, SV_FLAGRETURN, 2, SV_FLAGSCORE, 2, SV_FLAGRESET, 2, SV_FLAGINFO, 0, SV_FLAGS, 2, // EDIT: AH + SV_ARENASPAWN, 0, SV_ARENAWIN, 0, SV_SETMASTER, 2, SV_SETMASTERLOGIN, 0, SV_MASTERINFO, 2, SV_MASTERCMD, 3, SV_FORCETEAM, 2, SV_AUTOTEAM, 2, SV_PWD, 0, diff --git a/source/src/protocol.h b/source/src/protocol.h index 6e9f3ddb..2fa15f01 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -18,6 +18,7 @@ enum SV_SENDMAP, SV_RECVMAP, SV_SERVMSG, SV_ITEMLIST, SV_WEAPCHANGE, SV_MODELSKIN, SV_FLAGPICKUP, SV_FLAGDROP, SV_FLAGRETURN, SV_FLAGSCORE, SV_FLAGRESET, SV_FLAGINFO, SV_FLAGS, //EDIT: AH + SV_ARENASPAWN, SV_ARENAWIN, SV_SETMASTER, SV_SETMASTERLOGIN, SV_MASTERINFO, SV_MASTERCMD, SV_FORCETEAM, SV_AUTOTEAM, SV_PWD, diff --git a/source/src/protos.h b/source/src/protos.h index bf2552f2..32721b09 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -277,7 +277,7 @@ extern void startintermission(); extern void restoreserverstate(vector &ents); extern uchar *retrieveservers(uchar *buf, int buflen); extern char msgsizelookup(int msg); -extern void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds, bool isfull); +extern void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds); extern void servermsinit(const char *master, char *sdesc, bool listen); extern bool serverpickup(uint i, int sec, int sender); diff --git a/source/src/server.cpp b/source/src/server.cpp index d52a50e0..d3f829ca 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -40,6 +40,7 @@ struct client // server side version of "dynent" type int modevote; uint pos[3]; clientscore score; + bool arenadeath; bool ismaster; bool isauthed; // for passworded servers vector position, messages; @@ -48,6 +49,7 @@ struct client // server side version of "dynent" type { name[0] = 0; score.reset(); + arenadeath = true; position.setsizenodelete(0); messages.setsizenodelete(0); ismaster = isauthed = false; @@ -85,6 +87,11 @@ int bsend = 0, brec = 0, laststatus = 0, lastsec = 0; void sendpacket(int n, int chan, ENetPacket *packet) { + if(n<0) + { + loopv(clients) sendpacket(i, chan, packet); + return; + } switch(clients[n]->type) { case ST_TCPIP: @@ -257,7 +264,6 @@ bool isdedicated; ENetHost *serverhost = NULL; void process(ENetPacket *packet, int sender, int chan); -void multicast(ENetPacket *packet, int sender, int chan); void sendf(int cn, int chan, const char *format, ...) { @@ -279,8 +285,7 @@ void sendf(int cn, int chan, const char *format, ...) } va_end(args); enet_packet_resize(packet, p.length()); - if(cn<0) multicast(packet, -1, chan); - else sendpacket(cn, chan, packet); + sendpacket(cn, chan, packet); if(packet->referenceCount==0) enet_packet_destroy(packet); } @@ -309,8 +314,7 @@ void sendflaginfo(int flag, int action, int cn = -1) if(action==SV_FLAGPICKUP || action==SV_FLAGRETURN) putint(p, f.actor_cn); else if(f.state==CTFF_DROPPED) loopi(3) putint(p, f.pos[i]); enet_packet_resize(packet, p.length()); - if(cn<0) multicast(packet, -1, 1); - else sendpacket(cn, 1, packet); + sendpacket(cn, 1, packet); if(packet->referenceCount==0) enet_packet_destroy(packet); } @@ -371,6 +375,59 @@ void ctfreset() } } +int arenaround = 0; + +void arenareset() +{ + if(!m_arena) return; + + arenaround = 0; + loopv(clients) clients[i]->arenadeath = false; + sendf(-1, 1, "ri", SV_ARENASPAWN); +} + +void arenacheck(int secs) +{ + if(!m_arena || interm || secstype==ST_LOCAL) + { + bool alive = false, dead = false; + loopv(players) if(players[i]) + { + if(players[i]->state==CS_DEAD) dead = true; + else alive = true; + } + if((dead && !alive) || clients[0]->arenadeath) + { + sendf(-1, 1, "riis", SV_ARENAWIN, alive || player1->state!=CS_DEAD ? 1 : 0, player1->state==CS_DEAD ? "" : player1->name); + arenaround = secs+5; + } + return; + } +#endif + client *alive = NULL; + bool dead = false; + loopv(clients) + { + client &c = *clients[i]; + if(c.type==ST_EMPTY) continue; + if(c.arenadeath) dead = true; + else if(!alive) alive = &c; + else if(!m_teammode || strcmp(alive->team, c.team)) return; + } + if(!dead) return; + sendf(-1, 1, "riis", SV_ARENAWIN, alive ? 1 : 0, !alive ? "" : (m_teammode ? alive->team : alive->name)); + arenaround = secs+5; +} + void sendteamtext(char *text, int sender) { if(!clients[sender]->team[0]) return; @@ -514,6 +571,7 @@ void resetmap(const char *newname, int newmode, int newtime = -1, bool notify = ctfreset(); if(notify) sendf(-1, 1, "risi", SV_MAPCHANGE, smapname, smode); if(m_teammode && !lastteammode) shuffleteams(); + arenareset(); } void nextcfgset(bool notify = true) // load next maprotation set @@ -678,7 +736,7 @@ int checktype(int type, client *cl) static int edittypes[] = { SV_EDITENT, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE }; if(cl && smode!=1) loopi(sizeof(edittypes)/sizeof(int)) if(type == edittypes[i]) return -1; // server only messages - static int servtypes[] = { SV_INITS2C, SV_MAPRELOAD, SV_SERVMSG, SV_ITEMACC, SV_ITEMSPAWN, SV_TIMEUP, SV_CDIS, SV_PONG, SV_RESUME, SV_FLAGINFO, SV_CLIENT }; + static int servtypes[] = { SV_INITS2C, SV_MAPRELOAD, SV_SERVMSG, SV_ITEMACC, SV_ITEMSPAWN, SV_TIMEUP, SV_CDIS, SV_PONG, SV_RESUME, SV_FLAGINFO, SV_ARENASPAWN, SV_ARENAWIN, SV_CLIENT }; if(cl) loopi(sizeof(servtypes)/sizeof(int)) if(type == servtypes[i]) return -1; return type; } @@ -873,6 +931,13 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 QUEUE_MSG; break; + case SV_GIBDIED: + case SV_DIED: + getint(p); + if(m_arena) cl->arenadeath = true; + QUEUE_MSG; + break; + default: { int size = msgsizelookup(type); @@ -931,15 +996,7 @@ void send_welcome(int n) enet_packet_resize(packet, p.length()); sendpacket(n, 1, packet); if(smapname[0] && m_ctf) loopi(2) sendflaginfo(i, -1, n); -} - -void multicast(ENetPacket *packet, int sender, int chan) -{ - loopv(clients) - { - if(i==sender) continue; - sendpacket(i, chan, packet); - } + if(m_arena && numcl<=2) clients[n]->arenadeath = false; } void localclienttoserver(int chan, ENetPacket *packet) @@ -1018,7 +1075,8 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal sflaginfo &f = sflaginfos[i]; if(f.state==CTFF_DROPPED && seconds-f.lastupdate>30) flagaction(i, SV_FLAGRESET, -1); } - + if(m_arena) arenacheck(seconds); + lastsec = seconds; int nonlocalclients = 0; @@ -1042,8 +1100,7 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal if(!isdedicated) return; // below is network only - int numplayers = numclients(); - serverms(smode, numplayers, minremain, smapname, seconds, numclients()>=maxclients); + serverms(smode, numclients(), minremain, smapname, seconds); if(seconds-laststatus>60) // display bandwidth stats, useful for server ops { diff --git a/source/src/serverms.cpp b/source/src/serverms.cpp index 860a4a90..08541763 100644 --- a/source/src/serverms.cpp +++ b/source/src/serverms.cpp @@ -108,7 +108,7 @@ uchar *retrieveservers(uchar *buf, int buflen) ENetSocket pongsock = ENET_SOCKET_NULL; string serverdesc; -void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds, bool isfull) +void serverms(int mode, int numplayers, int minremain, char *smapname, int seconds) { checkmasterreply(); updatemasterserver(seconds); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 3086c6ca..f03e2817 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -409,7 +409,7 @@ void renderbounceents() } } path(model); - rendermodel(model, ANIM_MAPMODEL|ANIM_LOOP, 0, 1.1f, p->o.x, p->o.y, z, p->yaw, p->pitch, 10.0f); + rendermodel(model, ANIM_MAPMODEL|ANIM_LOOP, 0, 1.1f, p->o.x, p->o.y, z, p->yaw+90, p->pitch, 10.0f); } }