ComsConnectAcceptMessage.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 #ifndef S3D_SERVER
00022         #include <client/ScorchedClient.h>
00023 #endif
00024 #include <server/ScorchedServer.h>
00025 #include <coms/ComsConnectAcceptMessage.h>
00026 #include <weapons/AccessoryStore.h>
00027 #include <common/OptionsScorched.h>
00028 
00029 ComsConnectAcceptMessage::ComsConnectAcceptMessage(unsigned int destinationId,
00030         const char *serverName,
00031         const char *publishAddress,
00032         const char *uniqueId) :
00033         ComsMessage("ComsConnectAcceptMessage"),
00034         destinationId_(destinationId),
00035         serverName_(serverName),
00036         publishAddress_(publishAddress),
00037         uniqueId_(uniqueId)
00038 {
00039 
00040 }
00041 
00042 ComsConnectAcceptMessage::~ComsConnectAcceptMessage()
00043 {
00044 
00045 }
00046 
00047 bool ComsConnectAcceptMessage::writeMessage(NetBuffer &buffer)
00048 {
00049         buffer.addToBuffer(destinationId_);
00050         buffer.addToBuffer(serverName_);
00051         buffer.addToBuffer(publishAddress_);
00052         buffer.addToBuffer(uniqueId_);
00053         buffer.addToBuffer(serverPng_.getBufferUsed());
00054         buffer.addDataToBuffer(serverPng_.getBuffer(), serverPng_.getBufferUsed());
00055         if (!ScorchedServer::instance()->getOptionsGame().getMainOptions().
00056                 writeToBuffer(buffer, false, false)) return false;
00057         return true;
00058 }
00059 
00060 bool ComsConnectAcceptMessage::readMessage(NetBufferReader &reader)
00061 {
00062         if (!reader.getFromBuffer(destinationId_)) return false;
00063         if (!reader.getFromBuffer(serverName_)) return false;
00064         if (!reader.getFromBuffer(publishAddress_)) return false;
00065         if (!reader.getFromBuffer(uniqueId_)) return false;
00066         unsigned int used;
00067         if (!reader.getFromBuffer(used)) return false;
00068         serverPng_.allocate(used);
00069         serverPng_.reset();
00070         serverPng_.setBufferUsed(used);
00071         reader.getDataFromBuffer(serverPng_.getBuffer(), used);
00072 #ifndef S3D_SERVER
00073         if (!ScorchedClient::instance()->getOptionsGame().getMainOptions().
00074                 readFromBuffer(reader, false, false)) return false;
00075 #endif // #ifndef S3D_SERVER
00076         return true;
00077 }

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