From 82afcfedc88c31ae73d74befe6becdc718671294 Mon Sep 17 00:00:00 2001 From: hlstriker Date: Fri, 8 Nov 2013 08:53:16 +0000 Subject: [PATCH] Exposed glowing to all CBaseEntity to make everyones life easier. You can now set the glow RGBA as well. --- mp/src/game/client/c_basecombatcharacter.cpp | 25 +++++++ mp/src/game/client/c_basecombatcharacter.h | 17 +++++ mp/src/game/client/c_baseentity.cpp | 68 ++++++++++++++++++++ mp/src/game/client/c_baseentity.h | 21 ++++++ mp/src/game/client/clientmode_shared.cpp | 13 +++- mp/src/game/server/basecombatcharacter.cpp | 25 +++++++ mp/src/game/server/basecombatcharacter.h | 14 +++- mp/src/game/server/baseentity.cpp | 42 ++++++++++++ mp/src/game/server/baseentity.h | 13 ++++ mp/src/game/server/ff/ff_sv_player.cpp | 2 - 10 files changed, 234 insertions(+), 6 deletions(-) diff --git a/mp/src/game/client/c_basecombatcharacter.cpp b/mp/src/game/client/c_basecombatcharacter.cpp index 88309a57..a494c9ff 100644 --- a/mp/src/game/client/c_basecombatcharacter.cpp +++ b/mp/src/game/client/c_basecombatcharacter.cpp @@ -30,11 +30,15 @@ C_BaseCombatCharacter::C_BaseCombatCharacter() m_iAmmo.Set( i, 0 ); } +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE m_pGlowEffect = NULL; m_bGlowEnabled = false; m_bOldGlowEnabled = false; #endif // GLOWS_ENABLE +*/ +// FF <-- } //----------------------------------------------------------------------------- @@ -42,9 +46,13 @@ C_BaseCombatCharacter::C_BaseCombatCharacter() //----------------------------------------------------------------------------- C_BaseCombatCharacter::~C_BaseCombatCharacter() { +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE DestroyGlowEffect(); #endif // GLOWS_ENABLE +*/ +// FF <-- } /* @@ -64,9 +72,13 @@ void C_BaseCombatCharacter::OnPreDataChanged( DataUpdateType_t updateType ) { BaseClass::OnPreDataChanged( updateType ); +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE m_bOldGlowEnabled = m_bGlowEnabled; #endif // GLOWS_ENABLE +*/ +// FF <-- } //----------------------------------------------------------------------------- @@ -76,12 +88,16 @@ void C_BaseCombatCharacter::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE if ( m_bOldGlowEnabled != m_bGlowEnabled ) { UpdateGlowEffect(); } #endif // GLOWS_ENABLE +*/ +// FF <-- } //----------------------------------------------------------------------------- @@ -102,6 +118,8 @@ void C_BaseCombatCharacter::DoMuzzleFlash() } } +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE //----------------------------------------------------------------------------- // Purpose: @@ -146,6 +164,8 @@ void C_BaseCombatCharacter::DestroyGlowEffect( void ) } } #endif // GLOWS_ENABLE +*/ +// FF <-- IMPLEMENT_CLIENTCLASS(C_BaseCombatCharacter, DT_BaseCombatCharacter, CBaseCombatCharacter); @@ -159,9 +179,14 @@ BEGIN_RECV_TABLE(C_BaseCombatCharacter, DT_BaseCombatCharacter) RecvPropDataTable( "bcc_localdata", 0, 0, &REFERENCE_RECV_TABLE(DT_BCCLocalPlayerExclusive) ), RecvPropEHandle( RECVINFO( m_hActiveWeapon ) ), RecvPropArray3( RECVINFO_ARRAY(m_hMyWeapons), RecvPropEHandle( RECVINFO( m_hMyWeapons[0] ) ) ), + +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE RecvPropBool( RECVINFO( m_bGlowEnabled ) ), #endif // GLOWS_ENABLE +*/ +// FF <-- #ifdef INVASION_CLIENT_DLL RecvPropInt( RECVINFO( m_iPowerups ) ), diff --git a/mp/src/game/client/c_basecombatcharacter.h b/mp/src/game/client/c_basecombatcharacter.h index becc5de2..e0969e7d 100644 --- a/mp/src/game/client/c_basecombatcharacter.h +++ b/mp/src/game/client/c_basecombatcharacter.h @@ -14,9 +14,14 @@ #include "shareddefs.h" #include "c_baseflex.h" + +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE #include "glow_outline_effect.h" #endif // GLOWS_ENABLE +*/ +// FF <-- class C_BaseCombatWeapon; class C_WeaponCombatShield; @@ -94,10 +99,14 @@ public: virtual void DoMuzzleFlash(); +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE CGlowObject *GetGlowObject( void ){ return m_pGlowEffect; } virtual void GetGlowEffectColor( float *r, float *g, float *b ); #endif // GLOWS_ENABLE +*/ +// FF <-- public: @@ -105,10 +114,14 @@ public: protected: +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE virtual void UpdateGlowEffect( void ); virtual void DestroyGlowEffect( void ); #endif // GLOWS_ENABLE +*/ +// FF <-- int m_bloodColor; // color of blood particless @@ -120,11 +133,15 @@ private: CHandle m_hMyWeapons[MAX_WEAPONS]; CHandle< C_BaseCombatWeapon > m_hActiveWeapon; +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE bool m_bGlowEnabled; bool m_bOldGlowEnabled; CGlowObject *m_pGlowEffect; #endif // GLOWS_ENABLE +*/ +// FF <-- private: C_BaseCombatCharacter( const C_BaseCombatCharacter & ); // not defined, not accessible diff --git a/mp/src/game/client/c_baseentity.cpp b/mp/src/game/client/c_baseentity.cpp index 89b503d4..da47db0b 100644 --- a/mp/src/game/client/c_baseentity.cpp +++ b/mp/src/game/client/c_baseentity.cpp @@ -41,6 +41,12 @@ #include "inetchannelinfo.h" #include "proto_version.h" +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE +#include "glow_outline_effect.h" +#endif // GLOWS_ENABLE +// FF <-- + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -477,6 +483,13 @@ BEGIN_RECV_TABLE_NOBASE(C_BaseEntity, DT_BaseEntity) RecvPropArray3( RECVINFO_ARRAY(m_nModelIndexOverrides), RecvPropInt( RECVINFO(m_nModelIndexOverrides[0]) ) ), #endif +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE + RecvPropBool(RECVINFO(m_bGlowEnabled)), + RecvPropInt(RECVINFO(m_clrGlowColor)), +#endif // GLOWS_ENABLE +// FF <-- + END_RECV_TABLE() const float coordTolerance = 2.0f / (float)( 1 << COORD_FRACTIONAL_BITS ); @@ -957,6 +970,14 @@ C_BaseEntity::C_BaseEntity() : #endif ParticleProp()->Init( this ); + + // FF --> hlstriker: Added +#ifdef GLOWS_ENABLE + m_pGlowEffect = NULL; + m_bGlowEnabled = false; + m_bOldGlowEnabled = false; +#endif GLOWS_ENABLE + // FF <-- } @@ -967,6 +988,8 @@ C_BaseEntity::C_BaseEntity() : //----------------------------------------------------------------------------- C_BaseEntity::~C_BaseEntity() { + DestroyGlowEffect(); // FF --> hlstriker: Added + Term(); ClearDataChangedEvent( m_DataChangeEventRef ); #if !defined( NO_ENTITY_PREDICTION ) @@ -3254,12 +3277,22 @@ void C_BaseEntity::AddVisibleEntities() //----------------------------------------------------------------------------- void C_BaseEntity::OnPreDataChanged( DataUpdateType_t type ) { + // FF --> hlstriker: Added + m_bOldGlowEnabled = m_bGlowEnabled; + m_clrOldGlowColor = m_clrGlowColor; + // FF <-- + m_hOldMoveParent = m_hNetworkMoveParent; m_iOldParentAttachment = m_iParentAttachment; } void C_BaseEntity::OnDataChanged( DataUpdateType_t type ) { + // FF --> hlstriker: Added + if ( m_bOldGlowEnabled != m_bGlowEnabled || m_clrOldGlowColor != m_clrGlowColor ) + UpdateGlowEffect(); + // FF <-- + // See if it needs to allocate prediction stuff CheckInitPredictable( "OnDataChanged" ); @@ -3272,6 +3305,41 @@ void C_BaseEntity::OnDataChanged( DataUpdateType_t type ) } } +// FF --> hlstriker: Added +void C_BaseEntity::GetGlowEffectColor( float *r, float *g, float *b, float *a ) +{ + *r = m_clrGlowColor.r / 255.0f; + *g = m_clrGlowColor.g / 255.0f; + *b = m_clrGlowColor.b / 255.0f; + *a = m_clrGlowColor.a / 255.0f; +} + +void C_BaseEntity::UpdateGlowEffect( void ) +{ + // destroy the existing effect + if ( m_pGlowEffect ) + DestroyGlowEffect(); + + // create a new effect + if ( m_bGlowEnabled ) + { + float r, g, b, a; + GetGlowEffectColor( &r, &g, &b, &a ); + + m_pGlowEffect = new CGlowObject( this, Vector( r, g, b ), a, true, true ); + } +} + +void C_BaseEntity::DestroyGlowEffect( void ) +{ + if ( m_pGlowEffect ) + { + delete m_pGlowEffect; + m_pGlowEffect = NULL; + } +} +// FF <-- + ClientThinkHandle_t C_BaseEntity::GetThinkHandle() { return m_hThink; diff --git a/mp/src/game/client/c_baseentity.h b/mp/src/game/client/c_baseentity.h index e00513df..d1264df4 100644 --- a/mp/src/game/client/c_baseentity.h +++ b/mp/src/game/client/c_baseentity.h @@ -36,6 +36,12 @@ #include "toolframework/itoolentity.h" #include "tier0/threadtools.h" +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE +class CGlowObject; +#endif // GLOWS_ENABLE +// FF <-- + class C_Team; class IPhysicsObject; class IClientVehicle; @@ -1687,6 +1693,21 @@ protected: RenderMode_t m_PreviousRenderMode; color32 m_PreviousRenderColor; #endif + +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE +private: + void UpdateGlowEffect( void ); + void DestroyGlowEffect( void ); + void GetGlowEffectColor( float *r, float *g, float *b, float *a ); + + CGlowObject *m_pGlowEffect; + bool m_bGlowEnabled; + bool m_bOldGlowEnabled; + color32 m_clrGlowColor; + color32 m_clrOldGlowColor; +#endif // GLOWS_ENABLE +// FF <-- }; EXTERN_RECV_TABLE(DT_BaseEntity); diff --git a/mp/src/game/client/clientmode_shared.cpp b/mp/src/game/client/clientmode_shared.cpp index b5f15daa..15ca7593 100644 --- a/mp/src/game/client/clientmode_shared.cpp +++ b/mp/src/game/client/clientmode_shared.cpp @@ -65,6 +65,12 @@ extern ConVar replay_rendersetting_renderglow; #include "econ_item_description.h" #endif +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE +#include "glow_outline_effect.h" +#endif // GLOWS_ENABLE +// FF <-- + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -739,13 +745,16 @@ int ClientModeShared::HudElementKeyInput( int down, ButtonCode_t keynum, const c return 1; } - //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool ClientModeShared::DoPostScreenSpaceEffects( const CViewSetup *pSetup ) { - g_GlowObjectManager.RenderGlowEffects( pSetup, 0 /*GetSplitScreenPlayerSlot()*/ ); // FF --> hlstriker: Added +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE + g_GlowObjectManager.RenderGlowEffects( pSetup, 0 /*GetSplitScreenPlayerSlot()*/ ); +#endif // GLOWS_ENABLE +// FF <-- #if defined( REPLAY_ENABLED ) if ( engine->IsPlayingDemo() ) diff --git a/mp/src/game/server/basecombatcharacter.cpp b/mp/src/game/server/basecombatcharacter.cpp index 7fb5cce1..ce52839b 100644 --- a/mp/src/game/server/basecombatcharacter.cpp +++ b/mp/src/game/server/basecombatcharacter.cpp @@ -190,9 +190,14 @@ END_SEND_TABLE(); // This table encodes the CBaseCombatCharacter //----------------------------------------------------------------------------- IMPLEMENT_SERVERCLASS_ST(CBaseCombatCharacter, DT_BaseCombatCharacter) +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE SendPropBool( SENDINFO( m_bGlowEnabled ) ), #endif // GLOWS_ENABLE +*/ +// FF <-- + // Data that only gets sent to the local player. SendPropDataTable( "bcc_localdata", 0, &REFERENCE_SEND_TABLE(DT_BCCLocalPlayerExclusive), SendProxy_SendBaseCombatCharacterLocalDataTable ), @@ -744,9 +749,13 @@ CBaseCombatCharacter::CBaseCombatCharacter( void ) m_bForceServerRagdoll = ai_force_serverside_ragdoll.GetBool(); +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE m_bGlowEnabled.Set( false ); #endif // GLOWS_ENABLE +*/ +// FF <-- } //------------------------------------------------------------------------------ @@ -851,9 +860,13 @@ void CBaseCombatCharacter::UpdateOnRemove( void ) SetOwnerEntity( NULL ); } +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE RemoveGlowEffect(); #endif // GLOWS_ENABLE +*/ +// FF <-- // Chain at end to mimic destructor unwind order BaseClass::UpdateOnRemove(); @@ -1677,9 +1690,13 @@ void CBaseCombatCharacter::Event_Killed( const CTakeDamageInfo &info ) TheNextBots().OnKilled( this, info ); #endif +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE RemoveGlowEffect(); #endif // GLOWS_ENABLE +*/ +// FF <-- } void CBaseCombatCharacter::Event_Dying( const CTakeDamageInfo &info ) @@ -3230,6 +3247,8 @@ float CBaseCombatCharacter::GetSpreadBias( CBaseCombatWeapon *pWeapon, CBaseEnti return 1.0; } +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE //----------------------------------------------------------------------------- // Purpose: @@ -3256,6 +3275,8 @@ bool CBaseCombatCharacter::IsGlowEffectActive( void ) return m_bGlowEnabled; } #endif // GLOWS_ENABLE +*/ +// FF <-- //----------------------------------------------------------------------------- // Assume everyone is average with every weapon. Override this to make exceptions. @@ -3522,9 +3543,13 @@ void CBaseCombatCharacter::ChangeTeam( int iTeamNum ) // old team member no longer in the nav mesh ClearLastKnownArea(); +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE RemoveGlowEffect(); #endif // GLOWS_ENABLE +*/ +// FF <-- BaseClass::ChangeTeam( iTeamNum ); } diff --git a/mp/src/game/server/basecombatcharacter.h b/mp/src/game/server/basecombatcharacter.h index f16f2c7f..d961e383 100644 --- a/mp/src/game/server/basecombatcharacter.h +++ b/mp/src/game/server/basecombatcharacter.h @@ -412,12 +412,16 @@ public: // ----------------------- virtual void OnPursuedBy( INextBot * RESTRICT pPursuer ){} // called every frame while pursued by a bot in DirectChase. +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE // Glows void AddGlowEffect( void ); void RemoveGlowEffect( void ); bool IsGlowEffectActive( void ); #endif // GLOWS_ENABLE +*/ +// FF <-- #ifdef INVASION_DLL public: @@ -456,16 +460,22 @@ protected: public: CNetworkVar( float, m_flNextAttack ); // cannot attack again until this time +// FF --> hlstriker: Commented. +/* #ifdef GLOWS_ENABLE protected: CNetworkVar( bool, m_bGlowEnabled ); #endif // GLOWS_ENABLE +*/ +// FF <-- private: Hull_t m_eHull; - void UpdateGlowEffect( void ); - void DestroyGlowEffect( void ); + // FF --> hlstriker: Commented because they aren't used. + //void UpdateGlowEffect( void ); + //void DestroyGlowEffect( void ); + // FF <-- protected: int m_bloodColor; // color of blood particless diff --git a/mp/src/game/server/baseentity.cpp b/mp/src/game/server/baseentity.cpp index 48f1a4a7..7e365558 100644 --- a/mp/src/game/server/baseentity.cpp +++ b/mp/src/game/server/baseentity.cpp @@ -306,6 +306,13 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE( CBaseEntity, DT_BaseEntity ) SendPropArray3( SENDINFO_ARRAY3(m_nModelIndexOverrides), SendPropInt( SENDINFO_ARRAY(m_nModelIndexOverrides), SP_MODEL_INDEX_BITS, SPROP_UNSIGNED ) ), #endif +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE + SendPropBool( SENDINFO( m_bGlowEnabled ) ), + SendPropInt( SENDINFO( m_clrGlowColor ) ), +#endif // GLOWS_ENABLE +// FF <-- + END_SEND_TABLE() @@ -412,6 +419,14 @@ CBaseEntity::CBaseEntity( bool bServerOnly ) #ifndef _XBOX AddEFlags( EFL_USE_PARTITION_WHEN_NOT_SOLID ); #endif + + // FF --> hlstriker: Added + m_bGlowEnabled.Set( false ); + m_clrGlowColor.SetR( 255 ); + m_clrGlowColor.SetG( 255 ); + m_clrGlowColor.SetB( 255 ); + m_clrGlowColor.SetA( 175 ); + // FF <-- } //----------------------------------------------------------------------------- @@ -1607,6 +1622,8 @@ int CBaseEntity::VPhysicsTakeDamage( const CTakeDamageInfo &info ) // Character killed (only fired once) void CBaseEntity::Event_Killed( const CTakeDamageInfo &info ) { + RemoveGlowEffect(); // FF --> hlstriker: Added + if( info.GetAttacker() ) { info.GetAttacker()->Event_KilledOther(this, info); @@ -2054,6 +2071,8 @@ void CBaseEntity::UpdateOnRemove( void ) modelinfo->ReleaseDynamicModel( m_nModelIndex ); // no-op if not dynamic m_nModelIndex = -1; } + + RemoveGlowEffect(); // FF --> hlstriker: Added } //----------------------------------------------------------------------------- @@ -7294,6 +7313,29 @@ void CBaseEntity::SetCollisionBoundsFromModel() } } +// FF --> hlstriker: Added +#ifdef GLOWS_ENABLE +void CBaseEntity::AddGlowEffect( int red, int green, int blue, int alpha ) +{ + SetTransmitState( FL_EDICT_ALWAYS ); + m_clrGlowColor.SetR( red ); + m_clrGlowColor.SetG( green ); + m_clrGlowColor.SetB( blue ); + m_clrGlowColor.SetA( alpha ); + m_bGlowEnabled.Set( true ); +} + +void CBaseEntity::RemoveGlowEffect( void ) +{ + m_bGlowEnabled.Set( false ); +} + +bool CBaseEntity::IsGlowEffectActive( void ) +{ + return m_bGlowEnabled; +} +#endif // GLOWS_ENABLE +// FF <-- //------------------------------------------------------------------------------ // Purpose: Create an NPC of the given type diff --git a/mp/src/game/server/baseentity.h b/mp/src/game/server/baseentity.h index 7bcc3c2e..16747490 100644 --- a/mp/src/game/server/baseentity.h +++ b/mp/src/game/server/baseentity.h @@ -1791,6 +1791,19 @@ public: { return s_bAbsQueriesValid; } + +// FF --> hlstriker: Added. +#ifdef GLOWS_ENABLE +protected: + CNetworkVar( bool, m_bGlowEnabled ); + CNetworkColor32( m_clrGlowColor ); + +public: + void AddGlowEffect( int red, int green, int blue, int alpha ); + void RemoveGlowEffect( void ); + bool IsGlowEffectActive( void ); +#endif // GLOWS_ENABLE +// FF <-- }; // Send tables exposed in this module. diff --git a/mp/src/game/server/ff/ff_sv_player.cpp b/mp/src/game/server/ff/ff_sv_player.cpp index 1e596d26..9fa9414d 100644 --- a/mp/src/game/server/ff/ff_sv_player.cpp +++ b/mp/src/game/server/ff/ff_sv_player.cpp @@ -419,8 +419,6 @@ void CFF_SV_Player::SetPlayerTeamModel( void ) SetupPlayerSoundsByModel( szModelName ); m_flNextModelChangeTime = gpGlobals->curtime + MODEL_CHANGE_INTERVAL; - - AddGlowEffect(); } void CFF_SV_Player::SetPlayerModel( void )