Skip to content

Commit

Permalink
Server: RPG: Fix reloading when laser is on
Browse files Browse the repository at this point in the history
  • Loading branch information
tmp64 committed Oct 1, 2024
1 parent 9ec64fe commit 42ec2e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/game/server/rpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,7 @@ void CRpgRocket ::RocketTouch(CBaseEntity *pOther)
{
//ALERT( at_console, "RpgRocket RocketTouch, m_pLauncher: %u\n", GetLauncher() );

if (GetLauncher())
{
// my launcher is still around, tell it I'm dead.
GetLauncher()->m_cActiveRockets--;
}

ReleaseLauncher();
STOP_SOUND(edict(), CHAN_VOICE, "weapons/rocket1.wav");
ExplodeTouch(pOther);
}
Expand All @@ -168,14 +163,7 @@ void CRpgRocket::Explode(TraceResult *pTrace, int bitsDamageType)
//ALERT( at_console, "RpgRocket Explode, m_pLauncher: %u\n", GetLauncher() );

STOP_SOUND(edict(), CHAN_VOICE, "weapons/rocket1.wav");

if (GetLauncher())
{
// my launcher is still around, tell it I'm dead.
GetLauncher()->m_cActiveRockets--;
m_hLauncher = nullptr;
}

ReleaseLauncher();
CGrenade::Explode(pTrace, bitsDamageType);
}

Expand Down Expand Up @@ -228,6 +216,17 @@ CRpg *CRpgRocket::GetLauncher()
return (CRpg *)((CBaseEntity *)m_hLauncher);
}

void CRpgRocket::ReleaseLauncher()
{
if (GetLauncher())
{
// my launcher is still around, tell it I'm dead.
ASSERT(GetLauncher()->m_cActiveRockets > 0);
GetLauncher()->m_cActiveRockets--;
m_hLauncher = nullptr;
}
}

void CRpgRocket ::FollowThink(void)
{
CBaseEntity *pOther = NULL;
Expand Down Expand Up @@ -303,12 +302,7 @@ void CRpgRocket ::FollowThink(void)
pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798;
if (pev->waterlevel == 0 && pev->velocity.Length() < 1500)
{
if (GetLauncher())
{
// my launcher is still around, tell it I'm dead.
GetLauncher()->m_cActiveRockets--;
m_hLauncher = nullptr;
}
ReleaseLauncher();
Detonate();
}
}
Expand All @@ -321,8 +315,7 @@ void CRpgRocket ::FollowThink(void)
if (flDistance > 8192.0f || gpGlobals->time - m_flIgniteTime > 6.0f)
{
//ALERT( at_console, "RPG too far (%f)!\n", flDistance );
GetLauncher()->m_cActiveRockets--;
m_hLauncher = NULL;
ReleaseLauncher();
}

//ALERT( at_console, "%.0f, m_pLauncher: %u, flDistance: %f\n", flSpeed, GetLauncher(), flDistance );
Expand Down
4 changes: 4 additions & 0 deletions src/game/server/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,10 @@ class CRpgRocket : public CGrenade
int m_iTrail;
float m_flIgniteTime;
EHANDLE m_hLauncher; // pointer back to the launcher that fired me.

private:
//! Notifies the launcher that this rocket is dead.
void ReleaseLauncher();
};

class CGauss : public CBasePlayerWeapon
Expand Down

0 comments on commit 42ec2e0

Please sign in to comment.