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

Function flagdistance

source/src/server.cpp:1315–1341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1313#include "serverchecks.h"
1314
1315bool flagdistance(sflaginfo &f, int cn)
1316{
1317 if(!valid_client(cn) || m_demo) return false;
1318 client &c = *clients[cn];
1319 vec v(-1, -1, c.state.o.z);
1320 switch(f.state)
1321 {
1322 case CTFF_INBASE:
1323 v.x = f.x; v.y = f.y;
1324 break;
1325 case CTFF_DROPPED:
1326 v.x = f.pos[0]; v.y = f.pos[1];
1327 break;
1328 }
1329 bool lagging = (c.ping > 1000 || c.spj > 100);
1330 if(v.x < 0 && !lagging) return true;
1331 float dist = c.state.o.dist(v);
1332 int pdist = check_pdist(&c,dist);
1333 if(pdist)
1334 {
1335 c.farpickups++;
1336 mlog(ACLOG_INFO, "[%s] %s %s the %s flag at distance %.2f (%d)",
1337 c.hostname, c.name, (pdist==2?"tried to touch":"touched"), team_string(&f == sg->sflaginfos + 1), dist, c.farpickups);
1338 if (pdist==2) return false;
1339 }
1340 return lagging ? false : true; // today I found a lag hacker :: Brahma, 19-oct-2010... lets test it a bit
1341}
1342
1343void sendflaginfo(int flag = -1, int cn = -1)
1344{

Callers 1

flagactionFunction · 0.85

Calls 5

valid_clientFunction · 0.85
check_pdistFunction · 0.85
mlogFunction · 0.85
team_stringFunction · 0.85
distMethod · 0.80

Tested by

no test coverage detected