MCPcopy Create free account
hub / github.com/ddnet/ddnet / ReconstructSmokeTrail

Method ReconstructSmokeTrail

src/game/client/components/items.cpp:697–765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695}
696
697void CItems::ReconstructSmokeTrail(const CProjectileData *pCurrent, int DestroyTick)
698{
699 bool LocalPlayerInGame = false;
700
701 if(GameClient()->m_Snap.m_pLocalInfo)
702 LocalPlayerInGame = GameClient()->m_aClients[GameClient()->m_Snap.m_pLocalInfo->m_ClientId].m_Team != TEAM_SPECTATORS;
703 if(!GameClient()->AntiPingGunfire() || !LocalPlayerInGame)
704 return;
705
706 int PredictionTick = Client()->GetPredictionTick();
707
708 if(PredictionTick == pCurrent->m_StartTick)
709 return;
710
711 // get positions
712 float Curvature = 0;
713 float Speed = 0;
714 const CTuningParams *pTuning = GameClient()->GetTuning(pCurrent->m_TuneZone);
715
716 if(pCurrent->m_Type == WEAPON_GRENADE)
717 {
718 Curvature = pTuning->m_GrenadeCurvature;
719 Speed = pTuning->m_GrenadeSpeed;
720 }
721 else if(pCurrent->m_Type == WEAPON_SHOTGUN)
722 {
723 Curvature = pTuning->m_ShotgunCurvature;
724 Speed = pTuning->m_ShotgunSpeed;
725 }
726 else if(pCurrent->m_Type == WEAPON_GUN)
727 {
728 Curvature = pTuning->m_GunCurvature;
729 Speed = pTuning->m_GunSpeed;
730 }
731
732 float Pt = ((float)(PredictionTick - pCurrent->m_StartTick) + Client()->PredIntraGameTick(g_Config.m_ClDummy)) / (float)Client()->GameTickSpeed();
733 if(Pt < 0)
734 return; // projectile haven't been shot yet
735
736 float Gt = (Client()->PrevGameTick(g_Config.m_ClDummy) - pCurrent->m_StartTick) / (float)Client()->GameTickSpeed() + Client()->GameTickTime(g_Config.m_ClDummy);
737
738 float Alpha = 1.f;
739 if(pCurrent->m_ExtraInfo && pCurrent->m_Owner >= 0 && GameClient()->IsOtherTeam(pCurrent->m_Owner))
740 {
741 Alpha = g_Config.m_ClShowOthersAlpha / 100.0f;
742 }
743
744 float T = Pt;
745 if(DestroyTick >= 0)
746 T = minimum(Pt, ((float)(DestroyTick - 1 - pCurrent->m_StartTick) + Client()->PredIntraGameTick(g_Config.m_ClDummy)) / (float)Client()->GameTickSpeed());
747
748 float MinTrailSpan = 0.4f * ((pCurrent->m_Type == WEAPON_GRENADE) ? 0.5f : 0.25f);
749 float Step = maximum(Client()->FrameTimeAverage(), (pCurrent->m_Type == WEAPON_GRENADE) ? 0.02f : 0.01f);
750 for(int i = 1 + (int)(Gt / Step); i < (int)(T / Step); i++)
751 {
752 float t = Step * (float)i + 0.4f * Step * random_float(-0.5f, 0.5f);
753 vec2 Pos = CalcPos(pCurrent->m_StartPos, pCurrent->m_StartVel, Curvature, Speed, t);
754 vec2 PrevPos = CalcPos(pCurrent->m_StartPos, pCurrent->m_StartVel, Curvature, Speed, t - 0.001f);

Callers

nothing calls this directly

Calls 15

maximumFunction · 0.85
random_floatFunction · 0.85
CalcPosFunction · 0.85
AntiPingGunfireMethod · 0.80
GetPredictionTickMethod · 0.80
PredIntraGameTickMethod · 0.80
PrevGameTickMethod · 0.80
GameTickTimeMethod · 0.80
IsOtherTeamMethod · 0.80
FrameTimeAverageMethod · 0.80
SmokeTrailMethod · 0.80
BulletTrailMethod · 0.80

Tested by

no test coverage detected