]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_input.c
reworked input timing a bit more, now cl_movement 1 mode syncs client packets to...
[xonotic/darkplaces.git] / cl_input.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);