Skip to content

Commit

Permalink
fix displacer crash
Browse files Browse the repository at this point in the history
  • Loading branch information
wootguy committed Dec 7, 2024
1 parent 3ddfaae commit 27adcde
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions dlls/weapon/CDisplacerBall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,30 +369,32 @@ void CDisplacerBall::ArmBeam(int iSide)
if (!m_pBeam[m_uiBeams])
m_pBeam[m_uiBeams] = CBeam::BeamCreate("sprites/lgtning.spr", 30);

if (!m_pBeam[m_uiBeams])
CBeam* beam = (CBeam*)m_pBeam[m_uiBeams].GetEntity();

if (!beam)
return;

auto pHit = Instance(tr.pHit);

if (pHit && pHit->pev->takedamage != DAMAGE_NO)
{
// Beam hit something, deal radius damage to it.
m_pBeam[m_uiBeams]->EntsInit(pHit->entindex(), entindex());
beam->EntsInit(pHit->entindex(), entindex());

m_pBeam[m_uiBeams]->SetColor(255, 255, 255);
beam->SetColor(255, 255, 255);

m_pBeam[m_uiBeams]->SetBrightness(255);
beam->SetBrightness(255);

RadiusDamage(tr.vecEndPos, pev, &pev->owner->v, 25, 15, CLASS_NONE, DMG_ENERGYBEAM);
}
else
{
m_pBeam[m_uiBeams]->PointEntInit(tr.vecEndPos, entindex());
m_pBeam[m_uiBeams]->SetEndAttachment(iSide < 0 ? 2 : 1);
beam->PointEntInit(tr.vecEndPos, entindex());
beam->SetEndAttachment(iSide < 0 ? 2 : 1);
// m_pBeam[ m_uiBeams ]->SetColor( 180, 255, 96 );
m_pBeam[m_uiBeams]->SetColor(96, 128, 16);
m_pBeam[m_uiBeams]->SetBrightness(255);
m_pBeam[m_uiBeams]->SetNoise(80);
beam->SetColor(96, 128, 16);
beam->SetBrightness(255);
beam->SetNoise(80);
}

++m_uiBeams;
Expand Down
2 changes: 1 addition & 1 deletion dlls/weapon/CDisplacerBall.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CDisplacerBall : public CBaseEntity
private:
int m_iTrail;

CBeam* m_pBeam[NUM_BEAMS];
EHANDLE m_pBeam[NUM_BEAMS];

size_t m_uiBeams;

Expand Down

0 comments on commit 27adcde

Please sign in to comment.