]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
reworked input timing a bit more, now cl_movement 1 mode syncs client packets to...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 16 Feb 2006 10:28:15 +0000 (10:28 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 16 Feb 2006 10:28:15 +0000 (10:28 +0000)
moved CL_SendCmd() call into CL_ReadFromServer right after CL_ReadDemoMessage(), this fixes the prediction jitters that recently appeared with the cl_netinputpacketspersecond feature, however it might add a slight delay in local games (I haven't noticed a delay however)

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5990 d7cf8633-e32d-0410-b094-e92efae38249

cl_input.c
cl_main.c
cl_parse.c
client.h
host.c

index d1af6899729f825bf9b4dda38aeb11ffa9e8d1df..c3fd63acbd1e3cafeec7778be352ce8f1599bc93 100644 (file)
@@ -534,7 +534,7 @@ void CL_ClientMovement_Input(qboolean buttonjump, qboolean buttoncrouch)
                                cl.movement_queue[cl.movement_numqueue++] = cl.movement_queue[i];
        }
        // add to input queue if there is room
-       if (cl_movement.integer && cl.movement_numqueue < (int)(sizeof(cl.movement_queue)/sizeof(cl.movement_queue[0])) && cl.mtime[0] > cl.mtime[1])
+       if (cl.movement_numqueue < (int)(sizeof(cl.movement_queue)/sizeof(cl.movement_queue[0])) && cl.mtime[0] > cl.mtime[1])
        {
                // add to input queue
                cl.movement_queue[cl.movement_numqueue].sequence = cl.movesequence;
@@ -548,10 +548,6 @@ void CL_ClientMovement_Input(qboolean buttonjump, qboolean buttoncrouch)
                cl.movement_queue[cl.movement_numqueue].crouch = buttoncrouch;
                cl.movement_numqueue++;
        }
-       cl.movement = cl_movement.integer && cl.stats[STAT_HEALTH] > 0 && !cls.demoplayback && !cl.intermission;
-       // clear queue if client movement is disabled
-       if (!cl.movement)
-               cl.movement_numqueue = 0;
        cl.movement_replay = true;
 }
 
@@ -585,6 +581,7 @@ void CL_ClientMovement_Replay(void)
        trace_t trace;
        trace_t trace2;
        trace_t trace3;
+
        if (!cl.movement_replay)
                return;
        cl.movement_replay = false;
@@ -608,7 +605,7 @@ void CL_ClientMovement_Replay(void)
        // replay the input queue to predict current location
        // note: this relies on the fact there's always one queue item at the end
 
-       for (i = 0;i < cl.movement_numqueue;i++)
+       for (i = 0;cl.movement && i < cl.movement_numqueue;i++)
        {
                client_movementqueue_t *q = cl.movement_queue + bound(0, i, cl.movement_numqueue - 1);
                frametime = q->frametime;
@@ -822,13 +819,23 @@ void CL_SendMove(void)
        upmove += cl.cmd.upmove;
        total++;
 #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 (cl_movement.integer)
+       {
+               if (!cl.movement_needupdate)
+                       return;
+               cl.movement_needupdate = false;
+               cl.movement = cl.stats[STAT_HEALTH] > 0 && !cls.demoplayback && !cl.intermission;
+       }
+       else
+       {
+               cl.movement = false;
+               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;
@@ -1009,6 +1016,8 @@ void CL_SendMove(void)
        // nothing to send
        if (!buf.cursize)
                return;
+       if (cls.signon != SIGNONS)
+               return;
 
        // FIXME: bits & 16 is +button5, Nexuiz specific
        CL_ClientMovement_Input((bits & 2) != 0, (bits & 16) != 0);
index f32a22812435ff8932bfb80f0b5a744d1ab9e83c..4509dedbfb602019dbedc6737377282eae55204f 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -1480,6 +1480,7 @@ extern void CL_ClientMovement_Replay();
 int CL_ReadFromServer(void)
 {
        CL_ReadDemoMessage();
+       CL_SendCmd();
 
        r_refdef.time = cl.time;
        r_refdef.extraupdate = !r_speeds.integer;
index 063d6bb5371a31930e31ac5010f31d7a626dceec..74f2c15f56906cd185059bd7a5e81d49920621ab 100644 (file)
@@ -1465,6 +1465,7 @@ void CL_ParseServerMessage(void)
                case svc_time:
                        cl.mtime[1] = cl.mtime[0];
                        cl.mtime[0] = MSG_ReadFloat ();
+                       cl.movement_needupdate = true;
                        break;
 
                case svc_clientdata:
index 7efd028cdee8170c2673f064fb143824574839d5..262c2ec2aed5b2d45e2cd3e697a78c0a6a4a76a0 100644 (file)
--- a/client.h
+++ b/client.h
@@ -534,6 +534,9 @@ typedef struct client_state_s
        // client movement simulation
        // these fields are only updated by CL_ClientMovement (called by CL_SendMove after parsing each network packet)
        qboolean movement;
+       // this is set true by svc_time parsing and causes a new movement to be
+       // queued for prediction purposes
+       qboolean movement_needupdate;
        // indicates the queue has been updated and should be replayed
        qboolean movement_replay;
        // simulated data (this is valid even if cl.movement is false)
diff --git a/host.c b/host.c
index e4ec53dfeed0463d0769a1adc9eec405214b2a70..e63a7f7cce31c59ed27fa87e8f136a8f4d7ec5d6 100644 (file)
--- a/host.c
+++ b/host.c
@@ -761,8 +761,8 @@ void _Host_Frame (float time)
        Cbuf_Execute();
 
        // if running the server locally, make intentions now
-       if (cls.state == ca_connected && sv.active)
-               CL_SendCmd();
+       //if (cl.islocalgame)
+       //      CL_SendCmd();
 
 //-------------------
 //
@@ -789,11 +789,11 @@ void _Host_Frame (float time)
 
        if (cls.state == ca_connected)
        {
+               CL_ReadFromServer();
                // if running the server remotely, send intentions now after
                // the incoming messages have been read
-               if (!sv.active)
-                       CL_SendCmd();
-               CL_ReadFromServer();
+               //if (!cl.islocalgame)
+               //      CL_SendCmd();
        }
 
        //ui_update();