Skip to content

Commit a1b526f

Browse files
authored
cl_dll: ammo: fix WeaponList sprite not showing when FOV is at default (#364)
1 parent 934a366 commit a1b526f

1 file changed

Lines changed: 37 additions & 8 deletions

File tree

cl_dll/ammo.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf )
565565
if (gEngfuncs.IsSpectateOnly())
566566
return 1;
567567

568-
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
568+
if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_FLASHLIGHT | HIDEHUD_ALL | HIDEHUD_CROSSHAIR ) )
569569
{
570570
gpActiveSel = NULL;
571571
HideCrosshair();
@@ -581,12 +581,20 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf )
581581
//
582582
int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
583583
{
584+
int fOnTarget = FALSE;
585+
584586
BufferReader reader( pszName, pbuf, iSize );
585587

586588
int iState = reader.ReadByte();
587589
int iId = reader.ReadChar();
588590
int iClip = reader.ReadChar();
589591

592+
// detect if we're also on target
593+
if( iState > 1 )
594+
{
595+
fOnTarget = TRUE;
596+
}
597+
590598
if ( iId < 1 )
591599
{
592600
HideCrosshair();
@@ -621,6 +629,23 @@ int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf )
621629

622630
m_pWeapon = pWeapon;
623631

632+
if( gHUD.m_iFOV >= 90 )
633+
{ // normal crosshairs
634+
if( fOnTarget && m_pWeapon->hAutoaim )
635+
SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 );
636+
else
637+
SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 );
638+
639+
HideCrosshair(); // hide static
640+
}
641+
else
642+
{ // zoomed crosshairs
643+
if( fOnTarget && m_pWeapon->hZoomedAutoaim )
644+
SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 );
645+
else
646+
SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 );
647+
}
648+
624649
m_fFade = 200.0f; //!!!
625650

626651
return 1;
@@ -1024,16 +1049,14 @@ int CHudAmmo::Draw(float flTime)
10241049
int a, x, y, r, g, b;
10251050
int AmmoWidth;
10261051

1027-
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
1028-
return 1;
1029-
10301052
// place it here, so pretty dynamic crosshair will work even in spectator!
10311053
if( gHUD.m_iFOV > 40 )
10321054
{
1033-
HideCrosshair(); // hide static
1034-
10351055
// draw a dynamic crosshair
1036-
DrawCrosshair();
1056+
if( !( gHUD.m_iHideHUDDisplay & HIDEHUD_CROSSHAIR ) )
1057+
DrawCrosshair();
1058+
1059+
DrawSpriteCrosshair();
10371060
}
10381061
else
10391062
{
@@ -1045,7 +1068,10 @@ int CHudAmmo::Draw(float flTime)
10451068
}
10461069
}
10471070

1048-
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
1071+
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
1072+
return 1;
1073+
1074+
if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) )
10491075
return 1;
10501076

10511077
// Draw Weapon Menu
@@ -1576,6 +1602,9 @@ void CHudAmmo::DrawCrosshair( int weaponId )
15761602

15771603
void CHudAmmo::DrawCrosshair()
15781604
{
1605+
if( g_iUser1 && g_iUser1 != OBS_IN_EYE )
1606+
return;
1607+
15791608
int flags, iDeltaDistance, iDistance, iLength, weaponid;
15801609
float flCrosshairDistance;
15811610

0 commit comments

Comments
 (0)