summaryrefslogtreecommitdiff
path: root/game/client/c_recipientfilter.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/c_recipientfilter.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/c_recipientfilter.h')
-rw-r--r--game/client/c_recipientfilter.h189
1 files changed, 189 insertions, 0 deletions
diff --git a/game/client/c_recipientfilter.h b/game/client/c_recipientfilter.h
new file mode 100644
index 0000000..d501452
--- /dev/null
+++ b/game/client/c_recipientfilter.h
@@ -0,0 +1,189 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef C_RECIPIENTFILTER_H
+#define C_RECIPIENTFILTER_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "irecipientfilter.h"
+#include "utlvector.h"
+#include "c_baseentity.h"
+#include "soundflags.h"
+#include "bitvec.h"
+
+class C_BasePlayer;
+class C_Team;
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+class C_RecipientFilter : public IRecipientFilter
+{
+public:
+ C_RecipientFilter();
+ virtual ~C_RecipientFilter();
+
+ virtual bool IsReliable( void ) const;
+
+ virtual int GetRecipientCount( void ) const;
+ virtual int GetRecipientIndex( int slot ) const;
+
+ virtual bool IsInitMessage( void ) const { return false; };
+
+public:
+
+ void CopyFrom( const C_RecipientFilter& src );
+
+ void Reset( void );
+
+ void MakeReliable( void );
+
+ void AddAllPlayers( void );
+ void AddRecipientsByPVS( const Vector& origin );
+ void AddRecipientsByPAS( const Vector& origin );
+ void AddRecipient( C_BasePlayer *player );
+ void RemoveRecipient( C_BasePlayer *player );
+ void AddRecipientsByTeam( C_Team *team );
+ void RemoveRecipientsByTeam( C_Team *team );
+
+ void UsePredictionRules( void );
+ bool IsUsingPredictionRules( void ) const;
+
+ bool IgnorePredictionCull( void ) const;
+ void SetIgnorePredictionCull( bool ignore );
+
+ void AddPlayersFromBitMask( CBitVec< ABSOLUTE_PLAYER_LIMIT >& playerbits );
+
+//private:
+
+ bool m_bReliable;
+ bool m_bInitMessage;
+ CUtlVector< int > m_Recipients;
+ // If using prediction rules, the filter itself suppresses local player
+ bool m_bUsingPredictionRules;
+ // If ignoring prediction cull, then external systems can determine
+ // whether this is a special case where culling should not occur
+ bool m_bIgnorePredictionCull;
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Simple class to create a filter for a single player
+//-----------------------------------------------------------------------------
+class CSingleUserRecipientFilter : public C_RecipientFilter
+{
+public:
+ CSingleUserRecipientFilter( C_BasePlayer *player )
+ {
+ AddRecipient( player );
+ }
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Simple class to create a filter for all players, unreliable
+//-----------------------------------------------------------------------------
+class CBroadcastRecipientFilter : public C_RecipientFilter
+{
+public:
+ CBroadcastRecipientFilter( void )
+ {
+ AddAllPlayers();
+ }
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Simple class to create a filter for all players, reliable
+//-----------------------------------------------------------------------------
+class CReliableBroadcastRecipientFilter : public CBroadcastRecipientFilter
+{
+public:
+ CReliableBroadcastRecipientFilter( void )
+ {
+ MakeReliable();
+ }
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Simple class to create a filter for a single player
+//-----------------------------------------------------------------------------
+class CPASFilter : public C_RecipientFilter
+{
+public:
+ CPASFilter( const Vector& origin )
+ {
+ AddRecipientsByPAS( origin );
+ }
+};
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+class CPASAttenuationFilter : public CPASFilter
+{
+public:
+ CPASAttenuationFilter( C_BaseEntity *entity, float attenuation = ATTN_NORM ) :
+ CPASFilter( entity->GetAbsOrigin() )
+ {
+ }
+
+ CPASAttenuationFilter( const Vector& origin, float attenuation = ATTN_NORM ) :
+ CPASFilter( origin )
+ {
+ }
+
+ CPASAttenuationFilter( C_BaseEntity *entity, const char *lookupSound ) :
+ CPASFilter( entity->GetAbsOrigin() )
+ {
+ }
+
+ CPASAttenuationFilter( const Vector& origin, const char *lookupSound ) :
+ CPASFilter( origin )
+ {
+ }
+
+ CPASAttenuationFilter( C_BaseEntity *entity, const char *lookupSound, HSOUNDSCRIPTHANDLE& handle ) :
+ CPASFilter( entity->GetAbsOrigin() )
+ {
+ }
+
+ CPASAttenuationFilter( const Vector& origin, const char *lookupSound, HSOUNDSCRIPTHANDLE& handle ) :
+ CPASFilter( origin )
+ {
+ }
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Simple class to create a filter for a single player
+//-----------------------------------------------------------------------------
+class CPVSFilter : public C_RecipientFilter
+{
+public:
+ CPVSFilter( const Vector& origin )
+ {
+ AddRecipientsByPVS( origin );
+ }
+};
+
+class CLocalPlayerFilter : public C_RecipientFilter
+{
+public:
+ CLocalPlayerFilter( void );
+};
+
+class CUIFilter : public C_RecipientFilter
+{
+public:
+ CUIFilter( void )
+ {
+ m_Recipients.AddToTail( 1 );
+// AddRecipient( 0 );
+ }
+};
+
+
+#endif // C_RECIPIENTFILTER_H