MCPcopy Create free account
hub / github.com/assaultcube/AC / canspawn

Function canspawn

source/src/server.cpp:2011–2041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2009}
2010
2011int canspawn(client *c) // beware: canspawn() doesn't check m_arena!
2012{
2013 // more readable code; TODO clear up intention of especially "failwild" here and more generally the use of TEAM_ANYACTIVE
2014 bool failclientbasics = (!c || c->type == ST_EMPTY || !c->isauthed);
2015 bool failteam = !(c->team == TEAM_ANYACTIVE || team_isvalid(c->team));//TEST WAS JUST:!team_isvalid(c->team);//but since the code is calling updateclientteam(BLAH, TEAM_ANYACTIVE, BLAH) all over the place..
2016 bool failwait = false;
2017 bool failwild = false;
2018 if( c->type == ST_TCPIP ){
2019 failwait = ( c->state.lastdeath > 0 ? sg->gamemillis - c->state.lastdeath : servmillis - c->connectmillis ) < (m_arena ? 0 : m_flags_ ? 5000 : 2000);
2020 // failwild: this one contains a number of aspects, it's a /wild/ conglomeration.
2021 if( totalclients > 3 ){
2022 bool c1 = servmillis - c->connectmillis < 1000 + c->state.reconnections * 2000; // seems to delay respawn if you've reconnected too often
2023 bool c2 = sg->gamemillis > 10000; // only allow after 10 seconds of gametime
2024 //.. c3 = totalclients > 3; // all of this only applies if there are four or more players
2025 bool c4 = !team_isspect(c->team); // all of this only applies if the designated team is not a spectator team
2026 failwild = c1 && c2 && c4; // && c3
2027 }
2028 }
2029 if(failclientbasics || failteam || failwait || failwild ) return SP_OK_NUM; // equivalent to SP_DENY
2030 if(!c->isonrightmap) return SP_WRONGMAP;
2031 if(sg->mastermode == MM_MATCH && sg->matchteamsize)
2032 {
2033 if(c->team == TEAM_SPECT || (team_isspect(c->team) && !m_teammode)) return SP_SPECT;
2034 if(c->team == TEAM_CLA_SPECT || c->team == TEAM_RVSF_SPECT)
2035 {
2036 if(numteamclients()[team_base(c->team)] >= sg->matchteamsize) return SP_SPECT;
2037 else return SP_REFILLMATCH;
2038 }
2039 }
2040 return SP_OK;
2041}
2042
2043void autospawncheck()
2044{

Callers 2

autospawncheckFunction · 0.85
processFunction · 0.85

Calls 1

numteamclientsFunction · 0.85

Tested by

no test coverage detected