From 415f5baa1cff6b8417d33a64f8ecdb2ec4039fc0 Mon Sep 17 00:00:00 2001 From: SNMetamorph <25657591+SNMetamorph@users.noreply.github.com> Date: Sun, 2 May 2021 21:48:06 +0400 Subject: [PATCH] engine: client: CL_LerpPoint hotfix --- engine/client/cl_main.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index a32c4e48..d8c3bc9a 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -250,25 +250,29 @@ should be put at. */ static float CL_LerpPoint( void ) { - float f, frac = 1.0f; + float frac = 1.0f; + float server_frametime = cl_serverframetime(); - f = cl_serverframetime(); - - if( f == 0.0f || cls.timedemo ) + if( server_frametime == 0.0f || cls.timedemo ) { cl.time = cl.mtime[0]; return 1.0f; } - if( f > 0.1f ) + if( server_frametime > 0.1f ) { // dropped packet, or start of demo cl.mtime[1] = cl.mtime[0] - 0.1f; - f = 0.1f; + server_frametime = 0.1f; } -#if 1 +#if 0 + /* + g-cont: this code more suitable for singleplayer + NOTE in multiplayer causes significant framerate stutter/jitter and + occuring frames with zero time delta and even with negative time delta. + game becomes more twitchy and as if without interpolation. + */ frac = (cl.time - cl.mtime[1]) / f; - if( frac < 0.0f ) { if( frac < -0.01f ) @@ -282,15 +286,16 @@ static float CL_LerpPoint( void ) frac = 1.0f; } #else + // for multiplayer if( cl_interp->value > 0.001f ) { // manual lerp value (goldsrc mode) - frac = ( cl.time - cl.mtime[0] ) / cl_interp->value; + frac = ( cl.time - cl.mtime[1] ) / cl_interp->value; } - else if( f > 0.001f ) + else if( server_frametime > 0.001f ) { // automatic lerp (classic mode) - frac = ( cl.time - cl.mtime[1] ) / f; + frac = ( cl.time - cl.mtime[1] ) / server_frametime; } #endif return frac;