Make times more accurate

This commit is contained in:
Sergeanur 2021-05-29 14:31:37 +03:00
parent f741101e44
commit b90784da90

View File

@ -121,16 +121,31 @@ void CTimer::Update(void)
m_LogicalFrameCounter += m_LogicalFramesPassed; m_LogicalFrameCounter += m_LogicalFramesPassed;
#endif #endif
#ifdef FIX_BUGS
static double frameTimeDouble = 0.0;
frameTimeDouble += frameTime;
m_snTimeInMillisecondsPauseMode += uint32(frameTimeDouble);
#else
m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime;
#endif
if ( GetIsPaused() ) if ( GetIsPaused() )
ms_fTimeStep = 0.0f; ms_fTimeStep = 0.0f;
else else
{ {
#ifdef FIX_BUGS
m_snTimeInMilliseconds += uint32(frameTimeDouble);
m_snTimeInMillisecondsNonClipped += uint32(frameTimeDouble);
#else
m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime;
m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime;
#endif
ms_fTimeStep = frameTime / 1000.0f * 50.0f; ms_fTimeStep = frameTime / 1000.0f * 50.0f;
} }
#ifdef FIX_BUGS
frameTimeDouble -= uint32(frameTimeDouble);
#endif
} }
else else
#endif #endif
@ -158,16 +173,31 @@ void CTimer::Update(void)
oldPcTimer = timer; oldPcTimer = timer;
#ifdef FIX_BUGS
static double frameTimeDouble = 0.0;
frameTimeDouble += frameTime;
m_snTimeInMillisecondsPauseMode += uint32(frameTimeDouble);
#else
m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime;
#endif
if ( GetIsPaused() ) if ( GetIsPaused() )
ms_fTimeStep = 0.0f; ms_fTimeStep = 0.0f;
else else
{ {
#ifdef FIX_BUGS
m_snTimeInMilliseconds += uint32(frameTimeDouble);
m_snTimeInMillisecondsNonClipped += uint32(frameTimeDouble);
#else
m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime;
m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime;
#endif
ms_fTimeStep = frameTime / 1000.0f * 50.0f; ms_fTimeStep = frameTime / 1000.0f * 50.0f;
} }
#ifdef FIX_BUGS
frameTimeDouble -= uint32(frameTimeDouble);
#endif
} }
if ( ms_fTimeStep < 0.01f && !GetIsPaused() ) if ( ms_fTimeStep < 0.01f && !GetIsPaused() )