core/CellRecipientFilter.h
author Scott Ehlert <ds@alliedmods.net>
Sat Feb 17 05:33:31 2007 +0000 (2007-02-17)
changeset 511 c29f8796bcf4
parent 505 9fb8a1ccd4ec
child 552 e58968c96860
permissions -rw-r--r--
Initial fixes to ensure static strings passed to new convars
Also fixed minor warning in smn_bitbuffer.cpp
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@505
    24
	CellRecipientFilter() : m_Reliable(false), m_InitMessage(false), m_Size(0), m_CellRecipients(NULL) {}
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@505
    37
	bool m_Reliable;
faluco@505
    38
	bool m_InitMessage;
faluco@505
    39
	size_t m_Size;
faluco@505
    40
	cell_t *m_CellRecipients;
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
	m_CellRecipients = NULL;
faluco@505
    49
}
faluco@505
    50
faluco@505
    51
inline bool CellRecipientFilter::IsReliable() const
faluco@505
    52
{
faluco@505
    53
	return m_Reliable;
faluco@505
    54
}
faluco@505
    55
faluco@505
    56
inline bool CellRecipientFilter::IsInitMessage() const
faluco@505
    57
{
faluco@505
    58
	return m_InitMessage;
faluco@505
    59
}
faluco@505
    60
faluco@505
    61
inline int CellRecipientFilter::GetRecipientCount() const
faluco@505
    62
{
faluco@505
    63
	return m_Size;
faluco@505
    64
}
faluco@505
    65
faluco@505
    66
inline int CellRecipientFilter::GetRecipientIndex(int slot) const
faluco@505
    67
{
faluco@505
    68
	if ((slot < 0) || (slot >= GetRecipientCount()))
faluco@505
    69
	{
faluco@505
    70
		return -1;
faluco@505
    71
	}
faluco@505
    72
	return static_cast<int>(m_CellRecipients[slot]);
faluco@505
    73
}
faluco@505
    74
faluco@505
    75
inline void CellRecipientFilter::SetInitMessage(bool isinitmsg)
faluco@505
    76
{
faluco@505
    77
	m_InitMessage = isinitmsg;
faluco@505
    78
}
faluco@505
    79
faluco@505
    80
inline void CellRecipientFilter::SetReliable(bool isreliable)
faluco@505
    81
{
faluco@505
    82
	m_Reliable = isreliable;
faluco@505
    83
}
faluco@505
    84
faluco@505
    85
inline void CellRecipientFilter::SetRecipientPtr(cell_t *ptr, size_t count)
faluco@505
    86
{
faluco@505
    87
	m_CellRecipients = ptr;
faluco@505
    88
	m_Size = count;
faluco@505
    89
}
faluco@505
    90
faluco@505
    91
#endif //_INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_