sp/src/game/client/hl2/hud_weaponselection.cpp
void CHudWeaponSelection::CycleToNextWeapon( void )
{
	// Get the local player.
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;

	C_BaseCombatWeapon *pNextWeapon = NULL;
	if ( IsInSelectionMode() )
	{
		// find the next selection spot
		C_BaseCombatWeapon *pWeapon = GetSelectedWeapon();
		if ( !pWeapon )
			return;

		pNextWeapon = FindNextWeaponInWeaponSelection( pWeapon->GetSlot(), pWeapon->GetPosition() );
	}
	else
	{
		// open selection at the current place
		pNextWeapon = pPlayer->GetActiveWeapon();
		if ( pNextWeapon )
		{
			pNextWeapon = FindNextWeaponInWeaponSelection( pNextWeapon->GetSlot(), pNextWeapon->GetPosition() );
		}
	}

	if ( !pNextWeapon )
	{
		// wrap around back to start
		pNextWeapon = FindNextWeaponInWeaponSelection(-1, -1);
	}

	if ( pNextWeapon )
	{
		SetSelectedWeapon( pNextWeapon );

		if( hud_fastswitch.GetInt() > 0 )
		{
			SelectWeapon();
		}
		else if ( !IsInSelectionMode() )
		{
			OpenSelection();
		}

		// Play the "cycle to next weapon" sound
		pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
	}
}
//-----------------------------------------------------------------------------
// Purpose: Moves the selection to the next item in the menu
//-----------------------------------------------------------------------------
Moves the selection to the next item in the menu
Moves the selection to the next item in the menu
void CHudWeaponSelection::CycleToNextWeapon( void )
{
	C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
	if ( !pPlayer )
		return;
	C_BaseCombatWeapon *pNextWeapon = NULL;
	if ( IsInSelectionMode() )
	{
		C_BaseCombatWeapon *pWeapon = GetSelectedWeapon();
		if ( !pWeapon )
			return;
		pNextWeapon = FindNextWeaponInWeaponSelection( pWeapon->GetSlot(), pWeapon->GetPosition() );
	}
	else
	{
		pNextWeapon = pPlayer->GetActiveWeapon();
		if ( pNextWeapon )
		{
			pNextWeapon = FindNextWeaponInWeaponSelection( pNextWeapon->GetSlot(), pNextWeapon->GetPosition() );
		}
	}
	if ( !pNextWeapon )
	{
		pNextWeapon = FindNextWeaponInWeaponSelection(-1, -1);
	}
	if ( pNextWeapon )
	{
		SetSelectedWeapon( pNextWeapon );
		if( hud_fastswitch.GetInt() > 0 )
		{
			SelectWeapon();
		}
		else if ( !IsInSelectionMode() )
		{
			OpenSelection();
		}
		pPlayer->EmitSound( "Player.WeaponSelectionMoveSlot" );
	}
}
void CHudWeaponSelection :: CycleToNextWeapon ( void ) { C_BasePlayer * pPlayer = C_BasePlayer :: GetLocalPlayer ( ) ; if ( ! pPlayer ) return ; C_BaseCombatWeapon * pNextWeapon = NULL ; if ( IsInSelectionMode ( ) ) { C_BaseCombatWeapon * pWeapon = GetSelectedWeapon ( ) ; if ( ! pWeapon ) return ; pNextWeapon = FindNextWeaponInWeaponSelection ( pWeapon -> GetSlot ( ) , pWeapon -> GetPosition ( ) ) ; } else { pNextWeapon = pPlayer -> GetActiveWeapon ( ) ; if ( pNextWeapon ) { pNextWeapon = FindNextWeaponInWeaponSelection ( pNextWeapon -> GetSlot ( ) , pNextWeapon -> GetPosition ( ) ) ; } } if ( ! pNextWeapon ) { pNextWeapon = FindNextWeaponInWeaponSelection ( -1 , -1 ) ; } if ( pNextWeapon ) { SetSelectedWeapon ( pNextWeapon ) ; if ( hud_fastswitch . GetInt ( ) > 0 ) { SelectWeapon ( ) ; } else if ( ! IsInSelectionMode ( ) ) { OpenSelection ( ) ; } pPlayer -> EmitSound ( " " ) ; } }
Purpose: Moves the selection to the next item in the menu
Purpose : Moves the selection to the next item in the menu
// Get the local player. // find the next selection spot // open selection at the current place // wrap around back to start // Play the "cycle to next weapon" sound