stripping 4 bytes from every ping packet

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4046 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
ac_stef
2008-12-19 14:43:28 +00:00
parent d14ebec91d
commit 6f59c27390
+9 -2
View File
@@ -337,8 +337,12 @@ VARP(servpingrate, 1000, 5000, 60000);
VARP(maxservpings, 0, 0, 1000);
VAR(searchlan, 0, 1, 2);
#define PINGBUFSIZE 50
static int pingbuf[PINGBUFSIZE];
void pingservers(bool issearch)
{
static int curpingbuf = 0;
if(pingsock == ENET_SOCKET_NULL)
{
pingsock = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM);
@@ -353,7 +357,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 +449,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;