]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
server: Limit moveframetime to a multiple of sv.frametime
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 29 Mar 2021 20:55:11 +0000 (20:55 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 29 Mar 2021 20:55:11 +0000 (20:55 +0000)
Matches clmovement_inputtimeout decrementing behaviour and prevents player speed bugs with certain ticrate/inputtimeout/netfps combos.

Also use maximum of 0.1 for the timeout, not just the moveframetime limit.

From bones_was_here

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

sv_main.c
sv_user.c

index 3ed6e110a6a4a9f43dfe6c26752a8f25b3c03654..2aa9a9875d4d65d88d80f7a1856740c67102685c 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -76,7 +76,7 @@ cvar_t sv_checkforpacketsduringsleep = {CF_SERVER, "sv_checkforpacketsduringslee
 cvar_t sv_clmovement_enable = {CF_SERVER, "sv_clmovement_enable", "1", "whether to allow clients to use cl_movement prediction, which can cause choppy movement on the server which may annoy other players"};
 cvar_t sv_clmovement_minping = {CF_SERVER, "sv_clmovement_minping", "0", "if client ping is below this time in milliseconds, then their ability to use cl_movement prediction is disabled for a while (as they don't need it)"};
 cvar_t sv_clmovement_minping_disabletime = {CF_SERVER, "sv_clmovement_minping_disabletime", "1000", "when client falls below minping, disable their prediction for this many milliseconds (should be at least 1000 or else their prediction may turn on/off frequently)"};
-cvar_t sv_clmovement_inputtimeout = {CF_SERVER, "sv_clmovement_inputtimeout", "0.2", "when a client does not send input for this many seconds, force them to move anyway (unlike QuakeWorld)"};
+cvar_t sv_clmovement_inputtimeout = {CF_SERVER, "sv_clmovement_inputtimeout", "0.1", "when a client does not send input for this many seconds (max 0.1), force them to move anyway (unlike QuakeWorld)"};
 cvar_t sv_cullentities_nevercullbmodels = {CF_SERVER, "sv_cullentities_nevercullbmodels", "0", "if enabled the clients are always notified of moving doors and lifts and other submodels of world (warning: eats a lot of network bandwidth on some levels!)"};
 cvar_t sv_cullentities_pvs = {CF_SERVER, "sv_cullentities_pvs", "1", "fast but loose culling of hidden entities"};
 cvar_t sv_cullentities_stats = {CF_SERVER, "sv_cullentities_stats", "0", "displays stats on network entities culled by various methods for each client"};
index cf4727b000c8be0ac9e11c8bfbaac1aa8c2a1120..e3bc231a0ad00132d949627c9bba43f029848483 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -775,7 +775,7 @@ static void SV_ExecuteClientMoves(void)
 {
        prvm_prog_t *prog = SVVM_prog;
        int moveindex;
-       float moveframetime;
+       double moveframetime;
        double oldframetime;
        double oldframetime2;
 #ifdef NUM_PING_TIMES
@@ -811,7 +811,8 @@ static void SV_ExecuteClientMoves(void)
                                // this is a new move
                                move->time = bound(sv.time - 1, move->time, sv.time); // prevent slowhack/speedhack combos
                                move->time = max(move->time, host_client->cmd.time); // prevent backstepping of time
-                               moveframetime = bound(0, move->time - host_client->cmd.time, min(0.1, sv_clmovement_inputtimeout.value));
+                               // bones_was_here: limit moveframetime to a multiple of sv.frametime to match inputtimeout behaviour
+                               moveframetime = min(move->time - host_client->cmd.time, min(0.1, sys_ticrate.value > 0.0 ? sv.frametime * ceil(sv_clmovement_inputtimeout.value / sv.frametime) : sv_clmovement_inputtimeout.value));
 
                                // discard (treat like lost) moves with too low distance from
                                // the previous one to prevent hacks using float inaccuracy
@@ -855,7 +856,7 @@ static void SV_ExecuteClientMoves(void)
                                SV_Physics_ClientMove();
                                sv.frametime = oldframetime2;
                                PRVM_serverglobalfloat(frametime) = oldframetime;
-                               host_client->clmovement_inputtimeout = sv_clmovement_inputtimeout.value;
+                               host_client->clmovement_inputtimeout = min(0.1, sv_clmovement_inputtimeout.value);
                        }
                }
        }