Main Page | Class List | File List | Class Members | File Members

MRecipientFilter.cpp

Go to the documentation of this file.
00001 /* MRecipientFilter.cpp
00002  *
00003  * Copyright (C) 2005 Guwashi <guwashi[AT]fooos[DOT]com>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 // This code is based on
00021 // http://www.hl2coding.com/forums/viewtopic.php?t=31
00022 
00023 #include "MRecipientFilter.h"
00024 #include "interface.h"
00025 #include "filesystem.h"
00026 #include "engine/iserverplugin.h"
00027 #include "dlls/iplayerinfo.h"
00028 #include "eiface.h"
00029 #include "igameevents.h"
00030 #include "convar.h"
00031 #include "Color.h"
00032 
00033 #include "shake.h"
00034 #include "IEffects.h"
00035 #include "engine/IEngineSound.h"
00036 
00037 // memdbgon must be the last include file in a .cpp file!!!
00038 #include "tier0/memdbgon.h"
00039 
00040 MRecipientFilter::MRecipientFilter(void)
00041 {
00042 }
00043 
00044 MRecipientFilter::~MRecipientFilter(void)
00045 {
00046 }
00047 
00048 int MRecipientFilter::GetRecipientCount() const
00049 {
00050   return m_Recipients.Count();
00051 }
00052 
00053 int MRecipientFilter::GetRecipientIndex(int slot) const
00054 {
00055   if (slot < 0 || slot >= GetRecipientCount()) return -1;
00056   return m_Recipients[slot];
00057 }
00058 
00059 bool MRecipientFilter::IsInitMessage() const
00060 {
00061   return false;
00062 }
00063 
00064 bool MRecipientFilter::IsReliable() const
00065 {
00066   return false;
00067 }
00068 
00069 bool MRecipientFilter::AddPlayerByIndex(IVEngineServer* engine, IPlayerInfoManager* playerInfoManager, int playerIndex)
00070 {
00071   edict_t* pPlayerEdict = engine->PEntityOfEntIndex(playerIndex);
00072   if (!(pPlayerEdict && !pPlayerEdict->IsFree())) return false;
00073   IPlayerInfo* pPlayerInfo = playerInfoManager->GetPlayerInfo(pPlayerEdict);
00074   if (!(pPlayerInfo && pPlayerInfo->IsConnected())) return false;
00075   const char* steamId = pPlayerInfo->GetNetworkIDString();
00076   if (steamId &&
00077       (Q_strlen(steamId) > 0) &&
00078       (Q_strncmp(steamId, "BOT", sizeof("BOT")) != 0)) {
00079     m_Recipients.AddToTail(playerIndex);
00080     return true;
00081   } else {
00082     return false;
00083   }
00084 }
00085 
00086 bool MRecipientFilter::AddAllPlayers(IVEngineServer* engine, IPlayerInfoManager* playerInfoManager, int maxClients)
00087 {
00088   m_Recipients.RemoveAll();
00089   for (int i = 1; i <= maxClients; i++) {
00090     AddPlayerByIndex(engine, playerInfoManager, i);
00091   }
00092   return true;
00093 }

Generated on Tue Jun 28 01:09:07 2005 for CountryFilter by  doxygen 1.4.3-20050623