Skip to content

Commit 2adce19

Browse files
committed
Reset crosshair on resets to fix spectator non-matching-to-player xhair
This is kind of a guesswork if it'll fix the spectator seeing crosshair on player that it's not the player's actual crosshair, but I'm assuming the state haven't been refreshed properly especialy the timer till next crosshair refresh and maybe on map change and where player index changes it gets stuck with other player's crosshair. * fixes #1735
1 parent 8cfdc9f commit 2adce19

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/game/client/hud_crosshair.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,17 @@ void CHudCrosshair::GetDrawPosition ( float *pX, float *pY, bool *pbBehindCamera
377377
ConVar cl_neo_scope_restrict_to_rectangle("cl_neo_scope_restrict_to_rectangle", "1", FCVAR_CHEAT,
378378
"Whether to enforce rectangular sniper scope shape regardless of screen ratio.", true, 0.0, true, 1.0);
379379

380+
#ifdef NEO
381+
382+
void CHudCrosshair::resetPlayersCrosshair()
383+
{
384+
V_memset(m_szLocalStrPlayersCrosshair, 0, sizeof(m_szLocalStrPlayersCrosshair));
385+
V_memset(m_playersCrosshairInfos, 0, sizeof(m_playersCrosshairInfos));
386+
V_memset(m_aflLastCheckedPlayersCrosshair, 0, sizeof(m_aflLastCheckedPlayersCrosshair));
387+
}
388+
389+
#endif // NEO
390+
380391
void CHudCrosshair::Paint( void )
381392
{
382393
if ( !m_pCrosshair )
@@ -502,7 +513,6 @@ void CHudCrosshair::Paint( void )
502513
if (bPlayerIdxValid)
503514
{
504515
bTakeSpecCrosshair = true;
505-
m_playersCrosshairInfos;
506516
bThisFrameRefreshCrosshair = false;
507517
pCrosshairInfo = &m_playersCrosshairInfos[iPlayerIdx];
508518
pszNeoCrosshair = pNeoPlayer->m_szNeoCrosshair.Get();

src/game/client/hud_crosshair.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class CHudCrosshair : public CHudElement, public vgui::Panel
4141
char m_szLocalStrPlayersCrosshair[MAX_PLAYERS][NEO_XHAIR_SEQMAX] = {};
4242
CrosshairInfo m_playersCrosshairInfos[MAX_PLAYERS] = {};
4343
float m_aflLastCheckedPlayersCrosshair[MAX_PLAYERS] = {};
44+
45+
void resetPlayersCrosshair();
4446
#endif
4547

4648
virtual void SetCrosshairAngle( const QAngle& angle );

src/game/client/neo/c_neo_player.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,11 @@ void C_NEO_Player::Spawn( void )
16051605
neoHud->resetHUDState();
16061606
}
16071607
}
1608+
1609+
if (CHudCrosshair *crosshair = GET_HUDELEMENT(CHudCrosshair))
1610+
{
1611+
crosshair->resetPlayersCrosshair();
1612+
}
16081613
}
16091614
}
16101615

0 commit comments

Comments
 (0)