extensions/sdktools/CellRecipientFilter.h
author Scott Ehlert <ds@alliedmods.net>
Wed Aug 15 06:19:30 2007 +0000 (2007-08-15)
changeset 1330 ab94316bb52b
parent 1233 e9cfc03b9bb8
child 1947 e73a1e51833b
permissions -rw-r--r--
Updated license headers on virtually all files with extremely minor changes in the name of some sort of strange consistency.
All plugin and include file headers also have been changed to say about GPL3 instead of GPL2.

(This day shall henceforth be known as the Eighty Column Massacre of '07)
faluco@1031
     1
/**
faluco@1031
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1233
     4
 * SourceMod SDKTools Extension
dvander@1233
     5
 * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
faluco@1031
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1233
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1233
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1233
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
faluco@1031
    28
 *
faluco@1031
    29
 * Version: $Id$
faluco@1031
    30
 */
faluco@1031
    31
faluco@1031
    32
#ifndef _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
faluco@1031
    33
#define _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
faluco@1031
    34
faluco@1031
    35
#include <irecipientfilter.h>
faluco@1031
    36
#include <sp_vm_types.h>
faluco@1031
    37
faluco@1031
    38
class CellRecipientFilter : public IRecipientFilter
faluco@1031
    39
{
faluco@1031
    40
public:
faluco@1031
    41
	CellRecipientFilter() : m_IsReliable(false), m_IsInitMessage(false), m_Size(0) {}
faluco@1031
    42
	~CellRecipientFilter() {}
faluco@1031
    43
public: //IRecipientFilter
faluco@1031
    44
	bool IsReliable() const;
faluco@1031
    45
	bool IsInitMessage() const;
faluco@1031
    46
	int GetRecipientCount() const;
faluco@1031
    47
	int GetRecipientIndex(int slot) const;
faluco@1031
    48
public:
faluco@1031
    49
	void Initialize(cell_t *ptr, size_t count);
faluco@1031
    50
	void SetToReliable(bool isreliable);
faluco@1031
    51
	void SetToInit(bool isinitmsg);
faluco@1031
    52
	void Reset();
faluco@1031
    53
private:
faluco@1031
    54
	cell_t m_Players[255];
faluco@1031
    55
	bool m_IsReliable;
faluco@1031
    56
	bool m_IsInitMessage;
faluco@1031
    57
	size_t m_Size;
faluco@1031
    58
};
faluco@1031
    59
faluco@1031
    60
inline void CellRecipientFilter::Reset()
faluco@1031
    61
{
faluco@1031
    62
	m_IsReliable = false;
faluco@1031
    63
	m_IsInitMessage = false;
faluco@1031
    64
	m_Size = 0;
faluco@1031
    65
}
faluco@1031
    66
faluco@1031
    67
inline bool CellRecipientFilter::IsReliable() const
faluco@1031
    68
{
faluco@1031
    69
	return m_IsReliable;
faluco@1031
    70
}
faluco@1031
    71
faluco@1031
    72
inline bool CellRecipientFilter::IsInitMessage() const
faluco@1031
    73
{
faluco@1031
    74
	return m_IsInitMessage;
faluco@1031
    75
}
faluco@1031
    76
faluco@1031
    77
inline int CellRecipientFilter::GetRecipientCount() const
faluco@1031
    78
{
faluco@1031
    79
	return m_Size;
faluco@1031
    80
}
faluco@1031
    81
faluco@1031
    82
inline int CellRecipientFilter::GetRecipientIndex(int slot) const
faluco@1031
    83
{
faluco@1031
    84
	if ((slot < 0) || (slot >= GetRecipientCount()))
faluco@1031
    85
	{
faluco@1031
    86
		return -1;
faluco@1031
    87
	}
faluco@1031
    88
	return static_cast<int>(m_Players[slot]);
faluco@1031
    89
}
faluco@1031
    90
faluco@1031
    91
inline void CellRecipientFilter::SetToInit(bool isinitmsg)
faluco@1031
    92
{
faluco@1031
    93
	m_IsInitMessage = isinitmsg;
faluco@1031
    94
}
faluco@1031
    95
faluco@1031
    96
inline void CellRecipientFilter::SetToReliable(bool isreliable)
faluco@1031
    97
{
faluco@1031
    98
	m_IsReliable = isreliable;
faluco@1031
    99
}
faluco@1031
   100
faluco@1031
   101
inline void CellRecipientFilter::Initialize(cell_t *ptr, size_t count)
faluco@1031
   102
{
faluco@1031
   103
	memcpy(m_Players, ptr, count * sizeof(cell_t));
faluco@1031
   104
	m_Size = count;
faluco@1031
   105
}
faluco@1031
   106
faluco@1031
   107
#endif //_INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_