forked from EQEmu/Server
-
Notifications
You must be signed in to change notification settings - Fork 2
/
eqemu_config.h
191 lines (157 loc) · 4.23 KB
/
eqemu_config.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
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; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __EQEmuConfig_H
#define __EQEmuConfig_H
#include "json/json.h"
#include "linked_list.h"
#include "path_manager.h"
#include <fstream>
#include <fmt/format.h>
struct LoginConfig {
std::string LoginHost;
std::string LoginAccount;
std::string LoginPassword;
uint16 LoginPort;
bool LoginLegacy;
};
class EQEmuConfig
{
public:
virtual std::string GetByName(const std::string &var_name) const;
// From <world/>
std::string ShortName;
std::string LongName;
std::string WorldAddress;
std::string LocalAddress;
std::string LoginHost;
std::string LoginAccount;
std::string LoginPassword;
uint16 LoginPort;
bool LoginLegacy;
uint32 LoginCount;
LinkedList<LoginConfig*> loginlist;
bool Locked;
uint16 WorldTCPPort;
std::string WorldIP;
uint16 TelnetTCPPort;
std::string TelnetIP;
bool TelnetEnabled;
int32 MaxClients;
bool WorldHTTPEnabled;
uint16 WorldHTTPPort;
std::string WorldHTTPMimeFile;
std::string SharedKey;
bool DisableConfigChecks;
// From <database/>
std::string DatabaseHost;
std::string DatabaseUsername;
std::string DatabasePassword;
std::string DatabaseDB;
uint16 DatabasePort;
// From <content_database/>
std::string ContentDbHost;
std::string ContentDbUsername;
std::string ContentDbPassword;
std::string ContentDbName;
uint16 ContentDbPort;
// From <qsdatabase> // QueryServ
std::string QSDatabaseHost;
std::string QSDatabaseUsername;
std::string QSDatabasePassword;
std::string QSDatabaseDB;
uint16 QSDatabasePort;
// From <files/>
std::string SpellsFile;
std::string OpCodesFile;
std::string MailOpCodesFile;
std::string PluginPlFile;
// From <directories/>
std::string MapDir;
std::string QuestDir;
std::string PluginDir;
std::string LuaModuleDir;
std::string PatchDir;
std::string OpcodeDir;
std::string SharedMemDir;
std::string LogDir;
// From <launcher/>
std::string LogPrefix;
std::string LogSuffix;
std::string ZoneExe;
uint32 RestartWait;
uint32 TerminateWait;
uint32 InitialBootWait;
uint32 ZoneBootInterval;
// From <zones/>
uint16 ZonePortLow;
uint16 ZonePortHigh;
uint8 DefaultStatus;
bool auto_database_updates;
const std::string &GetUCSHost() const;
uint16 GetUCSPort() const;
// uint16 DynamicCount;
// map<string,uint16> StaticZones;
protected:
std::string m_ucs_host;
uint16 m_ucs_port;
static EQEmuConfig *_config;
Json::Value _root;
static std::string ConfigFile;
void parse_config();
EQEmuConfig()
{
}
virtual ~EQEmuConfig() {}
public:
// Produce a const singleton
static const EQEmuConfig *get()
{
LoadConfig();
return (_config);
}
// Load the config
static bool LoadConfig(const std::string& path = "")
{
if (_config != nullptr) {
return true;
}
_config = new EQEmuConfig;
return parseFile(path);
}
// Load config file and parse data
static bool parseFile(const std::string& file_path = ".")
{
if (_config == nullptr) {
return LoadConfig(file_path);
}
std::string file = fmt::format(
"{}/{}",
(file_path.empty() ? path.GetServerPath() : file_path),
EQEmuConfig::ConfigFile
);
std::ifstream fconfig(file, std::ifstream::binary);
try {
fconfig >> _config->_root;
_config->parse_config();
}
catch (std::exception &) {
return false;
}
return true;
}
void Dump() const;
void CheckUcsConfigConversion();
};
#endif