mp/src/game/client/sdk/hud/sdk_hud_weaponselection.cpp
void CHudWeaponSelection::SelectWeaponSlot( int iSlot )
{
	// iSlot is one higher than it should be, since it's the number key, not the 0-based index into the weapons
	--iSlot;

	// Get the local player.
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;

	// Don't try and read past our possible number of slots
	if ( iSlot > DA_MAX_WEAPON_SLOTS )
		return;

	// Make sure the player's allowed to switch weapons
	if ( pPlayer->IsAllowedToSwitchWeapons() == false )
		return;

	// do a fast switch if set
	if ( hud_fastswitch.GetBool() )
	{
		FastWeaponSwitch( iSlot );
		return;
	}

	if ( !IsInSelectionMode() )
		// open the weapon selection
		OpenSelection();

	C_BaseCombatWeapon *pActiveWeapon = m_ahWeaponSlots[iSlot];
	if (!pActiveWeapon)
		return;

	// Mark the change
	SetSelectedWeapon( pActiveWeapon );

	for (int i = 0; i < DA_MAX_WEAPON_SLOTS; i++)
		m_aflSelectedGoal[i] = 0;

	m_aflSelectedGoal[iSlot] = 1;

	m_flDeployGoal = 1;

	pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
}
//-----------------------------------------------------------------------------
// Purpose: Moves selection to the specified slot
//-----------------------------------------------------------------------------
Moves selection to the specified slot
Moves selection to the specified slot
void CHudWeaponSelection::SelectWeaponSlot( int iSlot )
{
	--iSlot;
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;
	if ( iSlot > DA_MAX_WEAPON_SLOTS )
		return;
	if ( pPlayer->IsAllowedToSwitchWeapons() == false )
		return;
	if ( hud_fastswitch.GetBool() )
	{
		FastWeaponSwitch( iSlot );
		return;
	}
	if ( !IsInSelectionMode() )
		OpenSelection();
	C_BaseCombatWeapon *pActiveWeapon = m_ahWeaponSlots[iSlot];
	if (!pActiveWeapon)
		return;
	SetSelectedWeapon( pActiveWeapon );
	for (int i = 0; i < DA_MAX_WEAPON_SLOTS; i++)
		m_aflSelectedGoal[i] = 0;
	m_aflSelectedGoal[iSlot] = 1;
	m_flDeployGoal = 1;
	pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
}
void CHudWeaponSelection :: SelectWeaponSlot ( int iSlot ) { -- iSlot ; C_BasePlayer * pPlayer = C_BasePlayer :: GetLocalPlayer ( ) ; if ( ! pPlayer ) return ; if ( iSlot > DA_MAX_WEAPON_SLOTS ) return ; if ( pPlayer -> IsAllowedToSwitchWeapons ( ) == false ) return ; if ( hud_fastswitch . GetBool ( ) ) { FastWeaponSwitch ( iSlot ) ; return ; } if ( ! IsInSelectionMode ( ) ) OpenSelection ( ) ; C_BaseCombatWeapon * pActiveWeapon = m_ahWeaponSlots [ iSlot ] ; if ( ! pActiveWeapon ) return ; SetSelectedWeapon ( pActiveWeapon ) ; for ( int i = 0 ; i < DA_MAX_WEAPON_SLOTS ; i ++ ) m_aflSelectedGoal [ i ] = 0 ; m_aflSelectedGoal [ iSlot ] = 1 ; m_flDeployGoal = 1 ; pPlayer -> EmitSound ( " " ) ; }
Purpose: Moves selection to the specified slot
Purpose : Moves selection to the specified slot
// iSlot is one higher than it should be, since it's the number key, not the 0-based index into the weapons // Get the local player. // Don't try and read past our possible number of slots // Make sure the player's allowed to switch weapons // do a fast switch if set // open the weapon selection // Mark the change