faluco@505: /**
ds@653: * vim: set ts=4 :
ds@1330: * =============================================================================
dvander@1231: * SourceMod
ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
ds@653: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
dvander@1231: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
dvander@1231: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
dvander@1231: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
ds@653: *
ds@653: * Version: $Id$
ds@653: */
faluco@505:
faluco@505: #ifndef _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
faluco@505: #define _INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_
faluco@505:
faluco@505: #include
faluco@505: #include
faluco@505:
faluco@505: class CellRecipientFilter : public IRecipientFilter
faluco@505: {
faluco@505: public:
faluco@593: CellRecipientFilter() : m_IsReliable(false), m_IsInitMessage(false), m_Size(0) {}
faluco@505: ~CellRecipientFilter() {}
faluco@505: public: //IRecipientFilter
faluco@505: bool IsReliable() const;
faluco@505: bool IsInitMessage() const;
faluco@505: int GetRecipientCount() const;
skamonkey@3916: #if SOURCE_ENGINE == SE_DOTA
skamonkey@3942: CEntityIndex GetRecipientIndex(int slot) const;
skamonkey@3916: #else
faluco@505: int GetRecipientIndex(int slot) const;
skamonkey@3916: #endif
faluco@505: public:
dvander@1690: void Initialize(const cell_t *ptr, size_t count);
faluco@593: void SetToReliable(bool isreliable);
faluco@593: void SetToInit(bool isinitmsg);
faluco@593: void Reset();
faluco@505: private:
faluco@593: cell_t m_Players[255];
faluco@593: bool m_IsReliable;
faluco@593: bool m_IsInitMessage;
faluco@505: size_t m_Size;
faluco@505: };
faluco@505:
faluco@593: inline void CellRecipientFilter::Reset()
faluco@505: {
faluco@593: m_IsReliable = false;
faluco@593: m_IsInitMessage = false;
faluco@505: m_Size = 0;
faluco@505: }
faluco@505:
faluco@505: inline bool CellRecipientFilter::IsReliable() const
faluco@505: {
faluco@593: return m_IsReliable;
faluco@505: }
faluco@505:
faluco@505: inline bool CellRecipientFilter::IsInitMessage() const
faluco@505: {
faluco@593: return m_IsInitMessage;
faluco@505: }
faluco@505:
faluco@505: inline int CellRecipientFilter::GetRecipientCount() const
faluco@505: {
faluco@505: return m_Size;
faluco@505: }
faluco@505:
skamonkey@3916: #if SOURCE_ENGINE == SE_DOTA
skamonkey@3942: inline CEntityIndex CellRecipientFilter::GetRecipientIndex(int slot) const
skamonkey@3916: #else
faluco@505: inline int CellRecipientFilter::GetRecipientIndex(int slot) const
skamonkey@3916: #endif
faluco@505: {
skamonkey@3916: int ret;
faluco@505: if ((slot < 0) || (slot >= GetRecipientCount()))
faluco@505: {
skamonkey@3916: ret = -1;
faluco@505: }
kyle@3970: else
kyle@3970: {
kyle@3970: ret = static_cast(m_Players[slot]);
kyle@3970: }
skamonkey@3916:
skamonkey@3916: #if SOURCE_ENGINE == SE_DOTA
skamonkey@3942: return CEntityIndex(ret);
skamonkey@3916: #else
skamonkey@3916: return ret;
skamonkey@3916: #endif
faluco@505: }
faluco@505:
faluco@593: inline void CellRecipientFilter::SetToInit(bool isinitmsg)
faluco@505: {
faluco@593: m_IsInitMessage = isinitmsg;
faluco@505: }
faluco@505:
faluco@593: inline void CellRecipientFilter::SetToReliable(bool isreliable)
faluco@505: {
faluco@593: m_IsReliable = isreliable;
faluco@505: }
faluco@505:
dvander@1690: inline void CellRecipientFilter::Initialize(const cell_t *ptr, size_t count)
faluco@505: {
faluco@593: memcpy(m_Players, ptr, count * sizeof(cell_t));
faluco@505: m_Size = count;
faluco@505: }
faluco@505:
faluco@505: #endif //_INCLUDE_SOURCEMOD_CELLRECIPIENTFILTER_H_