Skip to content

Commit 8809532

Browse files
authored
Don't show OBS ghost beacons whilst LIFE_DYING (#1791)
* Only consider drawing beacons for LIFE_ALIVE and LIFE_DEAD And not during LIFE_DYING * Refactor const ptr
1 parent 6ee5122 commit 8809532

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/game/client/neo/ui/neo_hud_ghost_beacons.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,20 @@ void CNEOHud_GhostBeacons::DrawNeoHudElement()
8585
if (!ShouldDraw())
8686
return;
8787

88-
auto ghoster = IsLocalPlayerSpectator()
89-
? ToNEOPlayer(UTIL_PlayerByIndex(GetSpectatorTarget()))
90-
: C_NEO_Player::GetLocalNEOPlayer();
88+
auto localPlayer = C_NEO_Player::GetLocalNEOPlayer();
89+
if (!localPlayer)
90+
return;
91+
92+
// Only consider drawing beacons if alive or dead, but not LIFE_DYING (the death animation)
93+
if (localPlayer->m_lifeState != LIFE_ALIVE &&
94+
localPlayer->m_lifeState != LIFE_DEAD)
95+
{
96+
return;
97+
}
98+
99+
auto ghoster = localPlayer->IsObserver()
100+
? ToNEOPlayer(localPlayer->GetObserverTarget())
101+
: localPlayer;
91102

92103
if (!ghoster || !ghoster->m_bCarryingGhost ||
93104
ghoster->GetTeamNumber() < FIRST_GAME_TEAM ||
@@ -97,19 +108,19 @@ void CNEOHud_GhostBeacons::DrawNeoHudElement()
97108
}
98109
Assert(ghoster->GetTeamNumber() < TEAM__TOTAL);
99110

100-
C_WeaponGhost* ghost;
111+
const C_WeaponGhost* ghost;
101112
if (sv_neo_ctg_ghost_beacons_when_inactive.GetBool())
102113
{
103-
ghost = assert_cast<C_WeaponGhost*>(GetNeoWepWithBits(ghoster, NEO_WEP_GHOST));
114+
ghost = assert_cast<const C_WeaponGhost*>(GetNeoWepWithBits(ghoster, NEO_WEP_GHOST));
104115
AssertMsg(ghoster->m_bCarryingGhost == !!ghost,
105116
"ghost ptr and m_bCarryingGhost mismatch");
106117
}
107118
else
108119
{
109120
auto weapon = assert_cast<C_NEOBaseCombatWeapon*>(ghoster->GetActiveWeapon());
110-
ghost = (weapon && weapon->IsGhost()) ? static_cast<C_WeaponGhost*>(weapon) : nullptr;
121+
ghost = (weapon && weapon->IsGhost()) ? static_cast<const C_WeaponGhost*>(weapon) : nullptr;
111122
AssertMsg(ghoster->m_bCarryingGhost ==
112-
!!assert_cast<C_WeaponGhost*>(GetNeoWepWithBits(ghoster, NEO_WEP_GHOST)),
123+
!!assert_cast<const C_WeaponGhost*>(GetNeoWepWithBits(ghoster, NEO_WEP_GHOST)),
113124
"ghost ptr and m_bCarryingGhost mismatch");
114125
}
115126

0 commit comments

Comments
 (0)