From ed5b32bf6b3265f7c252cc3b3b73519d9a22d154 Mon Sep 17 00:00:00 2001 From: ac_stef Date: Sat, 6 Sep 2008 09:40:34 +0000 Subject: [PATCH] improved htf on maps without flag spawns git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2487 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 6 +++++- source/src/clients2c.cpp | 2 +- source/src/cube.h | 2 +- source/src/server.cpp | 27 ++++++++++++++++----------- source/src/worldio.cpp | 4 +++- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index 4ebc1014..f6d7e2b8 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -316,7 +316,11 @@ void c2sinfo(playerent *d) // send update to the server } putint(p, SV_SPAWNLIST); putint(p, maploaded); - if(maploaded > 0) loopi(3) putint(p, numspawn[i]); + if(maploaded > 0) + { + loopi(3) putint(p, numspawn[i]); + loopi(2) putint(p, numflagspawn[i]); + } senditemstoserver = false; } int i = 0; diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 08b0a652..32f6b833 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -235,7 +235,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_SPAWNLIST: { - if(getint(p) > 0) loopi(3) getint(p); + if(getint(p) > 0) loopi(5) getint(p); break; } diff --git a/source/src/cube.h b/source/src/cube.h index 05ce09cb..44c37c84 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -44,7 +44,7 @@ extern int maxclients; extern hashtable mapinfo; extern bool hasTE, hasMT, hasMDA; extern int hwtexsize; -extern int numspawn[3], maploaded; +extern int numspawn[3], maploaded, numflagspawn[2]; extern int verbose; #include "protos.h" // external function decls diff --git a/source/src/server.cpp b/source/src/server.cpp index ed1d2671..9ba1fbf5 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -459,7 +459,7 @@ struct server_entity // server side version of "entity" type vector sents; bool notgotitems = true; // true when map has changed and waiting for clients to send item -int clnumspawn[3]; +int clnumspawn[3], clnumflagspawn[2]; // allows the gamemode macros to work with the server mode #define gamemode smode @@ -1682,6 +1682,7 @@ void resetmap(const char *newname, int newmode, int newtime, bool notify) resetvotes(); resetitems(); loopi(3) clnumspawn[i] = 0; + loopi(2) clnumflagspawn[i] = 0; scores.setsize(0); ctfreset(); if(notify) @@ -2337,7 +2338,11 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 case SV_SPAWNLIST: { - if(getint(p) > 0) loopi(3) clnumspawn[i] = getint(p); + if(getint(p) > 0) + { + loopi(3) clnumspawn[i] = getint(p); + loopi(2) clnumflagspawn[i] = getint(p); + } QUEUE_MSG; break; } @@ -2777,15 +2782,15 @@ void serverslice(uint timeout) // main server update, called from cube main lo if(m_flags) loopi(2) { sflaginfo &f = sflaginfos[i]; - if(f.state == CTFF_DROPPED && gamemillis-f.lastupdate > (m_ctf ? 30000 : 10000)) flagaction(i, SV_FLAGRESET, -1); - if(m_htf && f.state == CTFF_INBASE && gamemillis-f.lastupdate > 10000) - { - htf_forceflag(i); - } - if(m_ktf && f.state == CTFF_STOLEN && gamemillis-f.lastupdate > 15000) - { - flagaction(i, SV_FLAGSCORE, f.actor_cn); - } + if(f.state == CTFF_DROPPED && gamemillis-f.lastupdate > (m_ctf ? 30000 : 10000)) flagaction(i, SV_FLAGRESET, -1); + if(m_htf && f.state == CTFF_INBASE && gamemillis-f.lastupdate > (clnumflagspawn[0] && clnumflagspawn[1] ? 10000 : 1000)) + { + htf_forceflag(i); + } + if(m_ktf && f.state == CTFF_STOLEN && gamemillis-f.lastupdate > 15000) + { + flagaction(i, SV_FLAGSCORE, f.actor_cn); + } } if(m_arena) arenacheck(); } diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 92ff9313..6d2932be 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -257,7 +257,7 @@ void save_world(char *mname) } extern void preparectf(bool cleanonly = false); -int numspawn[3], maploaded = 0; +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! { @@ -287,6 +287,7 @@ bool load_world(char *mname) // still supports all map formats that have } ents.setsize(0); loopi(3) numspawn[i] = 0; + loopi(2) numflagspawn[i] = 0; loopi(hdr.numents) { entity &e = ents.add(); @@ -342,6 +343,7 @@ bool load_world(char *mname) // still supports all map formats that have else numspawn[e.attr2]++; } + if(e.type == CTF_FLAG && (e.attr2 == 0 || e.attr2 == 1)) numflagspawn[e.attr2]++; } delete[] world; setupworld(hdr.sfactor);