| author | David Anderson <dvander@alliedmods.net> |
| Fri Mar 02 08:34:13 2007 +0000 (2007-03-02) | |
| changeset 558 | fc0eec032efb |
| parent 552 | e58968c96860 |
| child 593 | 507e74843261 |
| permissions | -rw-r--r-- |
| faluco@505 | 1 |
/** |
| faluco@505 | 2 |
* vim: set ts=4 : |
| faluco@505 | 3 |
* =============================================================== |
| faluco@505 | 4 |
* SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved. |
| faluco@505 | 5 |
* =============================================================== |
| faluco@505 | 6 |
* |
| faluco@505 | 7 |
* This file is not open source and may not be copied without explicit |
| faluco@505 | 8 |
* written permission of AlliedModders LLC. This file may not be redistributed |
| faluco@505 | 9 |
* in whole or significant part. |
| faluco@505 | 10 |
* For information, see LICENSE.txt or http://www.sourcemod.net/license.php |
| faluco@505 | 11 |
* |
| faluco@505 | 12 |
* Version: $Id$ |
| faluco@505 | 13 |
*/ |
| faluco@505 | 14 |
|
| faluco@505 | 15 |
#ifndef _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_ |
| faluco@505 | 16 |
#define _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_ |
| faluco@505 | 17 |
|
| faluco@505 | 18 |
#include <irecipientfilter.h> |
| faluco@505 | 19 |
#include <sp_vm_types.h> |
| faluco@505 | 20 |
|
| faluco@505 | 21 |
class CellRecipientFilter : public IRecipientFilter |
| faluco@505 | 22 |
{ |
| faluco@505 | 23 |
public: |
| faluco@552 | 24 |
CellRecipientFilter() : m_Reliable(false), m_InitMessage(false), m_Size(0) {} |
| faluco@505 | 25 |
~CellRecipientFilter() {} |
| faluco@505 | 26 |
public: //IRecipientFilter |
| faluco@505 | 27 |
bool IsReliable() const; |
| faluco@505 | 28 |
bool IsInitMessage() const; |
| faluco@505 | 29 |
int GetRecipientCount() const; |
| faluco@505 | 30 |
int GetRecipientIndex(int slot) const; |
| faluco@505 | 31 |
public: |
| faluco@505 | 32 |
void SetRecipientPtr(cell_t *ptr, size_t count); |
| faluco@505 | 33 |
void SetReliable(bool isreliable); |
| faluco@505 | 34 |
void SetInitMessage(bool isinitmsg); |
| faluco@505 | 35 |
void ResetFilter(); |
| faluco@505 | 36 |
private: |
| faluco@552 | 37 |
cell_t m_CellRecipients[255]; |
| faluco@505 | 38 |
bool m_Reliable; |
| faluco@505 | 39 |
bool m_InitMessage; |
| faluco@505 | 40 |
size_t m_Size; |
| faluco@505 | 41 |
}; |
| faluco@505 | 42 |
|
| faluco@505 | 43 |
inline void CellRecipientFilter::ResetFilter() |
| faluco@505 | 44 |
{ |
| faluco@505 | 45 |
m_Reliable = false; |
| faluco@505 | 46 |
m_InitMessage = false; |
| faluco@505 | 47 |
m_Size = 0; |
| faluco@505 | 48 |
} |
| faluco@505 | 49 |
|
| faluco@505 | 50 |
inline bool CellRecipientFilter::IsReliable() const |
| faluco@505 | 51 |
{ |
| faluco@505 | 52 |
return m_Reliable; |
| faluco@505 | 53 |
} |
| faluco@505 | 54 |
|
| faluco@505 | 55 |
inline bool CellRecipientFilter::IsInitMessage() const |
| faluco@505 | 56 |
{ |
| faluco@505 | 57 |
return m_InitMessage; |
| faluco@505 | 58 |
} |
| faluco@505 | 59 |
|
| faluco@505 | 60 |
inline int CellRecipientFilter::GetRecipientCount() const |
| faluco@505 | 61 |
{ |
| faluco@505 | 62 |
return m_Size; |
| faluco@505 | 63 |
} |
| faluco@505 | 64 |
|
| faluco@505 | 65 |
inline int CellRecipientFilter::GetRecipientIndex(int slot) const |
| faluco@505 | 66 |
{ |
| faluco@505 | 67 |
if ((slot < 0) || (slot >= GetRecipientCount())) |
| faluco@505 | 68 |
{ |
| faluco@505 | 69 |
return -1; |
| faluco@505 | 70 |
} |
| faluco@505 | 71 |
return static_cast<int>(m_CellRecipients[slot]); |
| faluco@505 | 72 |
} |
| faluco@505 | 73 |
|
| faluco@505 | 74 |
inline void CellRecipientFilter::SetInitMessage(bool isinitmsg) |
| faluco@505 | 75 |
{ |
| faluco@505 | 76 |
m_InitMessage = isinitmsg; |
| faluco@505 | 77 |
} |
| faluco@505 | 78 |
|
| faluco@505 | 79 |
inline void CellRecipientFilter::SetReliable(bool isreliable) |
| faluco@505 | 80 |
{ |
| faluco@505 | 81 |
m_Reliable = isreliable; |
| faluco@505 | 82 |
} |
| faluco@505 | 83 |
|
| faluco@505 | 84 |
inline void CellRecipientFilter::SetRecipientPtr(cell_t *ptr, size_t count) |
| faluco@505 | 85 |
{ |
| faluco@552 | 86 |
memcpy(m_CellRecipients, ptr, count * sizeof(cell_t)); |
| faluco@505 | 87 |
m_Size = count; |
| faluco@505 | 88 |
} |
| faluco@505 | 89 |
|
| faluco@505 | 90 |
#endif //_INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_ |