Cleanup grenade prediction, now also correctly shows smoke trails

This commit is contained in:
BeaR 2014-12-08 19:14:44 +01:00
parent 0b00f17627
commit cd32f6d79a

View file

@ -44,10 +44,29 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
Speed = m_pClient->m_Tuning[g_Config.m_ClDummy].m_GunSpeed; Speed = m_pClient->m_Tuning[g_Config.m_ClDummy].m_GunSpeed;
} }
//
bool LocalPlayerInGame = false;
if(m_pClient->m_Snap.m_pLocalInfo)
LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Team != -1;
//
static float s_LastGameTickTime = Client()->GameTickTime(); static float s_LastGameTickTime = Client()->GameTickTime();
if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED)) if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED))
s_LastGameTickTime = Client()->GameTickTime(); s_LastGameTickTime = Client()->GameTickTime();
float Ct = (Client()->PrevGameTick()-pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + s_LastGameTickTime;
int PrevTick = Client()->PrevGameTick();
if (g_Config.m_ClAntiPingGrenade && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK))
{
// calc predicted game tick
static int Offset = 0;
Offset = (int)(0.8f * (float)Offset + 0.2f * (float)(Client()->PredGameTick() - Client()->GameTick()));
PrevTick += Offset;
}
float Ct = (PrevTick-pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + s_LastGameTickTime;
if(Ct < 0) if(Ct < 0)
return; // projectile havn't been shot yet return; // projectile havn't been shot yet
@ -105,31 +124,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
} }
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 32, 32); IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 32, 32);
Graphics()->QuadsDraw(&QuadItem, 1);
bool LocalPlayerInGame = false;
if(m_pClient->m_Snap.m_pLocalInfo)
LocalPlayerInGame = m_pClient->m_aClients[m_pClient->m_Snap.m_pLocalInfo->m_ClientID].m_Team != -1;
if (g_Config.m_ClAntiPingGrenade && LocalPlayerInGame && !(Client()->State() == IClient::STATE_DEMOPLAYBACK))
{
// Draw shadows of grenades
static int Offset = 0;
Offset = (int)(0.8f * (float)Offset + 0.2f * (float)(Client()->PredGameTick() - Client()->GameTick()));
int PredictedTick = Client()->PrevGameTick() + Offset;
float PredictedCt = (PredictedTick - pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + Client()->GameTickTime();
int shadow_type = pCurrent->m_Type;
RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[clamp(shadow_type, 0, NUM_WEAPONS-1)].m_pSpriteProj);
vec2 PredictedPos = CalcPos(StartPos, StartVel, Curvature, Speed, PredictedCt);
IGraphics::CQuadItem QuadItem(PredictedPos.x, PredictedPos.y, 32, 32);
Graphics()->QuadsDraw(&QuadItem, 1);
}
else
Graphics()->QuadsDraw(&QuadItem, 1);
Graphics()->QuadsSetRotation(0); Graphics()->QuadsSetRotation(0);
Graphics()->QuadsEnd(); Graphics()->QuadsEnd();