restoring stef's ping optimizations (i misunderstood something)
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4050 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -337,6 +337,9 @@ VARP(servpingrate, 1000, 5000, 60000);
|
||||
VARP(maxservpings, 0, 0, 1000);
|
||||
VAR(searchlan, 0, 1, 2);
|
||||
|
||||
#define PINGBUFSIZE 100
|
||||
static int pingbuf[PINGBUFSIZE], curpingbuf = 0;
|
||||
|
||||
void pingservers(bool issearch)
|
||||
{
|
||||
if(pingsock == ENET_SOCKET_NULL)
|
||||
@@ -353,7 +356,9 @@ void pingservers(bool issearch)
|
||||
ENetBuffer buf;
|
||||
static uchar ping[MAXTRANS];
|
||||
ucharbuf p(ping, sizeof(ping));
|
||||
putint(p, totalmillis);
|
||||
curpingbuf = (curpingbuf + 1) % PINGBUFSIZE;
|
||||
pingbuf[curpingbuf] = totalmillis;
|
||||
putint(p, curpingbuf + 1); // offset by 1 to avoid extinfo trigger
|
||||
int baselen = p.length();
|
||||
if(searchlan < 2)
|
||||
{
|
||||
@@ -443,7 +448,8 @@ void checkpings()
|
||||
|
||||
ucharbuf p(ping, len);
|
||||
si->lastpingmillis = totalmillis;
|
||||
si->ping = totalmillis - getint(p);
|
||||
int pingtm = pingbuf[(getint(p) - 1) % PINGBUFSIZE];
|
||||
si->ping = pingtm ? totalmillis - pingtm : 9997;
|
||||
int query = getint(p);
|
||||
si->protocol = getint(p);
|
||||
if(si->protocol!=PROTOCOL_VERSION) si->ping = 9998;
|
||||
|
||||
Reference in New Issue
Block a user