From 4988b3a80efbdb3108a0225ed2443d6015111424 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Sun, 11 Apr 2021 16:46:14 +0000 Subject: [PATCH] cl_input: Don't floor cl.cmd.frametime to the nearest millisecond in CL_SendMove 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 | 13 +++++++------ protocol.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cl_input.c b/cl_input.c index 922db005..b309f0b4 100644 --- a/cl_input.c +++ b/cl_input.c @@ -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) { diff --git a/protocol.h b/protocol.h index da32ab78..047262d6 100644 --- a/protocol.h +++ b/protocol.h @@ -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; -- 2.39.2