From 8881e4f2a4725a8e45db56db3e280b2361c5b3fe Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Mon, 29 Mar 2021 20:55:11 +0000 Subject: [PATCH] server: Limit moveframetime to a multiple of sv.frametime 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 | 2 +- sv_user.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sv_main.c b/sv_main.c index 3ed6e110..2aa9a987 100644 --- 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"}; diff --git a/sv_user.c b/sv_user.c index cf4727b0..e3bc231a 100644 --- 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); } } } -- 2.39.2