Skip to content

Commit

Permalink
Add the latest steam changes for cl_autowepswitch cvar.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Oct 10, 2020
1 parent 2de2509 commit 2a264d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
12 changes: 12 additions & 0 deletions dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ BOOL CHalfLifeMultiplay::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerI
return FALSE;
}

if( pPlayer->m_iAutoWepSwitch == 2
&& pPlayer->m_afButtonLast & ( IN_ATTACK | IN_ATTACK2 ) )
{
return FALSE;
}

if( !pPlayer->m_pActiveItem->CanHolster() )
{
// can't put away the active item.
Expand Down Expand Up @@ -573,7 +579,11 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
{
BOOL addDefault;
CBaseEntity *pWeaponEntity = NULL;
int iOldAutoWepSwitch;

iOldAutoWepSwitch = pPlayer->m_iAutoWepSwitch;

pPlayer->m_iAutoWepSwitch = 1;
pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT );

addDefault = TRUE;
Expand All @@ -590,6 +600,8 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
pPlayer->GiveNamedItem( "weapon_9mmhandgun" );
pPlayer->GiveAmmo( 68, "9mm", _9MM_MAX_CARRY );// 4 full reloads
}

pPlayer->m_iAutoWepSwitch = iOldAutoWepSwitch;
}

//=========================================================
Expand Down
2 changes: 0 additions & 2 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2876,8 +2876,6 @@ void CBasePlayer::Spawn( void )

m_flNextChatTime = gpGlobals->time;

m_iAutoWepSwitch = 1;

g_pGameRules->PlayerSpawn( this );
}

Expand Down
6 changes: 6 additions & 0 deletions dlls/singleplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ BOOL CHalfLifeRules::FShouldSwitchWeapon( CBasePlayer *pPlayer, CBasePlayerItem
return FALSE;
}

if( pPlayer->m_iAutoWepSwitch == 2
&& pPlayer->m_afButtonLast & ( IN_ATTACK | IN_ATTACK2 ) )
{
return FALSE;
}

if( !pPlayer->m_pActiveItem->CanHolster() )
{
return FALSE;
Expand Down

0 comments on commit 2a264d2

Please sign in to comment.