From 41fd1639d91ff9ba9ac937b315deab0619fb8b18 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Fri, 21 Jan 2022 11:30:31 +0100 Subject: [PATCH] Limit evolving to 3 seconds Took from upstream https://github.com/teeworlds/teeworlds/commit/5d44714e9206e2b12d5fa4b0af9ac80c30dd19b6#diff-597779b4eb51af9adfedd04b8a235afff01091a4ba741daa604cb5cbeda4e3daR1306-R1321 --- src/game/client/gameclient.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 5abeb931b..379dceb3a 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1247,8 +1247,12 @@ void CGameClient::OnNewSnapshot() m_Snap.m_aCharacters[Item.m_ID].m_Active = true; m_Snap.m_aCharacters[Item.m_ID].m_Prev = *((const CNetObj_Character *)pOld); + // limit evolving to 3 seconds + int EvolvePrevTick = minimum(m_Snap.m_aCharacters[Item.m_ID].m_Prev.m_Tick + Client()->GameTickSpeed() * 3, Client()->PrevGameTick(g_Config.m_ClDummy)); + int EvolveCurTick = minimum(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Tick + Client()->GameTickSpeed() * 3, Client()->GameTick(g_Config.m_ClDummy)); + // reuse the result from the previous evolve if the snapped character didn't change since the previous snapshot - if(m_aClients[Item.m_ID].m_Evolved.m_Tick == Client()->PrevGameTick(g_Config.m_ClDummy)) + if(m_aClients[Item.m_ID].m_Evolved.m_Tick == EvolvePrevTick) { if(mem_comp(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, &m_aClients[Item.m_ID].m_Snapped, sizeof(CNetObj_Character)) == 0) m_Snap.m_aCharacters[Item.m_ID].m_Prev = m_aClients[Item.m_ID].m_Evolved; @@ -1257,9 +1261,9 @@ void CGameClient::OnNewSnapshot() } if(m_Snap.m_aCharacters[Item.m_ID].m_Prev.m_Tick) - Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, Client()->PrevGameTick(g_Config.m_ClDummy)); + Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Prev, EvolvePrevTick); if(m_Snap.m_aCharacters[Item.m_ID].m_Cur.m_Tick) - Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, Client()->GameTick(g_Config.m_ClDummy)); + Evolve(&m_Snap.m_aCharacters[Item.m_ID].m_Cur, EvolveCurTick); m_aClients[Item.m_ID].m_Snapped = *((const CNetObj_Character *)pData); m_aClients[Item.m_ID].m_Evolved = m_Snap.m_aCharacters[Item.m_ID].m_Cur;