core/CellRecipientFilter.h
author David Anderson <dvander@alliedmods.net>
Tue Jul 03 20:46:17 2007 +0000 (2007-07-03)
changeset 1036 2a073d5b3454
parent 653 ef60870067ff
child 1231 17badaf66ce4
permissions -rw-r--r--
added amb505
faluco@505
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@653
     3
 * ===============================================================
ds@653
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
ds@653
     5
 * ===============================================================
ds@653
     6
 *
ds@653
     7
 * This file is not open source and may not be copied without explicit
ds@653
     8
 * written permission of AlliedModders LLC.  This file may not be redistributed 
ds@653
     9
 * in whole or significant part.
ds@653
    10
 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
ds@653
    11
 *
ds@653
    12
 * Version: $Id$
ds@653
    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@593
    24
	CellRecipientFilter() : m_IsReliable(false), m_IsInitMessage(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@593
    32
	void Initialize(cell_t *ptr, size_t count);
faluco@593
    33
	void SetToReliable(bool isreliable);
faluco@593
    34
	void SetToInit(bool isinitmsg);
faluco@593
    35
	void Reset();
faluco@505
    36
private:
faluco@593
    37
	cell_t m_Players[255];
faluco@593
    38
	bool m_IsReliable;
faluco@593
    39
	bool m_IsInitMessage;
faluco@505
    40
	size_t m_Size;
faluco@505
    41
};
faluco@505
    42
faluco@593
    43
inline void CellRecipientFilter::Reset()
faluco@505
    44
{
faluco@593
    45
	m_IsReliable = false;
faluco@593
    46
	m_IsInitMessage = 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@593
    52
	return m_IsReliable;
faluco@505
    53
}
faluco@505
    54
faluco@505
    55
inline bool CellRecipientFilter::IsInitMessage() const
faluco@505
    56
{
faluco@593
    57
	return m_IsInitMessage;
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@593
    71
	return static_cast<int>(m_Players[slot]);
faluco@505
    72
}
faluco@505
    73
faluco@593
    74
inline void CellRecipientFilter::SetToInit(bool isinitmsg)
faluco@505
    75
{
faluco@593
    76
	m_IsInitMessage = isinitmsg;
faluco@505
    77
}
faluco@505
    78
faluco@593
    79
inline void CellRecipientFilter::SetToReliable(bool isreliable)
faluco@505
    80
{
faluco@593
    81
	m_IsReliable = isreliable;
faluco@505
    82
}
faluco@505
    83
faluco@593
    84
inline void CellRecipientFilter::Initialize(cell_t *ptr, size_t count)
faluco@505
    85
{
faluco@593
    86
	memcpy(m_Players, 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_