From 19e4aff2dc1300875d514af2afe87953bdb09470 Mon Sep 17 00:00:00 2001 From: "lucas.gautheron" Date: Mon, 5 Jan 2015 14:49:37 +0100 Subject: [PATCH] Force respawn automatically in DM/TDM, PF and HTF in mastermode MATCH --- source/src/protocol.h | 1 + source/src/server.cpp | 18 ++++++++++++++++++ source/src/server.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/source/src/protocol.h b/source/src/protocol.h index 9e4863b9..b489304c 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -126,6 +126,7 @@ enum #define m_noprimary (m_pistol || m_lss) #define m_noguns (m_nopistol && m_noprimary) #define m_arena (m_lms || m_lss || m_osok) +#define m_autospawn (gamemode == 0 || gamemode == 2 || gamemode == 6 || gamemode == 13 || gamemode == 16) #define m_teammode (gamemode==0 || gamemode==4 || gamemode==5 || gamemode==7 || gamemode==11 || gamemode==13 || gamemode==14 || gamemode==16 || gamemode==17 || gamemode==20 || gamemode==21) #define m_tarena (m_arena && m_teammode) #define m_botmode (gamemode==7 || gamemode == 8 || gamemode==12 || (gamemode>=18 && gamemode<=21)) diff --git a/source/src/server.cpp b/source/src/server.cpp index 389f401e..d2650ea2 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1590,6 +1590,22 @@ int canspawn(client *c) // beware: canspawn() doesn't check m_arena! return SP_OK; } +void autospawncheck() +{ + if(mastermode != MM_MATCH || !m_autospawn || interm) return; + + loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed && team_isactive(clients[i]->team)) + { + client *cl = clients[i]; + if((cl->state.state == CS_DEAD || cl->state.state == CS_SPECTATE) + && canspawn(cl) == SP_OK && !cl->autospawn) + { + sendspawn(cl); + cl->autospawn = true; + } + } +} + /** FIXME: this function is unnecessarily complicated */ bool updateclientteam(int cln, int newteam, int ftr) { @@ -3099,6 +3115,7 @@ void process(ENetPacket *packet, int sender, int chan) ls!=cl->state.lifesequence || cl->state.lastspawn<0 || gunselect<0 || gunselect>=NUMGUNS || gunselect == GUN_CPISTOL) break; cl->state.lastspawn = -1; cl->state.spawn = gamemillis; + cl->autospawn = false; cl->upspawnp = false; cl->state.state = CS_ALIVE; cl->state.gunselect = gunselect; @@ -3873,6 +3890,7 @@ void serverslice(uint timeout) // main server update, called from cube main lo } if(m_ktf && !ktfflagingame) flagaction(rnd(2), FA_RESET, -1); // ktf flag watchdog if(m_arena) arenacheck(); + else if(m_autospawn) autospawncheck(); // if(m_lms) lmscheck(); sendextras(); if ( scl.afk_limit && mastermode == MM_OPEN && next_afk_check < servmillis && gamemillis > 20 * 1000 ) check_afk(); diff --git a/source/src/server.h b/source/src/server.h index 69069ba5..be6de9de 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -256,6 +256,7 @@ struct client // server side version of "dynent" type bool at3_dontmove; int spawnindex; int spawnperm, spawnpermsent; + bool autospawn; int salt; string pwd; uint authreq; // for AUTH @@ -294,6 +295,7 @@ struct client // server side version of "dynent" type isonrightmap = m_coop; spawnperm = SP_WRONGMAP; spawnpermsent = servmillis; + autospawn = false; if(!getmap) { loggedwrongmap = false;