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

Function arenacheck

source/src/server.cpp:1632–1701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1630void checkitemspawns(int);
1631
1632void arenacheck()
1633{
1634 if(!m_arena || sg->interm || sg->gamemillis < sg->arenaround || !numactiveclients()) return;
1635
1636 if(sg->arenaround)
1637 { // start new arena round
1638 sg->arenaround = 0;
1639 sg->arenaroundstartmillis = sg->gamemillis;
1640 distributespawns();
1641 checkitemspawns(60*1000); // the server will respawn all items now
1642 loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isauthed)
1643 {
1644 if(clients[i]->isonrightmap && team_isactive(clients[i]->team))
1645 sendspawn(clients[i]);
1646 }
1647 return;
1648 }
1649
1650#ifndef STANDALONE
1651 if(m_botmode && clients[0]->type==ST_LOCAL)
1652 {
1653 int enemies = 0, alive_enemies = 0;
1654 playerent *alive = NULL;
1655 loopv(players) if(players[i] && (!m_teammode || players[i]->team == team_opposite(player1->team)))
1656 {
1657 enemies++;
1658 if(players[i]->state == CS_ALIVE)
1659 {
1660 alive = players[i];
1661 alive_enemies++;
1662 }
1663 }
1664 if(player1->state != CS_DEAD) alive = player1;
1665 if(enemies && (!alive_enemies || player1->state == CS_DEAD))
1666 {
1667 sendf(-1, 1, "ri2", SV_ARENAWIN, m_teammode ? (alive ? alive->clientnum : -1) : (alive && alive->type == ENT_BOT ? -2 : player1->state == CS_ALIVE ? player1->clientnum : -1));
1668 sg->arenaround = sg->gamemillis + 5000;
1669 }
1670 return;
1671 }
1672#endif
1673 client *alive = NULL;
1674 bool dead = false;
1675 int lastdeath = 0;
1676 loopv(clients)
1677 {
1678 client &c = *clients[i];
1679 if(c.type==ST_EMPTY || !c.isauthed || !c.isonrightmap || team_isspect(c.team)) continue;
1680 if(c.state.state==CS_ALIVE || ((c.state.state==CS_DEAD || c.state.state==CS_SPECTATE) && c.state.lastspawn>=0))
1681 {
1682 if(!alive) alive = &c;
1683 else if(!m_teammode || alive->team != c.team) return;
1684 }
1685 else if(c.state.state==CS_DEAD || c.state.state==CS_SPECTATE)
1686 {
1687 dead = true;
1688 lastdeath = max(lastdeath, c.state.lastdeath);
1689 }

Callers 1

serversliceFunction · 0.85

Calls 8

numactiveclientsFunction · 0.85
distributespawnsFunction · 0.85
checkitemspawnsFunction · 0.85
sendspawnFunction · 0.85
sendfFunction · 0.85
numteamclientsFunction · 0.85
refillteamsFunction · 0.85
loopvFunction · 0.70

Tested by

no test coverage detected