[9296] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Patrick Boenzli |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | #define DEBUG_MODULE_NETWORK |
---|
| 17 | |
---|
| 18 | #include "proxy_settings.h" |
---|
| 19 | #include "netdefs.h" |
---|
| 20 | |
---|
[9297] | 21 | #include "loading/load_param.h" |
---|
[9296] | 22 | |
---|
[9297] | 23 | |
---|
[9296] | 24 | using namespace std; |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | ProxySettings* ProxySettings::singletonRef = NULL; |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | * Standard constructor |
---|
| 31 | */ |
---|
| 32 | ProxySettings::ProxySettings() |
---|
| 33 | { |
---|
| 34 | /* set the class id for the base object */ |
---|
| 35 | this->setClassID(CL_PROXY_SETTINGS, "ProxySettings"); |
---|
[9340] | 36 | // suggest a good standard max players value |
---|
| 37 | this->maxPlayer = 10; |
---|
[9296] | 38 | } |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Standard destructor |
---|
| 43 | */ |
---|
| 44 | ProxySettings::~ProxySettings() |
---|
| 45 | { |
---|
| 46 | ProxySettings::singletonRef = NULL; |
---|
[9300] | 47 | |
---|
| 48 | // remove all unused proxy data again |
---|
| 49 | for( int i = 0; i < this->proxies.size(); i++) |
---|
| 50 | { |
---|
| 51 | IPaddress* ip = this->proxies.back(); |
---|
| 52 | this->proxies.pop_back(); |
---|
| 53 | delete ip; |
---|
| 54 | } |
---|
[9296] | 55 | } |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | * load the proxy settings |
---|
| 61 | * @param root: the root element of the xml elemnts |
---|
| 62 | */ |
---|
| 63 | void ProxySettings::loadProxySettings(const TiXmlElement* root) |
---|
| 64 | { |
---|
[9297] | 65 | |
---|
| 66 | LoadParam(root, "max-player", this, ProxySettings, setMaxPlayer); |
---|
| 67 | |
---|
[9308] | 68 | LOAD_PARAM_START_CYCLE(root, element); |
---|
| 69 | { |
---|
| 70 | element->ToText(); |
---|
| 71 | // PER-PARTICLE-ATTRIBUTES: |
---|
| 72 | LoadParam(root, "proxy-addr", this, ProxySettings, setProxyAddr); |
---|
| 73 | } |
---|
| 74 | LOAD_PARAM_END_CYCLE(element); |
---|
| 75 | |
---|
[9297] | 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | /** |
---|
| 80 | * sets the proxy address to |
---|
| 81 | * @param proxyAddr: the proxy address |
---|
| 82 | */ |
---|
| 83 | void ProxySettings::setProxyAddr(const std::string& proxyAddr) |
---|
| 84 | { |
---|
| 85 | IPaddress *ip = new IPaddress; |
---|
| 86 | |
---|
| 87 | SDLNet_ResolveHost( ip, proxyAddr.c_str(), 9999 ); |
---|
| 88 | |
---|
| 89 | this->proxies.push_back(ip); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | |
---|