From 36c964327f97af90898dfda8b0511e0a337c6f5d Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Mon, 21 Dec 2020 23:09:15 +0900 Subject: [PATCH 1/2] Fixed compilation errors with CS:GO and Blade. --- .../modules/entities/blade/entities_props.h | 4 +- .../entities/blade/entities_props_wrap.h | 2 +- .../modules/entities/csgo/entities_props.h | 4 +- .../entities/csgo/entities_props_wrap.h | 2 +- .../blade/game/server/recipientfilter.h | 230 ++++++++++++++++++ .../csgo/game/server/recipientfilter.h | 230 ++++++++++++++++++ 6 files changed, 466 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/core/modules/entities/blade/entities_props.h mode change 100644 => 100755 src/core/modules/entities/blade/entities_props_wrap.h mode change 100644 => 100755 src/core/modules/entities/csgo/entities_props.h mode change 100644 => 100755 src/core/modules/entities/csgo/entities_props_wrap.h create mode 100755 src/patches/blade/game/server/recipientfilter.h create mode 100755 src/patches/csgo/game/server/recipientfilter.h diff --git a/src/core/modules/entities/blade/entities_props.h b/src/core/modules/entities/blade/entities_props.h old mode 100644 new mode 100755 index 865617fd1..62bee5543 --- a/src/core/modules/entities/blade/entities_props.h +++ b/src/core/modules/entities/blade/entities_props.h @@ -34,9 +34,9 @@ //----------------------------------------------------------------------------- -// ServerClass extension class. +// ServerClass specific extension class. //----------------------------------------------------------------------------- -class ServerClassExt +class ServerClassSpecificExt { public: static const char *get_name(ServerClass *pServerClass) diff --git a/src/core/modules/entities/blade/entities_props_wrap.h b/src/core/modules/entities/blade/entities_props_wrap.h old mode 100644 new mode 100755 index e48ba54ed..d8f27195d --- a/src/core/modules/entities/blade/entities_props_wrap.h +++ b/src/core/modules/entities/blade/entities_props_wrap.h @@ -41,7 +41,7 @@ template void export_engine_specific_server_class(T _props, U ServerClass_) { - ServerClass_.add_property("name", &ServerClassExt::get_name); + ServerClass_.add_property("name", &ServerClassSpecificExt::get_name); } diff --git a/src/core/modules/entities/csgo/entities_props.h b/src/core/modules/entities/csgo/entities_props.h old mode 100644 new mode 100755 index 36e5fdef5..a9bef1eda --- a/src/core/modules/entities/csgo/entities_props.h +++ b/src/core/modules/entities/csgo/entities_props.h @@ -34,9 +34,9 @@ //----------------------------------------------------------------------------- -// ServerClass extension class. +// ServerClass specific extension class. //----------------------------------------------------------------------------- -class ServerClassExt +class ServerClassSpecificExt { public: static const char *get_name(ServerClass *pServerClass) diff --git a/src/core/modules/entities/csgo/entities_props_wrap.h b/src/core/modules/entities/csgo/entities_props_wrap.h old mode 100644 new mode 100755 index 6334a5a0a..80d2d6406 --- a/src/core/modules/entities/csgo/entities_props_wrap.h +++ b/src/core/modules/entities/csgo/entities_props_wrap.h @@ -41,7 +41,7 @@ template void export_engine_specific_server_class(T _props, U ServerClass_) { - ServerClass_.add_property("name", &ServerClassExt::get_name); + ServerClass_.add_property("name", &ServerClassSpecificExt::get_name); } diff --git a/src/patches/blade/game/server/recipientfilter.h b/src/patches/blade/game/server/recipientfilter.h new file mode 100755 index 000000000..0258192df --- /dev/null +++ b/src/patches/blade/game/server/recipientfilter.h @@ -0,0 +1,230 @@ +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef RECIPIENTFILTER_H +#define RECIPIENTFILTER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "irecipientfilter.h" +#include "const.h" +//#include "player.h" +#include "bitvec.h" + +//----------------------------------------------------------------------------- +// Purpose: A generic filter for determining whom to send message/sounds etc. to and +// providing a bit of additional state information +//----------------------------------------------------------------------------- +class CRecipientFilter : public IRecipientFilter +{ +public: + CRecipientFilter(); + virtual ~CRecipientFilter(); + + virtual bool IsReliable( void ) const; + virtual bool IsInitMessage( void ) const; + + virtual int GetRecipientCount( void ) const; + virtual int GetRecipientIndex( int slot ) const; + +public: + + void CopyFrom( const CRecipientFilter& src ); + + void Reset( void ); + + void MakeInitMessage( void ); + + void MakeReliable( void ); + + void AddAllPlayers( void ); + void AddRecipientsByPVS( const Vector& origin ); + void RemoveRecipientsByPVS( const Vector& origin ); + void AddRecipientsByPAS( const Vector& origin ); + void AddRecipient( CBasePlayer *player ); + void RemoveAllRecipients( void ); + void RemoveRecipient( CBasePlayer *player ); + void RemoveRecipientByPlayerIndex( int playerindex ); + void AddRecipientsByTeam( CTeam *team ); + void RemoveRecipientsByTeam( CTeam *team ); + void RemoveRecipientsNotOnTeam( CTeam *team ); + + void UsePredictionRules( void ); + bool IsUsingPredictionRules( void ) const; + + bool IgnorePredictionCull( void ) const; + void SetIgnorePredictionCull( bool ignore ); + + void AddPlayersFromBitMask( CPlayerBitVec& playerbits ); + void RemovePlayersFromBitMask( CPlayerBitVec& playerbits ); + + void RemoveSplitScreenPlayers(); + +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 ( unreliable ) +//----------------------------------------------------------------------------- +class CSingleUserRecipientFilter : public CRecipientFilter +{ +public: + CSingleUserRecipientFilter( CBasePlayer *player ) + { + AddRecipient( player ); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple class to create a filter for all players on a given team +//----------------------------------------------------------------------------- +class CTeamRecipientFilter : public CRecipientFilter +{ +public: + CTeamRecipientFilter( int team, bool isReliable = false ); +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple class to create a filter for all players ( unreliable ) +//----------------------------------------------------------------------------- +class CBroadcastRecipientFilter : public CRecipientFilter +{ +public: + CBroadcastRecipientFilter( void ) + { + AddAllPlayers(); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple class to create a filter for all players ( reliable ) +//----------------------------------------------------------------------------- +class CReliableBroadcastRecipientFilter : public CBroadcastRecipientFilter +{ +public: + CReliableBroadcastRecipientFilter( void ) + { + MakeReliable(); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Add players in PAS to recipient list (unreliable) +//----------------------------------------------------------------------------- +class CPASFilter : public CRecipientFilter +{ +public: + CPASFilter( void ) + { + } + + CPASFilter( const Vector& origin ) + { + AddRecipientsByPAS( origin ); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Add players in PAS to list and if not in single player, use attenuation +// to remove those that are too far away from source origin +// Source origin can be stated as an entity or just a passed in origin +// (unreliable) +//----------------------------------------------------------------------------- +class CPASAttenuationFilter : public CPASFilter +{ +public: + CPASAttenuationFilter( void ) + { + } + + CPASAttenuationFilter( CBaseEntity *entity, soundlevel_t soundlevel ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + Filter( entity->GetSoundEmissionOrigin(), SNDLVL_TO_ATTN( soundlevel ) ); + } + + CPASAttenuationFilter( CBaseEntity *entity, float attenuation = ATTN_NORM ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + Filter( entity->GetSoundEmissionOrigin(), attenuation ); + } + + CPASAttenuationFilter( const Vector& origin, soundlevel_t soundlevel ) : + CPASFilter( origin ) + { + Filter( origin, SNDLVL_TO_ATTN( soundlevel ) ); + } + + CPASAttenuationFilter( const Vector& origin, float attenuation = ATTN_NORM ) : + CPASFilter( origin ) + { + Filter( origin, attenuation ); + } + + CPASAttenuationFilter( CBaseEntity *entity, const char *lookupSound ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( entity->GetSoundEmissionOrigin(), attenuation ); + } + + CPASAttenuationFilter( const Vector& origin, const char *lookupSound ) : + CPASFilter( origin ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( origin, attenuation ); + } + + CPASAttenuationFilter( CBaseEntity *entity, const char *lookupSound, HSOUNDSCRIPTHANDLE& handle ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound, handle ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( entity->GetSoundEmissionOrigin(), attenuation ); + } + + CPASAttenuationFilter( const Vector& origin, const char *lookupSound, HSOUNDSCRIPTHANDLE& handle ) : + CPASFilter( origin ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound, handle ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( origin, attenuation ); + } + + + + +public: + void Filter( const Vector& origin, float attenuation = ATTN_NORM ); +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple PVS based filter ( unreliable ) +//----------------------------------------------------------------------------- +class CPVSFilter : public CRecipientFilter +{ +public: + CPVSFilter( const Vector& origin ) + { + AddRecipientsByPVS( origin ); + } +}; + +#endif // RECIPIENTFILTER_H diff --git a/src/patches/csgo/game/server/recipientfilter.h b/src/patches/csgo/game/server/recipientfilter.h new file mode 100755 index 000000000..0258192df --- /dev/null +++ b/src/patches/csgo/game/server/recipientfilter.h @@ -0,0 +1,230 @@ +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef RECIPIENTFILTER_H +#define RECIPIENTFILTER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "irecipientfilter.h" +#include "const.h" +//#include "player.h" +#include "bitvec.h" + +//----------------------------------------------------------------------------- +// Purpose: A generic filter for determining whom to send message/sounds etc. to and +// providing a bit of additional state information +//----------------------------------------------------------------------------- +class CRecipientFilter : public IRecipientFilter +{ +public: + CRecipientFilter(); + virtual ~CRecipientFilter(); + + virtual bool IsReliable( void ) const; + virtual bool IsInitMessage( void ) const; + + virtual int GetRecipientCount( void ) const; + virtual int GetRecipientIndex( int slot ) const; + +public: + + void CopyFrom( const CRecipientFilter& src ); + + void Reset( void ); + + void MakeInitMessage( void ); + + void MakeReliable( void ); + + void AddAllPlayers( void ); + void AddRecipientsByPVS( const Vector& origin ); + void RemoveRecipientsByPVS( const Vector& origin ); + void AddRecipientsByPAS( const Vector& origin ); + void AddRecipient( CBasePlayer *player ); + void RemoveAllRecipients( void ); + void RemoveRecipient( CBasePlayer *player ); + void RemoveRecipientByPlayerIndex( int playerindex ); + void AddRecipientsByTeam( CTeam *team ); + void RemoveRecipientsByTeam( CTeam *team ); + void RemoveRecipientsNotOnTeam( CTeam *team ); + + void UsePredictionRules( void ); + bool IsUsingPredictionRules( void ) const; + + bool IgnorePredictionCull( void ) const; + void SetIgnorePredictionCull( bool ignore ); + + void AddPlayersFromBitMask( CPlayerBitVec& playerbits ); + void RemovePlayersFromBitMask( CPlayerBitVec& playerbits ); + + void RemoveSplitScreenPlayers(); + +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 ( unreliable ) +//----------------------------------------------------------------------------- +class CSingleUserRecipientFilter : public CRecipientFilter +{ +public: + CSingleUserRecipientFilter( CBasePlayer *player ) + { + AddRecipient( player ); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple class to create a filter for all players on a given team +//----------------------------------------------------------------------------- +class CTeamRecipientFilter : public CRecipientFilter +{ +public: + CTeamRecipientFilter( int team, bool isReliable = false ); +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple class to create a filter for all players ( unreliable ) +//----------------------------------------------------------------------------- +class CBroadcastRecipientFilter : public CRecipientFilter +{ +public: + CBroadcastRecipientFilter( void ) + { + AddAllPlayers(); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple class to create a filter for all players ( reliable ) +//----------------------------------------------------------------------------- +class CReliableBroadcastRecipientFilter : public CBroadcastRecipientFilter +{ +public: + CReliableBroadcastRecipientFilter( void ) + { + MakeReliable(); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Add players in PAS to recipient list (unreliable) +//----------------------------------------------------------------------------- +class CPASFilter : public CRecipientFilter +{ +public: + CPASFilter( void ) + { + } + + CPASFilter( const Vector& origin ) + { + AddRecipientsByPAS( origin ); + } +}; + +//----------------------------------------------------------------------------- +// Purpose: Add players in PAS to list and if not in single player, use attenuation +// to remove those that are too far away from source origin +// Source origin can be stated as an entity or just a passed in origin +// (unreliable) +//----------------------------------------------------------------------------- +class CPASAttenuationFilter : public CPASFilter +{ +public: + CPASAttenuationFilter( void ) + { + } + + CPASAttenuationFilter( CBaseEntity *entity, soundlevel_t soundlevel ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + Filter( entity->GetSoundEmissionOrigin(), SNDLVL_TO_ATTN( soundlevel ) ); + } + + CPASAttenuationFilter( CBaseEntity *entity, float attenuation = ATTN_NORM ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + Filter( entity->GetSoundEmissionOrigin(), attenuation ); + } + + CPASAttenuationFilter( const Vector& origin, soundlevel_t soundlevel ) : + CPASFilter( origin ) + { + Filter( origin, SNDLVL_TO_ATTN( soundlevel ) ); + } + + CPASAttenuationFilter( const Vector& origin, float attenuation = ATTN_NORM ) : + CPASFilter( origin ) + { + Filter( origin, attenuation ); + } + + CPASAttenuationFilter( CBaseEntity *entity, const char *lookupSound ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( entity->GetSoundEmissionOrigin(), attenuation ); + } + + CPASAttenuationFilter( const Vector& origin, const char *lookupSound ) : + CPASFilter( origin ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( origin, attenuation ); + } + + CPASAttenuationFilter( CBaseEntity *entity, const char *lookupSound, HSOUNDSCRIPTHANDLE& handle ) : + CPASFilter( static_cast(entity->GetSoundEmissionOrigin()) ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound, handle ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( entity->GetSoundEmissionOrigin(), attenuation ); + } + + CPASAttenuationFilter( const Vector& origin, const char *lookupSound, HSOUNDSCRIPTHANDLE& handle ) : + CPASFilter( origin ) + { + soundlevel_t level = CBaseEntity::LookupSoundLevel( lookupSound, handle ); + float attenuation = SNDLVL_TO_ATTN( level ); + Filter( origin, attenuation ); + } + + + + +public: + void Filter( const Vector& origin, float attenuation = ATTN_NORM ); +}; + +//----------------------------------------------------------------------------- +// Purpose: Simple PVS based filter ( unreliable ) +//----------------------------------------------------------------------------- +class CPVSFilter : public CRecipientFilter +{ +public: + CPVSFilter( const Vector& origin ) + { + AddRecipientsByPVS( origin ); + } +}; + +#endif // RECIPIENTFILTER_H From ec9463652bcfffdaf299b1227ab90b8a4dbd48d2 Mon Sep 17 00:00:00 2001 From: Jonathan <30329245+CookStar@users.noreply.github.com> Date: Mon, 21 Dec 2020 23:23:12 +0900 Subject: [PATCH 2/2] Added comments. --- src/patches/blade/game/server/recipientfilter.h | 3 ++- src/patches/csgo/game/server/recipientfilter.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/patches/blade/game/server/recipientfilter.h b/src/patches/blade/game/server/recipientfilter.h index 0258192df..db8638436 100755 --- a/src/patches/blade/game/server/recipientfilter.h +++ b/src/patches/blade/game/server/recipientfilter.h @@ -13,7 +13,8 @@ #include "irecipientfilter.h" #include "const.h" -//#include "player.h" +// Commented out to avoid numerous errors. #376 +// #include "player.h" #include "bitvec.h" //----------------------------------------------------------------------------- diff --git a/src/patches/csgo/game/server/recipientfilter.h b/src/patches/csgo/game/server/recipientfilter.h index 0258192df..db8638436 100755 --- a/src/patches/csgo/game/server/recipientfilter.h +++ b/src/patches/csgo/game/server/recipientfilter.h @@ -13,7 +13,8 @@ #include "irecipientfilter.h" #include "const.h" -//#include "player.h" +// Commented out to avoid numerous errors. #376 +// #include "player.h" #include "bitvec.h" //-----------------------------------------------------------------------------