about summary refs log tree commit diff
path: root/src/game/client/components/maplayers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/client/components/maplayers.cpp')
-rw-r--r--src/game/client/components/maplayers.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp
index 3d9c42e7..48f11f26 100644
--- a/src/game/client/components/maplayers.cpp
+++ b/src/game/client/components/maplayers.cpp
@@ -22,6 +22,9 @@ CMapLayers::CMapLayers(int t)
 {
 	m_Type = t;
 	m_pLayers = 0;
+	m_CurrentLocalTick = 0;
+	m_LastLocalTick = 0;
+	m_EnvelopeUpdate = false;
 }
 
 void CMapLayers::OnInit()
@@ -29,6 +32,17 @@ void CMapLayers::OnInit()
 	m_pLayers = Layers();
 }
 
+void CMapLayers::EnvelopeUpdate()
+{
+	if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
+	{
+		const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
+		m_CurrentLocalTick = pInfo->m_CurrentTick;
+		m_LastLocalTick = pInfo->m_CurrentTick;
+		m_EnvelopeUpdate = true;
+	}
+}
+
 
 void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup)
 {
@@ -67,19 +81,17 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
 	if(pThis->Client()->State() == IClient::STATE_DEMOPLAYBACK)
 	{
 		const IDemoPlayer::CInfo *pInfo = pThis->DemoPlayer()->BaseInfo();
-		static int CurrentLocalTick = pInfo->m_CurrentTick;
-		static int LastLocalTick = pInfo->m_CurrentTick;
-
-		if(!pInfo->m_Paused)
+		
+		if(!pInfo->m_Paused || pThis->m_EnvelopeUpdate)
 		{
-			if(CurrentLocalTick != pInfo->m_CurrentTick)
+			if(pThis->m_CurrentLocalTick != pInfo->m_CurrentTick)
 			{
-				LastLocalTick = CurrentLocalTick;
-				CurrentLocalTick = pInfo->m_CurrentTick;
+				pThis->m_LastLocalTick = pThis->m_CurrentLocalTick;
+				pThis->m_CurrentLocalTick = pInfo->m_CurrentTick;
 			}
 
-			Time = mix(LastLocalTick / (float)pThis->Client()->GameTickSpeed(),
-						CurrentLocalTick / (float)pThis->Client()->GameTickSpeed(),
+			Time = mix(pThis->m_LastLocalTick / (float)pThis->Client()->GameTickSpeed(),
+						pThis->m_CurrentLocalTick / (float)pThis->Client()->GameTickSpeed(),
 						pThis->Client()->IntraGameTick());
 		}