Shadowrun: Awakened 29 September 2011 - Build 871
SraServerInfo.h
Go to the documentation of this file.
00001 /*
00002  * SraServerInfo - Information about a server instance.
00003  * This information is sent to the client to choose a server.
00004  *
00005  * @Author Michael <Tharbas> Matzen
00006  *
00007  * This program is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU General Public License as published by the Free
00009  * Software Foundation; either version 2 of the License, or (at your option)
00010  * any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00015  * more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along with
00018  * this program; if not, write to the Free Software Foundation, Inc., 51
00019  * Franklin St, Fifth Floor, Boston, MA 02110, USA
00020  * 
00021  */
00022 
00023 #pragma once
00024 
00025 #include "NetworkHelper.h"
00026 #include <string>
00027 
00028 namespace SraNetwork
00029 {
00030     struct SraServerInfo
00031     {
00032     public:
00033         RakNet::RakString name;
00034 
00035         RakNet::RakString ip;
00036 
00037         int currentNumberOfPlayers;
00038 
00039         // For storing the struct we will need 2 strings and 1 int,
00040         // and 2 additional size_t's for storing the strlen of name & ip.
00041         static const int PACKAGE_SIZE = 2 * sizeof(std::string) + sizeof(int) + 2 * sizeof(size_t);
00042 
00043         void Serialize(RakNet::BitStream* target)
00044         {
00045             target->Write<int>(currentNumberOfPlayers);
00046             target->Write<RakNet::RakString>(name);
00047             target->Write<RakNet::RakString>(ip);
00048         }
00049 
00050         void Deserialize(RakNet::BitStream* source)
00051         {           
00052             source->Read<int>(currentNumberOfPlayers); 
00053             
00054             source->Read<RakNet::RakString>(ip);
00055                 
00056             source->Read<RakNet::RakString>(name);
00057         }
00058     };
00059 }

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net