-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecipientfilter.cpp
More file actions
98 lines (76 loc) · 1.65 KB
/
recipientfilter.cpp
File metadata and controls
98 lines (76 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "recipientfilter.h"
#include "utils.h"
CRecipientFilter::CRecipientFilter()
{
m_bReliable = false;
m_bInitMessage = false;
}
CRecipientFilter::~CRecipientFilter()
{
}
bool CRecipientFilter::IsReliable() const
{
return m_bReliable;
}
bool CRecipientFilter::IsInitMessage() const
{
return m_bInitMessage;
}
int CRecipientFilter::GetRecipientCount() const
{
return m_Recipients.Count();
}
int CRecipientFilter::GetRecipientIndex(int slot) const
{
if ( slot < 0 || slot >= GetRecipientCount() )
return -1;
return m_Recipients[slot];
}
void CRecipientFilter::Reset()
{
m_bReliable = false;
m_bInitMessage = false;
m_Recipients.RemoveAll();
}
void CRecipientFilter::MakeReliable()
{
m_bReliable = true;
}
void CRecipientFilter::MakeInitMessage()
{
m_bInitMessage = true;
}
void CRecipientFilter::AddAllPlayers()
{
m_Recipients.RemoveAll();
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
edict_t *pPlayer = EntIndexToEdict(i);
if ( !IsEdictValid(pPlayer) )
continue;
AddRecipient(pPlayer);
}
}
void CRecipientFilter::AddRecipient(edict_t *pPlayer)
{
if ( !IsEdictValid(pPlayer) )
return;
int index = EdictToEntIndex(pPlayer);
if ( m_Recipients.Find(index) != m_Recipients.InvalidIndex() )
return;
m_Recipients.AddToTail(index);
}
void CRecipientFilter::RemoveAllRecipients()
{
m_Recipients.RemoveAll();
}
void CRecipientFilter::RemoveRecipient(edict_t *pPlayer)
{
int index = EdictToEntIndex(pPlayer);
m_Recipients.FindAndRemove(index);
}
void CRecipientFilter::RemoveRecipientByPlayerIndex(int playerindex)
{
Assert( playerindex > 0 && playerindex <= gpGlobals->maxClients );
m_Recipients.FindAndRemove(playerindex);
}