Skip to content

Commit

Permalink
Moved where the custom CRecipientFilter class lives
Browse files Browse the repository at this point in the history
  • Loading branch information
OrsellGaming committed Nov 5, 2024
1 parent dbdb102 commit 56cb470
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 30 deletions.
32 changes: 31 additions & 1 deletion globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "public/steam/steamclientpublic.h"
#include "public/filesystem.h"
#include "tier2/fileutils.h"
#include "irecipientfilter.h"

#include "scanner.hpp"

Expand Down Expand Up @@ -64,7 +65,8 @@ extern IFileSystem* g_pFileSystem;

void P2MMLog(int level, bool dev, const char* pMsgFormat, ...);

namespace GFunc {
namespace GFunc
{
int UserIDToPlayerIndex(int userid);
const char* GetPlayerName(int index);
int GetSteamID(int index);
Expand All @@ -84,6 +86,34 @@ HSCRIPT CBaseEntity__GetScriptInstance(CBaseEntity* entity);
void CPortal_Player__RespawnPlayer(int playerIndex);
void CPortal_Player__SetFlashlightState(int playerIndex, bool enable);

class CFilter : public IRecipientFilter
{
public:
CFilter() { recipient_count = 0; };
~CFilter() {};

virtual bool IsReliable() const { return false; }
virtual bool IsInitMessage() const { return false; }

virtual int GetRecipientCount() const { return recipient_count; }
virtual int GetRecipientIndex(int slot) const {
return (slot < 0 || slot >= recipient_count) ? -1 : recipients[slot];
}

void AddPlayer(int playerIndex)
{
if (recipient_count < 256)
{
recipients[recipient_count] = playerIndex;
recipient_count++;
}
}

private:
int recipients[256];
int recipient_count;
};

// If String Equals String helper function. Taken from utils.h.
inline bool FStrEq(const char* sz1, const char* sz2)
{
Expand Down
29 changes: 0 additions & 29 deletions vscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "p2mm.hpp"

#include "irecipientfilter.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

Expand Down Expand Up @@ -111,33 +109,6 @@ static void InitializeEntity(HSCRIPT ent)
}
}

class CFilter : public IRecipientFilter
{
public:
CFilter() { recipient_count = 0; };
~CFilter() {};

virtual bool IsReliable() const { return false; };
virtual bool IsInitMessage() const { return false; };

virtual int GetRecipientCount() const { return recipient_count; };
virtual int GetRecipientIndex(int slot) const { return ((slot < 0) || (slot >= recipient_count)) ? -1 : recipients[slot]; };
void AddPlayer(int player_index)
{
if (recipient_count > 255)
{
return;
}

recipients[recipient_count] = player_index;
recipient_count++;
}

private:
int recipients[256];
int recipient_count;
};

//---------------------------------------------------------------------------------
// Purpose: Sends a raw message to the chat HUD.
//---------------------------------------------------------------------------------
Expand Down

0 comments on commit 56cb470

Please sign in to comment.