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

Function addgameserver

source/src/master.cpp:317–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317void addgameserver(mclient &c)
318{
319 if(gameservers.length() >= SERVER_LIMIT) return;
320 loopv(gameservers)
321 {
322 gameserver &s = *gameservers[i];
323 if(s.address.host == c.address.host && s.port == c.servport)
324 {
325 s.lastping = 0;
326 s.numpings = 0;
327 return;
328 }
329 }
330 string hostname;
331 if(enet_address_get_host_ip(&c.address, hostname, sizeof(hostname)) < 0)
332 {
333 outputf(c, "failreg failed resolving ip\n");
334 return;
335 }
336 gameserver &s = *gameservers.add(new gameserver);
337 s.address.host = c.address.host;
338 s.address.port = c.servport+1;
339 copystring(s.ip, hostname);
340 s.port = c.servport;
341 s.numpings = 0;
342 s.lastping = s.lastpong = 0;
343}
344
345mclient *findclient(gameserver &s)
346{

Callers 1

checkclientinputFunction · 0.85

Calls 5

outputfFunction · 0.85
copystringFunction · 0.85
enet_address_get_host_ipFunction · 0.50
lengthMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected