]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cl_input: Don't floor cl.cmd.frametime to the nearest millisecond in CL_SendMove
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Apr 2021 16:46:14 +0000 (16:46 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 11 Apr 2021 16:46:14 +0000 (16:46 +0000)
Removes the requirement of integer millisecond client and server frame times (eg 125fps) to get the smoothest asynchronous movement.

Authored by bones_was_here
https://gitlab.com/xonotic/darkplaces/-/merge_requests/112

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

cl_input.c
protocol.h

index 922db005dc558c382a3e2548c07f5db542e7b4cf..b309f0b4453274ef8c2d73303a7dedf7102626b2 100644 (file)
@@ -1757,7 +1757,6 @@ void CL_SendMove(void)
        sizebuf_t buf;
        unsigned char data[1024];
        float packettime;
-       int msecdelta;
        qbool quemove;
        qbool important;
 
@@ -1813,12 +1812,14 @@ void CL_SendMove(void)
        // set viewangles
        VectorCopy(cl.viewangles, cl.cmd.viewangles);
 
-       msecdelta = (int)(floor(cl.cmd.time * 1000) - floor(cl.movecmd[1].time * 1000));
-       cl.cmd.msec = (unsigned char)bound(0, msecdelta, 255);
+       // bones_was_here: previously cl.cmd.frametime was floored to nearest millisec
+       // this meant the smoothest async movement required integer millisec
+       // client and server frame times (eg 125fps)
+       cl.cmd.frametime = bound(0.0, cl.cmd.time - cl.movecmd[1].time, 0.255);
        // ridiculous value rejection (matches qw)
-       if (cl.cmd.msec > 250)
-               cl.cmd.msec = 100;
-       cl.cmd.frametime = cl.cmd.msec * (1.0 / 1000.0);
+       if (cl.cmd.frametime > 0.25)
+               cl.cmd.frametime = 0.1;
+       cl.cmd.msec = (unsigned char)floor(cl.cmd.frametime * 1000);
 
        switch(cls.protocol)
        {
index da32ab782d1b67e9edeb525e0b4b63684d33c5de..047262d6a979604c1cefb5096f141674bdd8b2ab 100644 (file)
@@ -390,7 +390,7 @@ typedef struct usercmd_s
 
        double time; // time the move is executed for (non-cl_movement is executed at receivetime)
        float receivetime; // time the move was received at (used for ping)
-       int msec; // for predicted moves
+       unsigned char msec; // for predicted moves
        int buttons;
        int impulse;
        unsigned int sequence;