From b90784da9060b6847d09bd18a15c690065b65214 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 29 May 2021 14:31:37 +0300 Subject: Make times more accurate --- src/core/Timer.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp index 5771274a..0c1875e9 100644 --- a/src/core/Timer.cpp +++ b/src/core/Timer.cpp @@ -121,16 +121,31 @@ void CTimer::Update(void) m_LogicalFrameCounter += m_LogicalFramesPassed; #endif +#ifdef FIX_BUGS + static double frameTimeDouble = 0.0; + frameTimeDouble += frameTime; + + m_snTimeInMillisecondsPauseMode += uint32(frameTimeDouble); +#else m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; +#endif if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { +#ifdef FIX_BUGS + m_snTimeInMilliseconds += uint32(frameTimeDouble); + m_snTimeInMillisecondsNonClipped += uint32(frameTimeDouble); +#else m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; +#endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } +#ifdef FIX_BUGS + frameTimeDouble -= uint32(frameTimeDouble); +#endif } else #endif @@ -158,16 +173,31 @@ void CTimer::Update(void) oldPcTimer = timer; +#ifdef FIX_BUGS + static double frameTimeDouble = 0.0; + frameTimeDouble += frameTime; + + m_snTimeInMillisecondsPauseMode += uint32(frameTimeDouble); +#else m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; +#endif if ( GetIsPaused() ) ms_fTimeStep = 0.0f; else { +#ifdef FIX_BUGS + m_snTimeInMilliseconds += uint32(frameTimeDouble); + m_snTimeInMillisecondsNonClipped += uint32(frameTimeDouble); +#else m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; +#endif ms_fTimeStep = frameTime / 1000.0f * 50.0f; } +#ifdef FIX_BUGS + frameTimeDouble -= uint32(frameTimeDouble); +#endif } if ( ms_fTimeStep < 0.01f && !GetIsPaused() ) -- cgit v1.2.3