From 9ce0f0f0bb5ca95e2f0423e5b930246315cc0cb3 Mon Sep 17 00:00:00 2001 From: Chris Roxby Date: Sun, 24 Jul 2016 16:26:10 -0400 Subject: [PATCH] Move more code into headers Make sure everything I need to call in my other mod is accessible. I want these simple edits in the base game. --- sp/src/game/server/env_screenoverlay.cpp | 54 +----------------- sp/src/game/server/env_screenoverlay.h | 71 ++++++++++++++++++++++++ sp/src/game/server/filters.cpp | 20 ------- sp/src/game/server/filters.h | 25 +++++++++ sp/src/game/server/tanktrain.cpp | 18 +----- sp/src/game/server/triggers.cpp | 65 ---------------------- sp/src/game/server/triggers.h | 66 ++++++++++++++++++++++ 7 files changed, 164 insertions(+), 155 deletions(-) create mode 100644 sp/src/game/server/env_screenoverlay.h diff --git a/sp/src/game/server/env_screenoverlay.cpp b/sp/src/game/server/env_screenoverlay.cpp index 07bbf08df..dc4024ba2 100644 --- a/sp/src/game/server/env_screenoverlay.cpp +++ b/sp/src/game/server/env_screenoverlay.cpp @@ -6,41 +6,11 @@ #include "cbase.h" #include "shareddefs.h" +#include "env_screenoverlay.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -class CEnvScreenOverlay : public CPointEntity -{ - DECLARE_CLASS( CEnvScreenOverlay, CPointEntity ); -public: - DECLARE_DATADESC(); - DECLARE_SERVERCLASS(); - - CEnvScreenOverlay(); - - // Always transmit to clients - virtual int UpdateTransmitState(); - virtual void Spawn( void ); - virtual void Precache( void ); - - void InputStartOverlay( inputdata_t &inputdata ); - void InputStopOverlay( inputdata_t &inputdata ); - void InputSwitchOverlay( inputdata_t &inputdata ); - - void SetActive( bool bActive ) { m_bIsActive = bActive; } - -protected: - CNetworkArray( string_t, m_iszOverlayNames, MAX_SCREEN_OVERLAYS ); - CNetworkArray( float, m_flOverlayTimes, MAX_SCREEN_OVERLAYS ); - CNetworkVar( float, m_flStartTime ); - CNetworkVar( int, m_iDesiredOverlay ); - CNetworkVar( bool, m_bIsActive ); -}; - LINK_ENTITY_TO_CLASS( env_screenoverlay, CEnvScreenOverlay ); BEGIN_DATADESC( CEnvScreenOverlay ) @@ -193,28 +163,6 @@ void CEnvScreenOverlay::InputStopOverlay( inputdata_t &inputdata ) // // ==================================================================================== -class CEnvScreenEffect : public CPointEntity -{ - DECLARE_CLASS( CEnvScreenEffect, CPointEntity ); -public: - DECLARE_DATADESC(); - DECLARE_SERVERCLASS(); - - // We always want to be sent to the client - CEnvScreenEffect( void ) { AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); } - virtual int UpdateTransmitState( void ) { return SetTransmitState( FL_EDICT_ALWAYS ); } - virtual void Spawn( void ); - virtual void Precache( void ); - -private: - - void InputStartEffect( inputdata_t &inputdata ); - void InputStopEffect( inputdata_t &inputdata ); - - CNetworkVar( float, m_flDuration ); - CNetworkVar( int, m_nType ); -}; - LINK_ENTITY_TO_CLASS( env_screeneffect, CEnvScreenEffect ); // CEnvScreenEffect diff --git a/sp/src/game/server/env_screenoverlay.h b/sp/src/game/server/env_screenoverlay.h new file mode 100644 index 000000000..c7f0153d4 --- /dev/null +++ b/sp/src/game/server/env_screenoverlay.h @@ -0,0 +1,71 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Entity to control screen overlays on a player +// +//=============================================================================// +#ifndef ENVSCREENOVERLAY_H +#define ENVSCREENOVERLAY_H +#ifdef _WIN32 +#pragma once +#endif + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CEnvScreenOverlay : public CPointEntity +{ + DECLARE_CLASS(CEnvScreenOverlay, CPointEntity); +public: + DECLARE_DATADESC(); + DECLARE_SERVERCLASS(); + + CEnvScreenOverlay(); + + // Always transmit to clients + virtual int UpdateTransmitState(); + virtual void Spawn(void); + virtual void Precache(void); + + void InputStartOverlay(inputdata_t &inputdata); + void InputStopOverlay(inputdata_t &inputdata); + void InputSwitchOverlay(inputdata_t &inputdata); + + void SetActive(bool bActive) { m_bIsActive = bActive; } + +protected: + CNetworkArray(string_t, m_iszOverlayNames, MAX_SCREEN_OVERLAYS); + CNetworkArray(float, m_flOverlayTimes, MAX_SCREEN_OVERLAYS); + CNetworkVar(float, m_flStartTime); + CNetworkVar(int, m_iDesiredOverlay); + CNetworkVar(bool, m_bIsActive); +}; + +// ==================================================================================== +// +// Screen-space effects +// +// ==================================================================================== + +class CEnvScreenEffect : public CPointEntity +{ + DECLARE_CLASS(CEnvScreenEffect, CPointEntity); +public: + DECLARE_DATADESC(); + DECLARE_SERVERCLASS(); + + // We always want to be sent to the client + CEnvScreenEffect(void) { AddEFlags(EFL_FORCE_CHECK_TRANSMIT); } + virtual int UpdateTransmitState(void) { return SetTransmitState(FL_EDICT_ALWAYS); } + virtual void Spawn(void); + virtual void Precache(void); + +private: + + void InputStartEffect(inputdata_t &inputdata); + void InputStopEffect(inputdata_t &inputdata); + + CNetworkVar(float, m_flDuration); + CNetworkVar(int, m_nType); +}; + +#endif // ENVSCREENOVERLAY_H diff --git a/sp/src/game/server/filters.cpp b/sp/src/game/server/filters.cpp index 6179254dd..91661861a 100644 --- a/sp/src/game/server/filters.cpp +++ b/sp/src/game/server/filters.cpp @@ -357,26 +357,6 @@ END_DATADESC() // ################################################################### // > FilterDamageType // ################################################################### -class FilterDamageType : public CBaseFilter -{ - DECLARE_CLASS( FilterDamageType, CBaseFilter ); - DECLARE_DATADESC(); - -protected: - - bool PassesFilterImpl(CBaseEntity *pCaller, CBaseEntity *pEntity ) - { - ASSERT( false ); - return true; - } - - bool PassesDamageFilterImpl(const CTakeDamageInfo &info) - { - return info.GetDamageType() == m_iDamageType; - } - - int m_iDamageType; -}; LINK_ENTITY_TO_CLASS( filter_damage_type, FilterDamageType ); diff --git a/sp/src/game/server/filters.h b/sp/src/game/server/filters.h index 483de2438..e5271e6ad 100644 --- a/sp/src/game/server/filters.h +++ b/sp/src/game/server/filters.h @@ -57,4 +57,29 @@ protected: virtual bool PassesDamageFilterImpl(const CTakeDamageInfo &info); }; +// ################################################################### +// > FilterDamageType +// ################################################################### +class FilterDamageType : public CBaseFilter +{ + DECLARE_CLASS(FilterDamageType, CBaseFilter); + DECLARE_DATADESC(); + +protected: + + bool PassesFilterImpl(CBaseEntity *pCaller, CBaseEntity *pEntity) + { + ASSERT(false); + return true; + } + + bool PassesDamageFilterImpl(const CTakeDamageInfo &info) + { + return info.GetDamageType() == m_iDamageType; + } + +public: + int m_iDamageType; +}; + #endif // FILTERS_H diff --git a/sp/src/game/server/tanktrain.cpp b/sp/src/game/server/tanktrain.cpp index d8216a163..46c38a048 100644 --- a/sp/src/game/server/tanktrain.cpp +++ b/sp/src/game/server/tanktrain.cpp @@ -14,10 +14,6 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -extern short g_sModelIndexFireball; -#define SPRITE_FIREBALL "sprites/zerogxplode.vmt" -#define SPRITE_SMOKE "sprites/steam1.vmt" - void UTIL_RemoveHierarchy( CBaseEntity *pDead ) { if ( !pDead ) @@ -44,8 +40,6 @@ public: void Spawn( void ); - // Filter out damage messages that don't contain blast damage (impervious to other forms of attack) - /*int OnTakeDamage( const CTakeDamageInfo &info ); BM: this has to go */ void Event_Killed( const CTakeDamageInfo &info ); void Blocked( CBaseEntity *pOther ) { @@ -70,19 +64,9 @@ END_DATADESC() void CFuncTankTrain::Spawn( void ) { - m_takedamage = DAMAGE_YES; /* BM: true;? */ + m_takedamage = DAMAGE_YES; BaseClass::Spawn(); } -/* BM: What? I don't even... -// Filter out damage messages that don't contain blast damage (impervious to other forms of attack) -int CFuncTankTrain::OnTakeDamage( const CTakeDamageInfo &info ) -{ - if ( ! (info.GetDamageType() & DMG_BLAST) ) - return 0; - - return BaseClass::OnTakeDamage( info ); -} -//*/ //----------------------------------------------------------------------------- // Purpose: Called when the train is killed. diff --git a/sp/src/game/server/triggers.cpp b/sp/src/game/server/triggers.cpp index 6c7a07bbd..ebf382225 100644 --- a/sp/src/game/server/triggers.cpp +++ b/sp/src/game/server/triggers.cpp @@ -2765,71 +2765,6 @@ void CAI_ChangeHintGroup::InputActivate( inputdata_t &inputdata ) #define SF_CAMERA_PLAYER_INTERRUPT 64 #define SF_CAMERA_PLAYER_LOOK 128 // Allow player look to pan/tilt the point_viewcontrol -//----------------------------------------------------------------------------- -// Purpose: -//----------------------------------------------------------------------------- -class CTriggerCamera : public CBaseEntity -{ -public: - DECLARE_CLASS( CTriggerCamera, CBaseEntity ); - - void Spawn( void ); - bool KeyValue( const char *szKeyName, const char *szValue ); - void Enable( void ); - void Disable( void ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void FollowTarget( void ); - void Move(void); - - // Always transmit to clients so they know where to move the view to - virtual int UpdateTransmitState(); - - DECLARE_DATADESC(); - - // Input handlers - void InputEnable( inputdata_t &inputdata ); - void InputDisable( inputdata_t &inputdata ); - -private: - EHANDLE m_hPlayer; - EHANDLE m_hTarget; - - // used for moving the camera along a path (rail rides) - CBaseEntity *m_pPath; - string_t m_sPath; - float m_flWait; - float m_flReturnTime; - float m_flStopTime; - float m_moveDistance; - float m_targetSpeed; - float m_initialSpeed; - float m_acceleration; - float m_deceleration; - int m_state; - Vector m_vecMoveDir; - QAngle m_angOldPlrView; // To save & restore the player's view for the new SF - - string_t m_iszTargetAttachment; - int m_iAttachmentIndex; - bool m_bSnapToGoal; - -#if HL2_EPISODIC - bool m_bInterpolatePosition; - - // these are interpolation vars used for interpolating the camera over time - Vector m_vStartPos, m_vEndPos; - float m_flInterpStartTime; - - const static float kflPosInterpTime; // seconds -#endif - - int m_nPlayerButtons; - int m_nOldTakeDamage; - -private: - COutputEvent m_OnEndFollow; -}; - #if HL2_EPISODIC const float CTriggerCamera::kflPosInterpTime = 2.0f; #endif diff --git a/sp/src/game/server/triggers.h b/sp/src/game/server/triggers.h index 7695d08cc..efd36a8cd 100644 --- a/sp/src/game/server/triggers.h +++ b/sp/src/game/server/triggers.h @@ -207,4 +207,70 @@ public: CUtlVector m_hurtEntities; }; +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CTriggerCamera : public CBaseEntity +{ +public: + DECLARE_CLASS(CTriggerCamera, CBaseEntity); + + void Spawn(void); + bool KeyValue(const char *szKeyName, const char *szValue); + void Enable(void); + void Disable(void); + void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); + void FollowTarget(void); + void Move(void); + + // Always transmit to clients so they know where to move the view to + virtual int UpdateTransmitState(); + + DECLARE_DATADESC(); + + // Input handlers + void InputEnable(inputdata_t &inputdata); + void InputDisable(inputdata_t &inputdata); + +private: + EHANDLE m_hPlayer; + EHANDLE m_hTarget; + + // used for moving the camera along a path (rail rides) + CBaseEntity *m_pPath; + string_t m_sPath; + float m_flWait; + float m_flReturnTime; + float m_flStopTime; + float m_moveDistance; + float m_targetSpeed; + float m_initialSpeed; + float m_acceleration; + float m_deceleration; + int m_state; + Vector m_vecMoveDir; + QAngle m_angOldPlrView; // To save & restore the player's view for the new SF + + + string_t m_iszTargetAttachment; + int m_iAttachmentIndex; + bool m_bSnapToGoal; + +#if HL2_EPISODIC + bool m_bInterpolatePosition; + + // these are interpolation vars used for interpolating the camera over time + Vector m_vStartPos, m_vEndPos; + float m_flInterpStartTime; + + const static float kflPosInterpTime; // seconds +#endif + + int m_nPlayerButtons; + int m_nOldTakeDamage; + +private: + COutputEvent m_OnEndFollow; +}; + #endif // TRIGGERS_H