blob: 28c6b1debac18804b4823925644a5557dda37f96 (
plain) (
blame)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "quakedef.h"
#include "server.h"
#include "enginesingleuserfilter.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
void SV_DetermineMulticastRecipients( bool usepas, const Vector& origin, CBitVec< ABSOLUTE_PLAYER_LIMIT >& playerbits );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEngineRecipientFilter::CEngineRecipientFilter()
{
Reset();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEngineRecipientFilter::Reset( void )
{
m_bReliable = false;
m_bInit = false;
m_Recipients.RemoveAll();
}
void CEngineRecipientFilter::MakeReliable( void )
{
m_bReliable = true;
}
void CEngineRecipientFilter::MakeInitMessage( void )
{
m_bInit = true;
}
int CEngineRecipientFilter::GetRecipientCount( void ) const
{
return m_Recipients.Size();
}
int CEngineRecipientFilter::GetRecipientIndex( int slot ) const
{
if ( slot < 0 || slot >= GetRecipientCount() )
return -1;
return m_Recipients[ slot ];
}
void CEngineRecipientFilter::AddAllPlayers( void )
{
m_Recipients.RemoveAll();
for ( int i = 0; i < sv.GetClientCount(); i++ )
{
IClient *cl = sv.GetClient( i );
if ( !cl->IsActive() )
continue;
m_Recipients.AddToTail( i+1 );
}
}
void CEngineRecipientFilter::AddRecipient( int index )
{
// Already in list
if ( m_Recipients.Find( index ) != m_Recipients.InvalidIndex() )
return;
m_Recipients.AddToTail( index );
}
void CEngineRecipientFilter::RemoveRecipient( int index )
{
// Remove it if it's in the list
m_Recipients.FindAndRemove( index );
}
void CEngineRecipientFilter::AddPlayersFromBitMask( CBitVec< ABSOLUTE_PLAYER_LIMIT >& playerbits )
{
for( int i = 0; i < sv.GetClientCount(); i++ )
{
if ( !playerbits[i] )
continue;
IClient *cl = sv.GetClient( i );
if ( !cl->IsActive() )
continue;
AddRecipient( i + 1 );
}
}
bool CEngineRecipientFilter::IncludesPlayer(int playerindex)
{
for( int i = 0; i < GetRecipientCount(); i++ )
{
if ( playerindex == GetRecipientIndex(i) )
return true;
}
return false;
}
void CEngineRecipientFilter::AddPlayersFromFilter(const IRecipientFilter *filter )
{
for( int i = 0; i < filter->GetRecipientCount(); i++ )
{
AddRecipient( filter->GetRecipientIndex(i) );
}
}
void CEngineRecipientFilter::AddRecipientsByPVS( const Vector& origin )
{
if ( sv.GetMaxClients() == 1 )
{
AddAllPlayers();
}
else
{
CBitVec< ABSOLUTE_PLAYER_LIMIT > playerbits;
SV_DetermineMulticastRecipients( false, origin, playerbits );
AddPlayersFromBitMask( playerbits );
}
}
void CEngineRecipientFilter::AddRecipientsByPAS( const Vector& origin )
{
if ( sv.GetMaxClients() == 1 )
{
AddAllPlayers();
}
else
{
CBitVec< ABSOLUTE_PLAYER_LIMIT > playerbits;
SV_DetermineMulticastRecipients( true, origin, playerbits );
AddPlayersFromBitMask( playerbits );
}
}
|