about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2012-01-09 23:43:53 +0100
committeroy <Tom_Adams@web.de>2012-01-09 23:43:53 +0100
commit9251796c3a8e3f31f9aa52ef84b9e0ce475d2f9b (patch)
treea6bcbc2b4b88aa6770be6cf8dd38b4d4eeaf5d25 /src/game/client
parent3e918075df63245bbc117c7dace711fb3e619003 (diff)
downloadzcatch-9251796c3a8e3f31f9aa52ef84b9e0ce475d2f9b.tar.gz
zcatch-9251796c3a8e3f31f9aa52ef84b9e0ce475d2f9b.zip
fixed rendering on pause/specific speed for damage indicators and muzzle in the demo player
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/components/damageind.cpp13
-rw-r--r--src/game/client/components/players.cpp9
2 files changed, 21 insertions, 1 deletions
diff --git a/src/game/client/components/damageind.cpp b/src/game/client/components/damageind.cpp
index 9be6722a..e2da21e1 100644
--- a/src/game/client/components/damageind.cpp
+++ b/src/game/client/components/damageind.cpp
@@ -1,5 +1,6 @@
 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
 /* If you are missing that file, acquire a complete release at teeworlds.com.                */
+#include <engine/demo.h>
 #include <engine/graphics.h>
 #include <game/generated/protocol.h>
 #include <game/generated/client_data.h>
@@ -46,11 +47,20 @@ void CDamageInd::Create(vec2 Pos, vec2 Dir)
 
 void CDamageInd::OnRender()
 {
-
 	Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
 	Graphics()->QuadsBegin();
+	static float s_LastLocalTime = Client()->LocalTime();
 	for(int i = 0; i < m_NumItems;)
 	{
+		if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
+		{
+			const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
+			if(pInfo->m_Paused)
+				m_aItems[i].m_StartTime += Client()->LocalTime()-s_LastLocalTime;
+			else
+				m_aItems[i].m_StartTime += (Client()->LocalTime()-s_LastLocalTime)*(1.0f-pInfo->m_Speed);
+		}
+
 		float Life = 0.75f - (Client()->LocalTime() - m_aItems[i].m_StartTime);
 		if(Life < 0.0f)
 			DestroyI(&m_aItems[i]);
@@ -64,6 +74,7 @@ void CDamageInd::OnRender()
 			i++;
 		}
 	}
+	s_LastLocalTime = Client()->LocalTime();
 	Graphics()->QuadsEnd();
 }
 
diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp
index 53bf5489..c53a1977 100644
--- a/src/game/client/components/players.cpp
+++ b/src/game/client/components/players.cpp
@@ -415,6 +415,15 @@ void CPlayers::RenderPlayer(
 				}
 
 				int IteX = rand() % g_pData->m_Weapons.m_aId[iw].m_NumSpriteMuzzles;
+				if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
+				{
+					static int s_LastIteX = IteX;
+					const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
+					if(pInfo->m_Paused)
+						IteX = s_LastIteX;
+					else
+						s_LastIteX = IteX;
+				}
 				if (Alpha > 0.0f && g_pData->m_Weapons.m_aId[iw].m_aSpriteMuzzles[IteX])
 				{
 					float OffsetY = -g_pData->m_Weapons.m_aId[iw].m_Muzzleoffsety;