faluco@505: /** ds@653: * vim: set ts=4 : dvander@1231: * ================================================================ dvander@1231: * SourceMod dvander@1231: * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. dvander@1231: * ================================================================ ds@653: * dvander@1231: * This program is free software; you can redistribute it and/or dvander@1231: * modify it under the terms of the GNU General Public License, dvander@1231: * version 3.0, as published by the Free Software Foundation. dvander@1231: * dvander@1231: * This program is distributed in the hope that it will be useful, dvander@1231: * but WITHOUT ANY WARRANTY; without even the implied warranty of dvander@1231: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dvander@1231: * GNU General Public License for more details. dvander@1231: * dvander@1231: * You should have received a copy of the GNU General Public License dvander@1231: * along with this program. If not, see . dvander@1231: * dvander@1231: * As a special exception, AlliedModders LLC gives you permission to dvander@1231: * link the code of this program (as well as its derivative works) to dvander@1231: * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any dvander@1231: * Game MODs that run on software by the Valve Corporation. You must dvander@1231: * obey the GNU General Public License in all respects for all other dvander@1231: * code used. Additionally, AlliedModders LLC grants this exception dvander@1231: * to all derivative works. AlliedModders LLC defines further dvander@1231: * exceptions, found in LICENSE.txt (as of this writing, version dvander@1231: * JULY-31-2007), 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; faluco@505: int GetRecipientIndex(int slot) const; faluco@505: public: faluco@593: void Initialize(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: faluco@505: inline int CellRecipientFilter::GetRecipientIndex(int slot) const faluco@505: { faluco@505: if ((slot < 0) || (slot >= GetRecipientCount())) faluco@505: { faluco@505: return -1; faluco@505: } faluco@593: return static_cast(m_Players[slot]); 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: faluco@593: inline void CellRecipientFilter::Initialize(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_