]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
minor cleanup of keepalive
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 11 Feb 2006 04:21:51 +0000 (04:21 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 11 Feb 2006 04:21:51 +0000 (04:21 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5961 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c

index f1cc56c180425ed834666f95543d68d788682521..78f2589a28bffd161801a2486463e87e9cfab1ac 100644 (file)
@@ -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);
        }