Client: Fix projectiles rendering for demo playback

The playback timing leads to always negative client time for projectiles
fired on the current game tick.
This commit is contained in:
Alexander Akulich 2021-12-25 13:21:48 +03:00
parent 15e6fd8a2f
commit 9a5b7339cf

View file

@ -58,7 +58,27 @@ void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemID)
else else
Ct = (Client()->PrevGameTick(g_Config.m_ClDummy) - pCurrent->m_StartTick) / (float)SERVER_TICK_SPEED + s_LastGameTickTime; Ct = (Client()->PrevGameTick(g_Config.m_ClDummy) - pCurrent->m_StartTick) / (float)SERVER_TICK_SPEED + s_LastGameTickTime;
if(Ct < 0) if(Ct < 0)
return; // projectile haven't been shot yet {
if(Ct > -s_LastGameTickTime / 2)
{
// Fixup the timing which might be screwed during demo playback because
// s_LastGameTickTime depends on the system timer, while the other part
// (Client()->PrevGameTick(g_Config.m_ClDummy) - pCurrent->m_StartTick) / (float)SERVER_TICK_SPEED
// is virtually constant (for projectiles fired on the current game tick):
// (x - (x+2)) / 50 = -0.04
//
// We have a strict comparison for the passed time being more than the time between ticks
// if(CurtickStart > m_Info.m_CurrentTime) in CDemoPlayer::Update()
// so on the practice the typical value of s_LastGameTickTime varies from 0.02386 to 0.03999
// which leads to Ct from -0.00001 to -0.01614.
// Round up those to 0.0 to fix missing rendering of the projectile.
Ct = 0;
}
else
{
return; // projectile haven't been shot yet
}
}
vec2 Pos = CalcPos(pCurrent->m_StartPos, pCurrent->m_StartVel, Curvature, Speed, Ct); vec2 Pos = CalcPos(pCurrent->m_StartPos, pCurrent->m_StartVel, Curvature, Speed, Ct);
vec2 PrevPos = CalcPos(pCurrent->m_StartPos, pCurrent->m_StartVel, Curvature, Speed, Ct - 0.001f); vec2 PrevPos = CalcPos(pCurrent->m_StartPos, pCurrent->m_StartVel, Curvature, Speed, Ct - 0.001f);