diff --git a/src/game/client/weapon_selection.cpp b/src/game/client/weapon_selection.cpp index 45334fcdc..835b4add1 100644 --- a/src/game/client/weapon_selection.cpp +++ b/src/game/client/weapon_selection.cpp @@ -400,6 +400,38 @@ void CBaseHudWeaponSelection::UserCmd_Slot10(void) SelectSlot( 10 ); } +void ClientInstantPhysSwap() +{ + C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); + if ( !pPlayer ) + return; + + C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); + if ( !pWeapon ) + return; + + const char *strWeaponName = pWeapon->GetName(); + + if ( !Q_stricmp( strWeaponName, "weapon_physcannon" ) ) + { + input->MakeWeaponSelection( pPlayer->GetLastWeapon() ); // back to previous weapon + } + else + { + for ( int i = 0; i < pPlayer->WeaponCount(); ++i ) + { + C_BaseCombatWeapon *pWeapon = pPlayer->GetWeapon( i ); + if ( pWeapon && !Q_stricmp( pWeapon->GetClassname(), "weapon_physcannon" ) ) // switch to physcannon + { + input->MakeWeaponSelection( pWeapon ); + return; + } + } + } +} + +static ConCommand cl_physswap( "phys_swap", ClientInstantPhysSwap, "Client-predicted physcannon swap for low-latency switching." ); + //----------------------------------------------------------------------------- // Purpose: returns true if the CHudMenu should take slot1, etc commands //----------------------------------------------------------------------------- diff --git a/src/game/server/client.cpp b/src/game/server/client.cpp index ae1840256..c774c7ef7 100644 --- a/src/game/server/client.cpp +++ b/src/game/server/client.cpp @@ -1038,40 +1038,6 @@ void CC_Player_TestDispatchEffect( const CCommand &args ) static ConCommand test_dispatcheffect("test_dispatcheffect", CC_Player_TestDispatchEffect, "Test a clientside dispatch effect.\n\tUsage: test_dispatcheffect \n\tDefaults are: \n", FCVAR_CHEAT); -#ifdef HL2_DLL -//----------------------------------------------------------------------------- -// Purpose: Quickly switch to the physics cannon, or back to previous item -//----------------------------------------------------------------------------- -void CC_Player_PhysSwap( void ) -{ - CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() ); - - if ( pPlayer ) - { - CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); - - if ( pWeapon ) - { - // Tell the client to stop selecting weapons - engine->ClientCommand( UTIL_GetCommandClient()->edict(), "cancelselect" ); - - const char *strWeaponName = pWeapon->GetName(); - - if ( !Q_stricmp( strWeaponName, "weapon_physcannon" ) ) - { - PhysCannonForceDrop( pWeapon, NULL ); - pPlayer->SelectLastItem(); - } - else - { - pPlayer->SelectItem( "weapon_physcannon" ); - } - } - } -} -static ConCommand physswap("phys_swap", CC_Player_PhysSwap, "Automatically swaps the current weapon for the physcannon and back again." ); -#endif - //----------------------------------------------------------------------------- // Purpose: Quickly switch to the bug bait, or back to previous item //-----------------------------------------------------------------------------