]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
changed client input packets to be sent at a fixed 50fps (configurable by cvar) rathe...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Feb 2006 03:14:42 +0000 (03:14 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 15 Feb 2006 03:14:42 +0000 (03:14 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5985 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
cl_main.c
cl_parse.c

index de203112b7f004b649f7511776816a889588c348..786e86985cac09a4ced0503cd2fef1434b6792e9 100644 (file)
@@ -287,6 +287,8 @@ cvar_t in_pitch_max = {0, "in_pitch_max", "90", "how far upward you can aim (qua
 
 cvar_t m_filter = {CVAR_SAVE, "m_filter","0", "smoothes mouse movement, less responsive but smoother aiming"};
 
+cvar_t cl_netinputpacketspersecond = {CVAR_SAVE, "cl_netinputpacketspersecond","50", "how many input packets to send to server each second"};
+
 
 /*
 ================
@@ -799,12 +801,14 @@ void CL_ClientMovement_Replay(void)
 CL_SendMove
 ==============
 */
+extern cvar_t cl_netinputpacketspersecond;
 void CL_SendMove(void)
 {
        int i;
        int bits;
        sizebuf_t buf;
        unsigned char data[128];
+       static double lastsendtime = 0;
 #define MOVEAVERAGING 0
 #if MOVEAVERAGING
        static float forwardmove, sidemove, upmove, total; // accumulation
@@ -821,6 +825,11 @@ void CL_SendMove(void)
 #endif
        if (cls.signon != SIGNONS)
                return;
+       if (realtime < lastsendtime + 1.0 / bound(10, cl_netinputpacketspersecond.value, 100))
+               return;
+       // don't let it fall behind if CL_SendMove hasn't been called recently
+       // (such is the case when framerate is too low for instance)
+       lastsendtime = max(lastsendtime + 1.0 / bound(10, cl_netinputpacketspersecond.value, 100), realtime);
 #if MOVEAVERAGING
        // average the accumulated changes
        total = 1.0f / total;
@@ -1104,5 +1113,7 @@ void CL_InitInput (void)
        Cvar_RegisterVariable(&in_pitch_min);
        Cvar_RegisterVariable(&in_pitch_max);
        Cvar_RegisterVariable(&m_filter);
+
+       Cvar_RegisterVariable(&cl_netinputpacketspersecond);
 }
 
index 8c2cda210191febd9dcc204e2521fddf6b94678c..f32a22812435ff8932bfb80f0b5a744d1ab9e83c 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1548,6 +1548,9 @@ void CL_SendCmd(void)
                        Host_Error("CL_WriteToServer: lost server connection");
                SZ_Clear(&cls.netcon->message);
        }
+
+       // send a move periodically
+       CL_SendMove();
 }
 
 // LordHavoc: pausedemo command
index 78f2589a28bffd161801a2486463e87e9cfab1ac..063d6bb5371a31930e31ac5010f31d7a626dceec 100644 (file)
@@ -1365,7 +1365,6 @@ void CL_ParseServerMessage(void)
        unsigned char           cmdlog[32];
        char            *cmdlogname[32], *temp;
        int                     cmdindex, cmdcount = 0;
-       qboolean        sendmove = false;
 
        if (cls.demorecording)
                CL_WriteDemoMessage ();
@@ -1466,7 +1465,6 @@ void CL_ParseServerMessage(void)
                case svc_time:
                        cl.mtime[1] = cl.mtime[0];
                        cl.mtime[0] = MSG_ReadFloat ();
-                       sendmove = true;
                        break;
 
                case svc_clientdata:
@@ -1792,12 +1790,6 @@ void CL_ParseServerMessage(void)
 
        EntityFrameQuake_ISeeDeadEntities();
 
-       if (sendmove)
-       {
-               // send one move per server frame
-               CL_SendMove();
-       }
-
        parsingerror = false;
 }