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

Function htf_forceflag

source/src/server.cpp:1553–1587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1551}
1552
1553void htf_forceflag(int flag)
1554{
1555 sflaginfo &f = sg->sflaginfos[flag];
1556 int besthealth = 0;
1557 vector<int> clientnumbers;
1558 loopv(clients) if(clients[i]->type!=ST_EMPTY)
1559 {
1560 if(clients[i]->state.state == CS_ALIVE && team_base(clients[i]->team) == flag)
1561 {
1562 if(clients[i]->state.health == besthealth)
1563 clientnumbers.add(i);
1564 else
1565 {
1566 if(clients[i]->state.health > besthealth)
1567 {
1568 besthealth = clients[i]->state.health;
1569 clientnumbers.shrink(0);
1570 clientnumbers.add(i);
1571 }
1572 }
1573 }
1574 }
1575
1576 if(clientnumbers.length())
1577 {
1578 int pick = rnd(clientnumbers.length());
1579 client *cl = clients[clientnumbers[pick]];
1580 f.state = CTFF_STOLEN;
1581 f.actor_cn = cl->clientnum;
1582 sendflaginfo(flag);
1583 flagmessage(flag, FM_PICKUP, cl->clientnum);
1584 mlog(ACLOG_INFO,"[%s] %s got forced to pickup the flag", cl->hostname, cl->name);
1585 }
1586 f.lastupdate = sg->gamemillis;
1587}
1588
1589int cmpscore(const int *a, const int *b) { return clients[*a]->at3_score - clients[*b]->at3_score; }
1590

Callers 1

serversliceFunction · 0.85

Calls 7

sendflaginfoFunction · 0.85
flagmessageFunction · 0.85
mlogFunction · 0.85
shrinkMethod · 0.80
loopvFunction · 0.70
addMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected