core/CellRecipientFilter.h
author Nicholas Hastings <skamonkey@gmail.com>
Mon Aug 05 11:36:59 2013 -0400 (2013-08-05)
changeset 3973 5c5ed57cca88
parent 3970 f105ae16b49e
permissions -rw-r--r--
Fixed a path not using updated mapcycle file detection (bug 5719).
faluco@505
     1
/**
ds@653
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1231
     4
 * SourceMod
ds@1947
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
ds@653
     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@1231
    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@1231
    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@1231
    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>.
ds@653
    28
 *
ds@653
    29
 * Version: $Id$
ds@653
    30
 */
faluco@505
    31
faluco@505
    32
#ifndef _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
faluco@505
    33
#define _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
faluco@505
    34
faluco@505
    35
#include <irecipientfilter.h>
faluco@505
    36
#include <sp_vm_types.h>
faluco@505
    37
faluco@505
    38
class CellRecipientFilter : public IRecipientFilter
faluco@505
    39
{
faluco@505
    40
public:
faluco@593
    41
	CellRecipientFilter() : m_IsReliable(false), m_IsInitMessage(false), m_Size(0) {}
faluco@505
    42
	~CellRecipientFilter() {}
faluco@505
    43
public: //IRecipientFilter
faluco@505
    44
	bool IsReliable() const;
faluco@505
    45
	bool IsInitMessage() const;
faluco@505
    46
	int GetRecipientCount() const;
skamonkey@3916
    47
#if SOURCE_ENGINE == SE_DOTA
skamonkey@3942
    48
	CEntityIndex GetRecipientIndex(int slot) const;
skamonkey@3916
    49
#else
faluco@505
    50
	int GetRecipientIndex(int slot) const;
skamonkey@3916
    51
#endif
faluco@505
    52
public:
dvander@1690
    53
	void Initialize(const cell_t *ptr, size_t count);
faluco@593
    54
	void SetToReliable(bool isreliable);
faluco@593
    55
	void SetToInit(bool isinitmsg);
faluco@593
    56
	void Reset();
faluco@505
    57
private:
faluco@593
    58
	cell_t m_Players[255];
faluco@593
    59
	bool m_IsReliable;
faluco@593
    60
	bool m_IsInitMessage;
faluco@505
    61
	size_t m_Size;
faluco@505
    62
};
faluco@505
    63
faluco@593
    64
inline void CellRecipientFilter::Reset()
faluco@505
    65
{
faluco@593
    66
	m_IsReliable = false;
faluco@593
    67
	m_IsInitMessage = false;
faluco@505
    68
	m_Size = 0;
faluco@505
    69
}
faluco@505
    70
faluco@505
    71
inline bool CellRecipientFilter::IsReliable() const
faluco@505
    72
{
faluco@593
    73
	return m_IsReliable;
faluco@505
    74
}
faluco@505
    75
faluco@505
    76
inline bool CellRecipientFilter::IsInitMessage() const
faluco@505
    77
{
faluco@593
    78
	return m_IsInitMessage;
faluco@505
    79
}
faluco@505
    80
faluco@505
    81
inline int CellRecipientFilter::GetRecipientCount() const
faluco@505
    82
{
faluco@505
    83
	return m_Size;
faluco@505
    84
}
faluco@505
    85
skamonkey@3916
    86
#if SOURCE_ENGINE == SE_DOTA
skamonkey@3942
    87
inline CEntityIndex CellRecipientFilter::GetRecipientIndex(int slot) const
skamonkey@3916
    88
#else
faluco@505
    89
inline int CellRecipientFilter::GetRecipientIndex(int slot) const
skamonkey@3916
    90
#endif
faluco@505
    91
{
skamonkey@3916
    92
	int ret;
faluco@505
    93
	if ((slot < 0) || (slot >= GetRecipientCount()))
faluco@505
    94
	{
skamonkey@3916
    95
		ret = -1;
faluco@505
    96
	}
kyle@3970
    97
	else
kyle@3970
    98
	{
kyle@3970
    99
		ret = static_cast<int>(m_Players[slot]);
kyle@3970
   100
	}
skamonkey@3916
   101
skamonkey@3916
   102
#if SOURCE_ENGINE == SE_DOTA
skamonkey@3942
   103
	return CEntityIndex(ret);
skamonkey@3916
   104
#else
skamonkey@3916
   105
	return ret;
skamonkey@3916
   106
#endif
faluco@505
   107
}
faluco@505
   108
faluco@593
   109
inline void CellRecipientFilter::SetToInit(bool isinitmsg)
faluco@505
   110
{
faluco@593
   111
	m_IsInitMessage = isinitmsg;
faluco@505
   112
}
faluco@505
   113
faluco@593
   114
inline void CellRecipientFilter::SetToReliable(bool isreliable)
faluco@505
   115
{
faluco@593
   116
	m_IsReliable = isreliable;
faluco@505
   117
}
faluco@505
   118
dvander@1690
   119
inline void CellRecipientFilter::Initialize(const cell_t *ptr, size_t count)
faluco@505
   120
{
faluco@593
   121
	memcpy(m_Players, ptr, count * sizeof(cell_t));
faluco@505
   122
	m_Size = count;
faluco@505
   123
}
faluco@505
   124
faluco@505
   125
#endif //_INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_