diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/shared/sdk/weapon_sdkbase.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/shared/sdk/weapon_sdkbase.cpp')
| -rw-r--r-- | mp/src/game/shared/sdk/weapon_sdkbase.cpp | 324 |
1 files changed, 162 insertions, 162 deletions
diff --git a/mp/src/game/shared/sdk/weapon_sdkbase.cpp b/mp/src/game/shared/sdk/weapon_sdkbase.cpp index bba6a2a3..f6e59291 100644 --- a/mp/src/game/shared/sdk/weapon_sdkbase.cpp +++ b/mp/src/game/shared/sdk/weapon_sdkbase.cpp @@ -1,163 +1,163 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#include "cbase.h"
-#include "in_buttons.h"
-#include "takedamageinfo.h"
-#include "weapon_sdkbase.h"
-#include "ammodef.h"
-
-
-#if defined( CLIENT_DLL )
-
- #include "c_sdk_player.h"
-
-#else
-
- #include "sdk_player.h"
-
-#endif
-
-
-// ----------------------------------------------------------------------------- //
-// Global functions.
-// ----------------------------------------------------------------------------- //
-
-//--------------------------------------------------------------------------------------------------------
-static const char * s_WeaponAliasInfo[] =
-{
- "none", // WEAPON_NONE
- "mp5", // WEAPON_MP5
- "shotgun", // WEAPON_SHOTGUN
- "grenade", // WEAPON_GRENADE
- NULL, // WEAPON_NONE
-};
-
-//--------------------------------------------------------------------------------------------------------
-//
-// Given an alias, return the associated weapon ID
-//
-int AliasToWeaponID( const char *alias )
-{
- if (alias)
- {
- for( int i=0; s_WeaponAliasInfo[i] != NULL; ++i )
- if (!Q_stricmp( s_WeaponAliasInfo[i], alias ))
- return i;
- }
-
- return WEAPON_NONE;
-}
-
-//--------------------------------------------------------------------------------------------------------
-//
-// Given a weapon ID, return its alias
-//
-const char *WeaponIDToAlias( int id )
-{
- if ( (id >= WEAPON_MAX) || (id < 0) )
- return NULL;
-
- return s_WeaponAliasInfo[id];
-}
-
-// ----------------------------------------------------------------------------- //
-// CWeaponSDKBase tables.
-// ----------------------------------------------------------------------------- //
-
-IMPLEMENT_NETWORKCLASS_ALIASED( WeaponSDKBase, DT_WeaponSDKBase )
-
-BEGIN_NETWORK_TABLE( CWeaponSDKBase, DT_WeaponSDKBase )
-#ifdef CLIENT_DLL
-
-#else
- // world weapon models have no animations
- SendPropExclude( "DT_AnimTimeMustBeFirst", "m_flAnimTime" ),
- SendPropExclude( "DT_BaseAnimating", "m_nSequence" ),
-#endif
-END_NETWORK_TABLE()
-
-#ifdef CLIENT_DLL
-BEGIN_PREDICTION_DATA( CWeaponSDKBase )
- DEFINE_PRED_FIELD( m_flTimeWeaponIdle, FIELD_FLOAT, FTYPEDESC_OVERRIDE | FTYPEDESC_NOERRORCHECK ),
-END_PREDICTION_DATA()
-#endif
-
-LINK_ENTITY_TO_CLASS( weapon_sdk_base, CWeaponSDKBase );
-
-
-#ifdef GAME_DLL
-
- BEGIN_DATADESC( CWeaponSDKBase )
-
- // New weapon Think and Touch Functions go here..
-
- END_DATADESC()
-
-#endif
-
-// ----------------------------------------------------------------------------- //
-// CWeaponCSBase implementation.
-// ----------------------------------------------------------------------------- //
-CWeaponSDKBase::CWeaponSDKBase()
-{
- SetPredictionEligible( true );
-
- AddSolidFlags( FSOLID_TRIGGER ); // Nothing collides with these but it gets touches.
-}
-
-const CSDKWeaponInfo &CWeaponSDKBase::GetSDKWpnData() const
-{
- const FileWeaponInfo_t *pWeaponInfo = &GetWpnData();
- const CSDKWeaponInfo *pSDKInfo;
-
- #ifdef _DEBUG
- pSDKInfo = dynamic_cast< const CSDKWeaponInfo* >( pWeaponInfo );
- Assert( pSDKInfo );
- #else
- pSDKInfo = static_cast< const CSDKWeaponInfo* >( pWeaponInfo );
- #endif
-
- return *pSDKInfo;
-}
-
-bool CWeaponSDKBase::PlayEmptySound()
-{
- CPASAttenuationFilter filter( this );
- filter.UsePredictionRules();
-
- EmitSound( filter, entindex(), "Default.ClipEmpty_Rifle" );
-
- return 0;
-}
-
-CSDKPlayer* CWeaponSDKBase::GetPlayerOwner() const
-{
- return dynamic_cast< CSDKPlayer* >( GetOwner() );
-}
-
-#ifdef GAME_DLL
-
-void CWeaponSDKBase::SendReloadEvents()
-{
- CSDKPlayer *pPlayer = dynamic_cast< CSDKPlayer* >( GetOwner() );
- if ( !pPlayer )
- return;
-
- // Send a message to any clients that have this entity to play the reload.
- CPASFilter filter( pPlayer->GetAbsOrigin() );
- filter.RemoveRecipient( pPlayer );
-
- UserMessageBegin( filter, "ReloadEffect" );
- WRITE_SHORT( pPlayer->entindex() );
- MessageEnd();
-
- // Make the player play his reload animation.
- pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD );
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include "cbase.h" +#include "in_buttons.h" +#include "takedamageinfo.h" +#include "weapon_sdkbase.h" +#include "ammodef.h" + + +#if defined( CLIENT_DLL ) + + #include "c_sdk_player.h" + +#else + + #include "sdk_player.h" + +#endif + + +// ----------------------------------------------------------------------------- // +// Global functions. +// ----------------------------------------------------------------------------- // + +//-------------------------------------------------------------------------------------------------------- +static const char * s_WeaponAliasInfo[] = +{ + "none", // WEAPON_NONE + "mp5", // WEAPON_MP5 + "shotgun", // WEAPON_SHOTGUN + "grenade", // WEAPON_GRENADE + NULL, // WEAPON_NONE +}; + +//-------------------------------------------------------------------------------------------------------- +// +// Given an alias, return the associated weapon ID +// +int AliasToWeaponID( const char *alias ) +{ + if (alias) + { + for( int i=0; s_WeaponAliasInfo[i] != NULL; ++i ) + if (!Q_stricmp( s_WeaponAliasInfo[i], alias )) + return i; + } + + return WEAPON_NONE; +} + +//-------------------------------------------------------------------------------------------------------- +// +// Given a weapon ID, return its alias +// +const char *WeaponIDToAlias( int id ) +{ + if ( (id >= WEAPON_MAX) || (id < 0) ) + return NULL; + + return s_WeaponAliasInfo[id]; +} + +// ----------------------------------------------------------------------------- // +// CWeaponSDKBase tables. +// ----------------------------------------------------------------------------- // + +IMPLEMENT_NETWORKCLASS_ALIASED( WeaponSDKBase, DT_WeaponSDKBase ) + +BEGIN_NETWORK_TABLE( CWeaponSDKBase, DT_WeaponSDKBase ) +#ifdef CLIENT_DLL + +#else + // world weapon models have no animations + SendPropExclude( "DT_AnimTimeMustBeFirst", "m_flAnimTime" ), + SendPropExclude( "DT_BaseAnimating", "m_nSequence" ), +#endif +END_NETWORK_TABLE() + +#ifdef CLIENT_DLL +BEGIN_PREDICTION_DATA( CWeaponSDKBase ) + DEFINE_PRED_FIELD( m_flTimeWeaponIdle, FIELD_FLOAT, FTYPEDESC_OVERRIDE | FTYPEDESC_NOERRORCHECK ), +END_PREDICTION_DATA() +#endif + +LINK_ENTITY_TO_CLASS( weapon_sdk_base, CWeaponSDKBase ); + + +#ifdef GAME_DLL + + BEGIN_DATADESC( CWeaponSDKBase ) + + // New weapon Think and Touch Functions go here.. + + END_DATADESC() + +#endif + +// ----------------------------------------------------------------------------- // +// CWeaponCSBase implementation. +// ----------------------------------------------------------------------------- // +CWeaponSDKBase::CWeaponSDKBase() +{ + SetPredictionEligible( true ); + + AddSolidFlags( FSOLID_TRIGGER ); // Nothing collides with these but it gets touches. +} + +const CSDKWeaponInfo &CWeaponSDKBase::GetSDKWpnData() const +{ + const FileWeaponInfo_t *pWeaponInfo = &GetWpnData(); + const CSDKWeaponInfo *pSDKInfo; + + #ifdef _DEBUG + pSDKInfo = dynamic_cast< const CSDKWeaponInfo* >( pWeaponInfo ); + Assert( pSDKInfo ); + #else + pSDKInfo = static_cast< const CSDKWeaponInfo* >( pWeaponInfo ); + #endif + + return *pSDKInfo; +} + +bool CWeaponSDKBase::PlayEmptySound() +{ + CPASAttenuationFilter filter( this ); + filter.UsePredictionRules(); + + EmitSound( filter, entindex(), "Default.ClipEmpty_Rifle" ); + + return 0; +} + +CSDKPlayer* CWeaponSDKBase::GetPlayerOwner() const +{ + return dynamic_cast< CSDKPlayer* >( GetOwner() ); +} + +#ifdef GAME_DLL + +void CWeaponSDKBase::SendReloadEvents() +{ + CSDKPlayer *pPlayer = dynamic_cast< CSDKPlayer* >( GetOwner() ); + if ( !pPlayer ) + return; + + // Send a message to any clients that have this entity to play the reload. + CPASFilter filter( pPlayer->GetAbsOrigin() ); + filter.RemoveRecipient( pPlayer ); + + UserMessageBegin( filter, "ReloadEffect" ); + WRITE_SHORT( pPlayer->entindex() ); + MessageEnd(); + + // Make the player play his reload animation. + pPlayer->DoAnimationEvent( PLAYERANIMEVENT_RELOAD ); +} + #endif
\ No newline at end of file |