From 9251796c3a8e3f31f9aa52ef84b9e0ce475d2f9b Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 9 Jan 2012 23:43:53 +0100 Subject: fixed rendering on pause/specific speed for damage indicators and muzzle in the demo player --- src/game/client/components/damageind.cpp | 13 ++++++++++++- src/game/client/components/players.cpp | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include #include @@ -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; -- cgit 1.4.1