engine: client: improve accumulating rounding error, thanks @SNMetamorph for suggestion

This commit is contained in:
Alibek Omarov 2024-06-02 13:08:53 +03:00
parent 793adadb06
commit 413a0fb2e5

View file

@ -608,10 +608,12 @@ static void CL_CreateCmd( void )
cl.frametime_remainder += accurate_ms - ms; // accumulate rounding error each frame cl.frametime_remainder += accurate_ms - ms; // accumulate rounding error each frame
// add a ms if error accumulates enough // add a ms if error accumulates enough
if( cl.frametime_remainder > 1.0 ) if( cl.frametime_remainder >= 1.0 )
{ {
cl.frametime_remainder = 0.0; int ms2 = (int)cl.frametime_remainder;
ms++;
ms += ms2;
cl.frametime_remainder -= ms2;
} }
// ms can't be negative, rely on error accumulation only if FPS > 1000 // ms can't be negative, rely on error accumulation only if FPS > 1000