ServerChannelFilter.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <server/ServerChannelFilter.h>
00022 #include <server/ScorchedServer.h>
00023 #include <tank/TankContainer.h>
00024 
00025 ServerChannelFilter::ServerChannelFilter()
00026 {
00027 }
00028 
00029 ServerChannelFilter::~ServerChannelFilter()
00030 {
00031 }
00032 
00033 bool ServerChannelFilterTeams::sentToDestination(ChannelText &text, unsigned int destination)
00034 {
00035         // Find the tank that is sending the message
00036         Tank *sendTank = ScorchedServer::instance()->getTankContainer().getTankById(
00037                 text.getSrcPlayerId());
00038         if (!sendTank) return false;
00039 
00040         // Check this tank is actualy in a team
00041         if (sendTank->getTeam() == 0) return false;
00042 
00043         // Find a suitable tank to recieve the message
00044         std::map<unsigned int, Tank *> &tanks = 
00045                 ScorchedServer::instance()->getTankContainer().getPlayingTanks();
00046         std::map<unsigned int, Tank *>::iterator itor;
00047         for (itor = tanks.begin();
00048                 itor != tanks.end();
00049                 itor++)
00050         {
00051                 Tank *recvTank = itor->second;
00052                 if (recvTank->getDestinationId() == destination &&
00053                         recvTank->getTeam() == sendTank->getTeam())
00054                 {
00055                         return true;
00056                 }
00057         }
00058 
00059         return false;
00060 }

Generated on Mon Feb 16 15:14:53 2009 for Scorched3D by  doxygen 1.5.3