| [7161] | 1 | /* | 
|---|
| [7745] | 2 | *   ORXONOX - the hottest 3D action shooter ever to exist > www.orxonox.net < | 
|---|
| [7161] | 3 | * | 
|---|
|  | 4 | * | 
|---|
|  | 5 | *   License notice: | 
|---|
|  | 6 | * | 
|---|
| [7745] | 7 | *   This program is free software; you can redistribute it and/or modify it | 
|---|
|  | 8 | *   under the terms of the GNU General Public License as published by the Free | 
|---|
|  | 9 | *   Software Foundation; either version 2 of the License, or (at your option) | 
|---|
|  | 10 | *   any later version. | 
|---|
| [7161] | 11 | * | 
|---|
| [7745] | 12 | *   This program is distributed in the hope that it will be useful, but | 
|---|
|  | 13 | *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | 
|---|
|  | 14 | *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License | 
|---|
|  | 15 | *   for more details. | 
|---|
| [7161] | 16 | * | 
|---|
| [7745] | 17 | *   You should have received a copy of the GNU General Public License along | 
|---|
|  | 18 | *   with this program; if not, write to the Free Software Foundation, Inc., 51 | 
|---|
|  | 19 | *   Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
|---|
| [7161] | 20 | * | 
|---|
| [8858] | 21 | *   Author: | 
|---|
|  | 22 | *      Sandro 'smerkli' Merkli | 
|---|
|  | 23 | *   Co-authors: | 
|---|
|  | 24 | *      Oliver Scheuss (original) | 
|---|
| [7161] | 25 | * | 
|---|
|  | 26 | */ | 
|---|
|  | 27 |  | 
|---|
| [7770] | 28 | #ifndef _WANDiscovery_H__ | 
|---|
|  | 29 | #define _WANDiscovery_H__ | 
|---|
| [7161] | 30 |  | 
|---|
|  | 31 | #include "NetworkPrereqs.h" | 
|---|
|  | 32 | #include "packet/ServerInformation.h" | 
|---|
| [9667] | 33 | #include "core/config/Configurable.h" | 
|---|
|  | 34 | #include "core/config/ConfigValueIncludes.h" | 
|---|
| [7631] | 35 | #include "MasterServerComm.h" | 
|---|
| [7650] | 36 | #include "MasterServerProtocol.h" | 
|---|
| [10622] | 37 | #include <OgreStringConverter.h> | 
|---|
| [7161] | 38 |  | 
|---|
|  | 39 | #include <vector> | 
|---|
|  | 40 |  | 
|---|
| [7692] | 41 | #define WANDISC_MAXTRIES 5 | 
|---|
| [7631] | 42 |  | 
|---|
| [7161] | 43 | // tolua_begin | 
|---|
|  | 44 | namespace orxonox | 
|---|
|  | 45 | { | 
|---|
|  | 46 |  | 
|---|
| [7630] | 47 | class _NetworkExport WANDiscovery | 
|---|
| [7161] | 48 | // tolua_end | 
|---|
| [9667] | 49 | : public Configurable | 
|---|
| [7161] | 50 | { // tolua_export | 
|---|
|  | 51 | public: | 
|---|
| [7631] | 52 | /** constructor */ | 
|---|
| [8858] | 53 | WANDiscovery(); // tolua_export | 
|---|
| [7631] | 54 |  | 
|---|
|  | 55 | /** destructor */ | 
|---|
| [7630] | 56 | ~WANDiscovery(); | 
|---|
| [7631] | 57 |  | 
|---|
| [7750] | 58 | /** \return Address of the master server | 
|---|
| [10622] | 59 | * | 
|---|
|  | 60 | * Get the master server address | 
|---|
| [7750] | 61 | */ | 
|---|
| [7745] | 62 | std::string getMSAddress() | 
|---|
|  | 63 | { return this->msaddress; } | 
|---|
|  | 64 |  | 
|---|
| [7631] | 65 | /** ask server for server list  */ | 
|---|
| [7161] | 66 | void discover(); // tolua_export | 
|---|
| [7631] | 67 |  | 
|---|
| [10622] | 68 | /** \param index Index to get the name of | 
|---|
| [7631] | 69 | * \return The name of the server | 
|---|
| [10622] | 70 | * | 
|---|
|  | 71 | * Get the name of the server at index index. | 
|---|
| [7631] | 72 | */ | 
|---|
| [7161] | 73 | std::string getServerListItemName( unsigned int index ); // tolua_export | 
|---|
| [7631] | 74 |  | 
|---|
| [10622] | 75 | /** \param index Index to get the IP of | 
|---|
| [7631] | 76 | * \return The IP of the server | 
|---|
| [10622] | 77 | * | 
|---|
|  | 78 | * Get the IP of the server at index index. | 
|---|
| [7631] | 79 | */ | 
|---|
| [7161] | 80 | std::string getServerListItemIP( unsigned int index ); // tolua_export | 
|---|
| [7631] | 81 |  | 
|---|
| [10622] | 82 | /** \param index Index to get the RTT of | 
|---|
|  | 83 | * \return The RTT of the server | 
|---|
|  | 84 | * | 
|---|
|  | 85 | * Get the RTT of the server at index index. | 
|---|
|  | 86 | */ | 
|---|
|  | 87 | std::string getServerListItemRTT( unsigned int index ); // tolua_export | 
|---|
|  | 88 |  | 
|---|
|  | 89 | /** \param index Index to get the RTT of | 
|---|
|  | 90 | * \return The number of players on the server | 
|---|
|  | 91 | * | 
|---|
|  | 92 | * Get the number of players on the server | 
|---|
|  | 93 | */ | 
|---|
|  | 94 | std::string getServerListItemPlayerNumber( unsigned int index ); // tolua_export | 
|---|
|  | 95 |  | 
|---|
| [7672] | 96 | /* todo: might make this private and use getter/setter methods | 
|---|
| [10622] | 97 | * at some later time. | 
|---|
| [7672] | 98 | */ | 
|---|
| [7657] | 99 | /** game server list */ | 
|---|
|  | 100 | std::vector<packet::ServerInformation> servers_; | 
|---|
| [7737] | 101 |  | 
|---|
|  | 102 | /** Function used for the configuration file parameter update */ | 
|---|
|  | 103 | void setConfigValues(); | 
|---|
| [7763] | 104 |  | 
|---|
|  | 105 | /** Master server communications object */ | 
|---|
|  | 106 | MasterServerComm msc; | 
|---|
| [8858] | 107 |  | 
|---|
|  | 108 | int rhandler( char *addr, ENetEvent *ev ); | 
|---|
| [10622] | 109 |  | 
|---|
| [7161] | 110 | private: | 
|---|
| [7737] | 111 | /** master server address */ | 
|---|
| [7739] | 112 | std::string msaddress; | 
|---|
| [7737] | 113 |  | 
|---|
| [7161] | 114 | }; // tolua_export | 
|---|
|  | 115 |  | 
|---|
|  | 116 | } // tolua_export | 
|---|
|  | 117 |  | 
|---|
| [7770] | 118 | #endif // _WANDiscovery_H__ | 
|---|