From: havoc Date: Sat, 11 Feb 2006 04:21:51 +0000 (+0000) Subject: minor cleanup of keepalive X-Git-Tag: xonotic-v0.1.0preview~4348 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=084a75e0978e78cc092243e574685a22b73df5f9;p=xonotic%2Fdarkplaces.git minor cleanup of keepalive git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5961 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_parse.c b/cl_parse.c index f1cc56c1..78f2589a 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -173,7 +173,7 @@ static unsigned char olddata[NET_MAXMESSAGE]; void CL_KeepaliveMessage (void) { float time; - static float lastmsg; + static double nextmsg = -1; int oldreadcount; qboolean oldbadread; sizebuf_t old; @@ -195,17 +195,17 @@ void CL_KeepaliveMessage (void) net_message = old; memcpy(net_message.data, olddata, net_message.cursize); - if (cls.netcon && NetConn_CanSendMessage(cls.netcon) && (time = Sys_DoubleTime()) - lastmsg >= 5) + if (cls.netcon && (time = Sys_DoubleTime()) >= nextmsg) { sizebuf_t msg; unsigned char buf[4]; - lastmsg = time; + nextmsg = time + 5; // write out a nop // LordHavoc: must use unreliable because reliable could kill the sigon message! Con_Print("--> client to server keepalive\n"); + memset(&msg, 0, sizeof(msg)); msg.data = buf; msg.maxsize = sizeof(buf); - msg.cursize = 0; MSG_WriteChar(&msg, svc_nop); NetConn_SendUnreliableMessage(cls.netcon, &msg); }