From 88c31a47112ca3bffa540dd560d114f6b92e73e2 Mon Sep 17 00:00:00 2001 From: Fireball Date: Sat, 3 Oct 2020 19:52:40 +0100 Subject: [PATCH] Make menu background animations smoother time_get_microseconds() count starts from 1970-01-01 and float's precision is not enough for every 1/60 of a second. I'm replacing it with LocalTime() - it's also available in the menu and it's counted from the start of the game. I've tested menu and in-game animations. --- src/game/client/components/maplayers.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 8b646e5b5..a045963c6 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -116,24 +116,18 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void { if(pThis->m_OnlineOnly && (pItem->m_Version < 2 || pItem->m_Synchronized)) { - if(pThis->m_OnlineOnly && pThis->m_pClient->m_Snap.m_pGameInfoObj) // && !(pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED)) + if(pThis->m_pClient->m_Snap.m_pGameInfoObj) // && !(pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED)) { s_Time = mix((pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), (pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(), pThis->Client()->IntraGameTick(g_Config.m_ClDummy)); } } - else if(pThis->m_OnlineOnly) + else { s_Time += pThis->LocalTime() - s_LastLocalTime; s_LastLocalTime = pThis->LocalTime(); } - else - { - float CurTime = (float)((double)time_get_microseconds() / 1000000.0); - s_Time += CurTime - s_LastLocalTime; - s_LastLocalTime = CurTime; - } pThis->RenderTools()->RenderEvalEnvelope(pPoints + pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time + TimeOffset, pChannels); } }