mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Cleanup grenade prediction, now also correctly shows smoke trails
This commit is contained in:
parent
0b00f17627
commit
cd32f6d79a
|
@ -44,10 +44,29 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
|
|||
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();
|
||||
if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED))
|
||||
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)
|
||||
return; // projectile havn't been shot yet
|
||||
|
||||
|
@ -105,30 +124,6 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID)
|
|||
}
|
||||
|
||||
IGraphics::CQuadItem QuadItem(Pos.x, Pos.y, 32, 32);
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue