core/CellRecipientFilter.h
changeset 505 9fb8a1ccd4ec
child 552 e58968c96860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/CellRecipientFilter.h	Fri Feb 16 18:47:16 2007 +0000
     1.3 @@ -0,0 +1,91 @@
     1.4 +/**
     1.5 +* vim: set ts=4 :
     1.6 +* ===============================================================
     1.7 +* SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     1.8 +* ===============================================================
     1.9 +*
    1.10 +* This file is not open source and may not be copied without explicit
    1.11 +* written permission of AlliedModders LLC.  This file may not be redistributed 
    1.12 +* in whole or significant part.
    1.13 +* For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    1.14 +*
    1.15 +* Version: $Id$
    1.16 +*/
    1.17 +
    1.18 +#ifndef _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
    1.19 +#define _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
    1.20 +
    1.21 +#include <irecipientfilter.h>
    1.22 +#include <sp_vm_types.h>
    1.23 +
    1.24 +class CellRecipientFilter : public IRecipientFilter
    1.25 +{
    1.26 +public:
    1.27 +	CellRecipientFilter() : m_Reliable(false), m_InitMessage(false), m_Size(0), m_CellRecipients(NULL) {}
    1.28 +	~CellRecipientFilter() {}
    1.29 +public: //IRecipientFilter
    1.30 +	bool IsReliable() const;
    1.31 +	bool IsInitMessage() const;
    1.32 +	int GetRecipientCount() const;
    1.33 +	int GetRecipientIndex(int slot) const;
    1.34 +public:
    1.35 +	void SetRecipientPtr(cell_t *ptr, size_t count);
    1.36 +	void SetReliable(bool isreliable);
    1.37 +	void SetInitMessage(bool isinitmsg);
    1.38 +	void ResetFilter();
    1.39 +private:
    1.40 +	bool m_Reliable;
    1.41 +	bool m_InitMessage;
    1.42 +	size_t m_Size;
    1.43 +	cell_t *m_CellRecipients;
    1.44 +};
    1.45 +
    1.46 +inline void CellRecipientFilter::ResetFilter()
    1.47 +{
    1.48 +	m_Reliable = false;
    1.49 +	m_InitMessage = false;
    1.50 +	m_Size = 0;
    1.51 +	m_CellRecipients = NULL;
    1.52 +}
    1.53 +
    1.54 +inline bool CellRecipientFilter::IsReliable() const
    1.55 +{
    1.56 +	return m_Reliable;
    1.57 +}
    1.58 +
    1.59 +inline bool CellRecipientFilter::IsInitMessage() const
    1.60 +{
    1.61 +	return m_InitMessage;
    1.62 +}
    1.63 +
    1.64 +inline int CellRecipientFilter::GetRecipientCount() const
    1.65 +{
    1.66 +	return m_Size;
    1.67 +}
    1.68 +
    1.69 +inline int CellRecipientFilter::GetRecipientIndex(int slot) const
    1.70 +{
    1.71 +	if ((slot < 0) || (slot >= GetRecipientCount()))
    1.72 +	{
    1.73 +		return -1;
    1.74 +	}
    1.75 +	return static_cast<int>(m_CellRecipients[slot]);
    1.76 +}
    1.77 +
    1.78 +inline void CellRecipientFilter::SetInitMessage(bool isinitmsg)
    1.79 +{
    1.80 +	m_InitMessage = isinitmsg;
    1.81 +}
    1.82 +
    1.83 +inline void CellRecipientFilter::SetReliable(bool isreliable)
    1.84 +{
    1.85 +	m_Reliable = isreliable;
    1.86 +}
    1.87 +
    1.88 +inline void CellRecipientFilter::SetRecipientPtr(cell_t *ptr, size_t count)
    1.89 +{
    1.90 +	m_CellRecipients = ptr;
    1.91 +	m_Size = count;
    1.92 +}
    1.93 +
    1.94 +#endif //_INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_