-
Notifications
You must be signed in to change notification settings - Fork 1
/
gameservers.h
72 lines (60 loc) · 2.32 KB
/
gameservers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
////////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
////////////////////////////////////////////////////////////////////////
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////
#ifndef __GAMESERVER__
#define __GAMESERVER__
#include "otsystem.h"
#include "resources.h"
#include "const.h"
class GameServer
{
public:
GameServer(): name("TheForgottenServer"), address(LOCALHOST), port(7172),
versionMin(CLIENT_VERSION_MIN), versionMax(CLIENT_VERSION_MAX) {}
GameServer(std::string _name, uint32_t _versionMin, uint32_t _versionMax, uint32_t _address, uint32_t _port):
name(_name), address(_address), port(_port), versionMin(_versionMin), versionMax(_versionMax) {}
virtual ~GameServer() {}
std::string getName() const {return name;}
uint32_t getVersionMin() const {return versionMin;}
uint32_t getVersionMax() const {return versionMax;}
uint32_t getAddress() const {return address;}
uint32_t getPort() const {return port;}
protected:
std::string name;
uint32_t address, port, versionMin, versionMax;
};
typedef std::map<uint32_t, GameServer*> GameServersMap;
class GameServers
{
public:
GameServers() {}
virtual ~GameServers() {clear();}
static GameServers* getInstance()
{
static GameServers instance;
return &instance;
}
bool loadFromXml(bool showResult = false);
bool reload(bool showResult = false);
GameServer* getServerById(uint32_t id) const;
GameServer* getServerByName(std::string name) const;
GameServer* getServerByAddress(uint32_t address) const;
GameServer* getServerByPort(uint32_t port) const;
protected:
void clear();
GameServersMap serverList;
};
#endif