mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
Merge pull request #635 from xackery/eqemu_config_json
Eqemu config json
This commit is contained in:
commit
10a27c2081
@ -23,351 +23,111 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
|
std::string EQEmuConfig::ConfigFile = "eqemu_config.json";
|
||||||
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
||||||
|
|
||||||
void EQEmuConfig::do_world(TiXmlElement *ele)
|
void EQEmuConfig::parse_config() {
|
||||||
{
|
|
||||||
const char *text;
|
ShortName = _root["server"]["world"].get("shortname", "").asString();
|
||||||
TiXmlElement * sub_ele;;
|
LongName = _root["server"]["world"].get("longname", "").asString();
|
||||||
text = ParseTextBlock(ele, "shortname");
|
WorldAddress = _root["server"]["world"].get("address", "").asString();
|
||||||
if (text) {
|
LocalAddress = _root["server"]["world"].get("localaddress", "").asString();
|
||||||
ShortName = text;
|
MaxClients = atoi(_root["server"]["world"].get("maxclients", "-1").asString().c_str());
|
||||||
}
|
SharedKey = _root["server"]["world"].get("key", "").asString();
|
||||||
text = ParseTextBlock(ele, "longname");
|
LoginCount = 0;
|
||||||
if (text) {
|
|
||||||
LongName = text;
|
if (_root["server"]["world"]["loginserver"].isObject()) {
|
||||||
}
|
LoginHost = _root["server"]["world"]["loginserver"].get("host", "login.eqemulator.net").asString();
|
||||||
text = ParseTextBlock(ele, "address", true);
|
LoginPort = atoi(_root["server"]["world"]["loginserver"].get("port", "5998").asString().c_str());
|
||||||
if (text) {
|
LoginLegacy = false;
|
||||||
WorldAddress = text;
|
if (_root["server"]["world"]["loginserver"].get("legacy", "0").asString() == "1") LoginLegacy = true;
|
||||||
}
|
LoginAccount = _root["server"]["world"]["loginserver"].get("account", "").asString();
|
||||||
text = ParseTextBlock(ele, "localaddress", true);
|
LoginPassword = _root["server"]["world"]["loginserver"].get("password", "").asString();
|
||||||
if (text) {
|
|
||||||
LocalAddress = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "maxclients", true);
|
|
||||||
if (text) {
|
|
||||||
MaxClients = atoi(text);
|
|
||||||
}
|
|
||||||
// Get the <key> element
|
|
||||||
text = ParseTextBlock(ele, "key", true);
|
|
||||||
if (text) {
|
|
||||||
SharedKey = text;
|
|
||||||
}
|
|
||||||
// Get the <loginserver> element
|
|
||||||
sub_ele = ele->FirstChildElement("loginserver");
|
|
||||||
if (sub_ele) {
|
|
||||||
text = ParseTextBlock(sub_ele, "host", true);
|
|
||||||
if (text) {
|
|
||||||
LoginHost = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "port", true);
|
|
||||||
if (text) {
|
|
||||||
LoginPort = atoi(text);
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "legacy", true);
|
|
||||||
if (text) {
|
|
||||||
LoginLegacy = atoi(text) > 0 ? true : false;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "account", true);
|
|
||||||
if (text) {
|
|
||||||
LoginAccount = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "password", true);
|
|
||||||
if (text) {
|
|
||||||
LoginPassword = text;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
char str[32];
|
char str[32];
|
||||||
do {
|
do {
|
||||||
sprintf(str, "loginserver%i", ++LoginCount);
|
sprintf(str, "loginserver%i", ++LoginCount);
|
||||||
sub_ele = ele->FirstChildElement(str);
|
if (_root["server"]["world"][str].get("host", "").asString() == "") {
|
||||||
if (sub_ele) {
|
break;
|
||||||
auto loginconfig = new LoginConfig;
|
|
||||||
text = ParseTextBlock(sub_ele, "host", true);
|
|
||||||
if (text) {
|
|
||||||
loginconfig->LoginHost = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "port", true);
|
|
||||||
if (text) {
|
|
||||||
loginconfig->LoginPort = atoi(text);
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "legacy", true);
|
|
||||||
if (text) {
|
|
||||||
loginconfig->LoginLegacy = atoi(text) > 0 ? true : false;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "account", true);
|
|
||||||
if (text) {
|
|
||||||
loginconfig->LoginAccount = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(sub_ele, "password", true);
|
|
||||||
if (text) {
|
|
||||||
loginconfig->LoginPassword = text;
|
|
||||||
}
|
|
||||||
loginlist.Insert(loginconfig);
|
|
||||||
}
|
}
|
||||||
} while (sub_ele);
|
|
||||||
}
|
|
||||||
// Check for locked
|
|
||||||
sub_ele = ele->FirstChildElement("locked");
|
|
||||||
if (sub_ele != nullptr) {
|
|
||||||
Locked = true;
|
|
||||||
}
|
|
||||||
// Get the <tcp> element
|
|
||||||
sub_ele = ele->FirstChildElement("tcp");
|
|
||||||
if (sub_ele != nullptr) {
|
|
||||||
text = sub_ele->Attribute("ip");
|
|
||||||
if (text) {
|
|
||||||
WorldIP = text;
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("port");
|
|
||||||
if (text) {
|
|
||||||
WorldTCPPort = atoi(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub_ele = ele->FirstChildElement("telnet");
|
auto loginconfig = new LoginConfig;
|
||||||
if (sub_ele != nullptr) {
|
loginconfig->LoginHost = _root["server"]["world"][str].get("host", "login.eqemulator.net").asString();
|
||||||
text = sub_ele->Attribute("ip");
|
loginconfig->LoginPort = atoi(_root["server"]["world"][str].get("port", "5998").asString().c_str());
|
||||||
if (text) {
|
loginconfig->LoginAccount = _root["server"]["world"][str].get("account", "").asString();
|
||||||
TelnetIP = text;
|
loginconfig->LoginPassword = _root["server"]["world"][str].get("password", "").asString();
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("port");
|
|
||||||
if (text) {
|
|
||||||
TelnetTCPPort = atoi(text);
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("enabled");
|
|
||||||
if (text && !strcasecmp(text, "true")) {
|
|
||||||
TelnetEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the <http> element
|
loginconfig->LoginLegacy = false;
|
||||||
sub_ele = ele->FirstChildElement("http");
|
if (_root["server"]["world"][str].get("legacy", "0").asString() == "1") loginconfig->LoginLegacy = true;
|
||||||
if (sub_ele != nullptr) {
|
loginlist.Insert(loginconfig);
|
||||||
// text = sub_ele->Attribute("ip");
|
} while (LoginCount < 100);
|
||||||
// if (text)
|
|
||||||
// WorldIP=text;
|
|
||||||
text = sub_ele->Attribute("mimefile");
|
|
||||||
if (text) {
|
|
||||||
WorldHTTPMimeFile = text;
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("port");
|
|
||||||
if (text) {
|
|
||||||
WorldHTTPPort = atoi(text);
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("enabled");
|
|
||||||
if (text && !strcasecmp(text, "true")) {
|
|
||||||
WorldHTTPEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//<locked> from xml converts to json as locked: "", so i default to "false".
|
||||||
|
//The only way to enable locked is by switching to true, meaning this value is always false until manually set true
|
||||||
|
Locked = false;
|
||||||
|
if (_root["server"]["world"].get("locked", "false").asString() == "true") Locked = true;
|
||||||
|
WorldIP = _root["server"]["world"]["tcp"].get("host", "127.0.0.1").asString();
|
||||||
|
WorldTCPPort = atoi(_root["server"]["world"]["tcp"].get("port", "9000").asString().c_str());
|
||||||
|
|
||||||
|
TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString();
|
||||||
|
TelnetTCPPort = atoi(_root["server"]["world"]["telnet"].get("port", "9001").asString().c_str());
|
||||||
|
TelnetEnabled = false;
|
||||||
|
if (_root["server"]["world"]["telnet"].get("enabled", "false").asString() == "true") TelnetEnabled = true;
|
||||||
|
|
||||||
|
WorldHTTPMimeFile = _root["server"]["world"]["http"].get("mimefile", "mime.types").asString();
|
||||||
|
WorldHTTPPort = atoi(_root["server"]["world"]["http"].get("port", "9080").asString().c_str());
|
||||||
|
WorldHTTPEnabled = false;
|
||||||
|
if (_root["server"]["world"]["http"].get("enabled", "false").asString() == "true") WorldHTTPEnabled = true;
|
||||||
|
|
||||||
|
ChatHost = _root["server"]["chatserver"].get("host", "eqchat.eqemulator.net").asString();
|
||||||
|
ChatPort = atoi(_root["server"]["chatserver"].get("port", "7778").asString().c_str());
|
||||||
|
|
||||||
|
MailHost = _root["server"]["mailserver"].get("host", "eqmail.eqemulator.net").asString();
|
||||||
|
MailPort = atoi(_root["server"]["mailserver"].get("port", "7778").asString().c_str());
|
||||||
|
|
||||||
|
DatabaseUsername = _root["server"]["database"].get("username", "eq").asString();
|
||||||
|
DatabasePassword = _root["server"]["database"].get("password", "eq").asString();
|
||||||
|
DatabaseHost = _root["server"]["database"].get("host", "localhost").asString();
|
||||||
|
DatabasePort = atoi(_root["server"]["database"].get("port", "3306").asString().c_str());
|
||||||
|
DatabaseDB = _root["server"]["database"].get("db", "eq").asString();
|
||||||
|
|
||||||
|
QSDatabaseHost = _root["server"]["qsdatabase"].get("host", "localhost").asString();
|
||||||
|
QSDatabasePort = atoi(_root["server"]["qsdatabase"].get("port", "3306").asString().c_str());
|
||||||
|
QSDatabaseUsername = _root["server"]["qsdatabase"].get("username", "eq").asString();
|
||||||
|
QSDatabasePassword = _root["server"]["qsdatabase"].get("password", "eq").asString();
|
||||||
|
QSDatabaseDB = _root["server"]["qsdatabase"].get("db", "eq").asString();
|
||||||
|
|
||||||
|
DefaultStatus = atoi(_root["server"]["zones"].get("defaultstatus", 0).asString().c_str());
|
||||||
|
ZonePortLow = atoi(_root["server"]["zones"]["ports"].get("low", "7000").asString().c_str());
|
||||||
|
ZonePortHigh = atoi(_root["server"]["zones"]["ports"].get("high", "7999").asString().c_str());
|
||||||
|
|
||||||
|
SpellsFile = _root["server"]["files"].get("spells", "spells_us.txt").asString();
|
||||||
|
OpCodesFile = _root["server"]["files"].get("opcodes", "opcodes.conf").asString();
|
||||||
|
PluginPlFile = _root["server"]["files"].get("plugin.pl", "plugin.pl").asString();
|
||||||
|
|
||||||
|
MapDir = _root["server"]["directories"].get("maps", "Maps/").asString();
|
||||||
|
QuestDir = _root["server"]["directories"].get("quests", "quests/").asString();
|
||||||
|
PluginDir = _root["server"]["directories"].get("plugins", "plugins/").asString();
|
||||||
|
LuaModuleDir = _root["server"]["directories"].get("lua_modules", "lua_modules/").asString();
|
||||||
|
PatchDir = _root["server"]["directories"].get("patches", "./").asString();
|
||||||
|
SharedMemDir = _root["server"]["directories"].get("shared_memory", "shared/").asString();
|
||||||
|
LogDir = _root["server"]["directories"].get("logs", "logs/").asString();
|
||||||
|
|
||||||
|
LogPrefix = _root["server"]["launcher"].get("logprefix", "logs/zone-").asString();
|
||||||
|
LogSuffix = _root["server"]["launcher"].get("logsuffix", ".log").asString();
|
||||||
|
RestartWait = atoi(_root["server"]["launcher"]["timers"].get("restart", "10000").asString().c_str());
|
||||||
|
TerminateWait = atoi(_root["server"]["launcher"]["timers"].get("reterminate", "10000").asString().c_str());
|
||||||
|
InitialBootWait = atoi(_root["server"]["launcher"]["timers"].get("initial", "20000").asString().c_str());
|
||||||
|
ZoneBootInterval = atoi(_root["server"]["launcher"]["timers"].get("interval", "2000").asString().c_str());
|
||||||
|
#ifdef WIN32
|
||||||
|
ZoneExe = _root["server"]["launcher"].get("exe", "zone.exe").asString();
|
||||||
|
#else
|
||||||
|
ZoneExe = _root["server"]["launcher"].get("exe", "./zone").asString();
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EQEmuConfig::do_chatserver(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
text = ParseTextBlock(ele, "host", true);
|
|
||||||
if (text) {
|
|
||||||
ChatHost = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "port", true);
|
|
||||||
if (text) {
|
|
||||||
ChatPort = atoi(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQEmuConfig::do_mailserver(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
text = ParseTextBlock(ele, "host", true);
|
|
||||||
if (text) {
|
|
||||||
MailHost = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "port", true);
|
|
||||||
if (text) {
|
|
||||||
MailPort = atoi(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQEmuConfig::do_database(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
text = ParseTextBlock(ele, "host", true);
|
|
||||||
if (text) {
|
|
||||||
DatabaseHost = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "port", true);
|
|
||||||
if (text) {
|
|
||||||
DatabasePort = atoi(text);
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "username", true);
|
|
||||||
if (text) {
|
|
||||||
DatabaseUsername = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "password", true);
|
|
||||||
if (text) {
|
|
||||||
DatabasePassword = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "db", true);
|
|
||||||
if (text) {
|
|
||||||
DatabaseDB = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
text = ParseTextBlock(ele, "host", true);
|
|
||||||
if (text) {
|
|
||||||
QSDatabaseHost = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "port", true);
|
|
||||||
if (text) {
|
|
||||||
QSDatabasePort = atoi(text);
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "username", true);
|
|
||||||
if (text) {
|
|
||||||
QSDatabaseUsername = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "password", true);
|
|
||||||
if (text) {
|
|
||||||
QSDatabasePassword = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "db", true);
|
|
||||||
if (text) {
|
|
||||||
QSDatabaseDB = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQEmuConfig::do_zones(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
TiXmlElement *sub_ele;
|
|
||||||
// TiXmlNode *node,*sub_node;
|
|
||||||
text = ParseTextBlock(ele, "defaultstatus", true);
|
|
||||||
if (text) {
|
|
||||||
DefaultStatus = atoi(text);
|
|
||||||
}
|
|
||||||
// Get the <ports> element
|
|
||||||
sub_ele = ele->FirstChildElement("ports");
|
|
||||||
if (sub_ele != nullptr) {
|
|
||||||
text = sub_ele->Attribute("low");
|
|
||||||
if (text) {
|
|
||||||
ZonePortLow = atoi(text);
|
|
||||||
};
|
|
||||||
text = sub_ele->Attribute("high");
|
|
||||||
if (text) {
|
|
||||||
ZonePortHigh = atoi(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQEmuConfig::do_files(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
text = ParseTextBlock(ele, "spells", true);
|
|
||||||
if (text) {
|
|
||||||
SpellsFile = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "opcodes", true);
|
|
||||||
if (text) {
|
|
||||||
OpCodesFile = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "plugin.pl", true);
|
|
||||||
if (text) {
|
|
||||||
PluginPlFile = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQEmuConfig::do_directories(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
text = ParseTextBlock(ele, "maps", true);
|
|
||||||
if (text) {
|
|
||||||
MapDir = text;
|
|
||||||
if ( MapDir.back() != '/' )
|
|
||||||
MapDir += '/';
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "quests", true);
|
|
||||||
if (text) {
|
|
||||||
QuestDir = text;
|
|
||||||
if ( QuestDir.back() != '/' )
|
|
||||||
QuestDir += '/';
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "plugins", true);
|
|
||||||
if (text) {
|
|
||||||
PluginDir = text;
|
|
||||||
if ( PluginDir.back() != '/' )
|
|
||||||
PluginDir += '/';
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "lua_modules", true);
|
|
||||||
if (text) {
|
|
||||||
LuaModuleDir = text;
|
|
||||||
if ( LuaModuleDir.back() != '/' )
|
|
||||||
LuaModuleDir += '/';
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "patches", true);
|
|
||||||
if (text) {
|
|
||||||
PatchDir = text;
|
|
||||||
if ( PatchDir.back() != '/' )
|
|
||||||
PatchDir += '/';
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "shared_memory", true);
|
|
||||||
if (text) {
|
|
||||||
SharedMemDir = text;
|
|
||||||
if ( SharedMemDir.back() != '/' )
|
|
||||||
SharedMemDir += '/';
|
|
||||||
}
|
|
||||||
//Not Fully Implemented yet LogDir
|
|
||||||
text = ParseTextBlock(ele, "logs", true);
|
|
||||||
if (text) {
|
|
||||||
LogDir = text;
|
|
||||||
if ( LogDir.back() != '/' )
|
|
||||||
LogDir += '/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EQEmuConfig::do_launcher(TiXmlElement *ele)
|
|
||||||
{
|
|
||||||
const char *text;
|
|
||||||
TiXmlElement *sub_ele;
|
|
||||||
text = ParseTextBlock(ele, "logprefix", true);
|
|
||||||
if (text) {
|
|
||||||
LogPrefix = text;
|
|
||||||
}
|
|
||||||
text = ParseTextBlock(ele, "logsuffix", true);
|
|
||||||
if (text) {
|
|
||||||
LogSuffix = text;
|
|
||||||
}
|
|
||||||
// Get the <exe> element
|
|
||||||
text = ParseTextBlock(ele, "exe", true);
|
|
||||||
if (text) {
|
|
||||||
ZoneExe = text;
|
|
||||||
}
|
|
||||||
// Get the <timers> element
|
|
||||||
sub_ele = ele->FirstChildElement("timers");
|
|
||||||
if (sub_ele != nullptr) {
|
|
||||||
text = sub_ele->Attribute("restart");
|
|
||||||
if (text) {
|
|
||||||
RestartWait = atoi(text);
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("reterminate");
|
|
||||||
if (text) {
|
|
||||||
TerminateWait = atoi(text);
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("initial");
|
|
||||||
if (text) {
|
|
||||||
InitialBootWait = atoi(text);
|
|
||||||
}
|
|
||||||
text = sub_ele->Attribute("interval");
|
|
||||||
if (text) {
|
|
||||||
ZoneBootInterval = atoi(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string EQEmuConfig::GetByName(const std::string &var_name) const
|
std::string EQEmuConfig::GetByName(const std::string &var_name) const
|
||||||
{
|
{
|
||||||
if (var_name == "ShortName") {
|
if (var_name == "ShortName") {
|
||||||
@ -564,4 +324,3 @@ void EQEmuConfig::Dump() const
|
|||||||
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
|
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
|
||||||
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
|
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,9 @@
|
|||||||
#ifndef __EQEmuConfig_H
|
#ifndef __EQEmuConfig_H
|
||||||
#define __EQEmuConfig_H
|
#define __EQEmuConfig_H
|
||||||
|
|
||||||
#include "xml_parser.h"
|
#include "json/json.h"
|
||||||
#include "linked_list.h"
|
#include "linked_list.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
struct LoginConfig {
|
struct LoginConfig {
|
||||||
std::string LoginHost;
|
std::string LoginHost;
|
||||||
@ -29,7 +30,7 @@ struct LoginConfig {
|
|||||||
bool LoginLegacy;
|
bool LoginLegacy;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EQEmuConfig : public XMLParser
|
class EQEmuConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual std::string GetByName(const std::string &var_name) const;
|
virtual std::string GetByName(const std::string &var_name) const;
|
||||||
@ -115,88 +116,14 @@ class EQEmuConfig : public XMLParser
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
static EQEmuConfig *_config;
|
static EQEmuConfig *_config;
|
||||||
|
Json::Value _root;
|
||||||
static std::string ConfigFile;
|
static std::string ConfigFile;
|
||||||
|
|
||||||
#define ELEMENT(name) \
|
void parse_config();
|
||||||
void do_##name(TiXmlElement *ele);
|
|
||||||
#include "eqemu_config_elements.h"
|
|
||||||
|
|
||||||
|
|
||||||
EQEmuConfig()
|
EQEmuConfig()
|
||||||
{
|
{
|
||||||
// import the needed handler prototypes
|
|
||||||
#define ELEMENT(name) \
|
|
||||||
Handlers[#name]=(ElementHandler)&EQEmuConfig::do_##name;
|
|
||||||
#include "eqemu_config_elements.h"
|
|
||||||
// Set sane defaults
|
|
||||||
// Login server
|
|
||||||
LoginHost = "login.eqemulator.net";
|
|
||||||
LoginPort = 5998;
|
|
||||||
LoginLegacy = false;
|
|
||||||
// World
|
|
||||||
Locked = false;
|
|
||||||
WorldTCPPort = 9000;
|
|
||||||
TelnetTCPPort = 9001;
|
|
||||||
TelnetEnabled = false;
|
|
||||||
WorldHTTPEnabled = false;
|
|
||||||
WorldHTTPPort = 9080;
|
|
||||||
WorldHTTPMimeFile = "mime.types";
|
|
||||||
SharedKey = ""; //blank disables authentication
|
|
||||||
// Mail
|
|
||||||
ChatHost = "eqchat.eqemulator.net";
|
|
||||||
ChatPort = 7778;
|
|
||||||
// Mail
|
|
||||||
MailHost = "eqmail.eqemulator.net";
|
|
||||||
MailPort = 7779;
|
|
||||||
// Mysql
|
|
||||||
DatabaseHost = "localhost";
|
|
||||||
DatabasePort = 3306;
|
|
||||||
DatabaseUsername = "eq";
|
|
||||||
DatabasePassword = "eq";
|
|
||||||
DatabaseDB = "eq";
|
|
||||||
// QueryServ Database
|
|
||||||
QSDatabaseHost = "localhost";
|
|
||||||
QSDatabasePort = 3306;
|
|
||||||
QSDatabaseUsername = "eq";
|
|
||||||
QSDatabasePassword = "eq";
|
|
||||||
QSDatabaseDB = "eq";
|
|
||||||
// Files
|
|
||||||
SpellsFile = "spells_us.txt";
|
|
||||||
OpCodesFile = "opcodes.conf";
|
|
||||||
PluginPlFile = "plugin.pl";
|
|
||||||
// Dirs
|
|
||||||
MapDir = "Maps/";
|
|
||||||
QuestDir = "quests/";
|
|
||||||
PluginDir = "plugins/";
|
|
||||||
LuaModuleDir = "lua_modules/";
|
|
||||||
PatchDir = "./";
|
|
||||||
SharedMemDir = "shared/";
|
|
||||||
LogDir = "logs/";
|
|
||||||
|
|
||||||
// Launcher
|
|
||||||
LogPrefix = "logs/zone-";
|
|
||||||
LogSuffix = ".log";
|
|
||||||
RestartWait = 10000; //milliseconds
|
|
||||||
TerminateWait = 10000; //milliseconds
|
|
||||||
InitialBootWait = 20000; //milliseconds
|
|
||||||
ZoneBootInterval = 2000; //milliseconds
|
|
||||||
#ifdef WIN32
|
|
||||||
ZoneExe = "zone.exe";
|
|
||||||
#else
|
|
||||||
ZoneExe = "./zone";
|
|
||||||
#endif
|
|
||||||
// Zones
|
|
||||||
ZonePortLow = 7000;
|
|
||||||
ZonePortHigh = 7999;
|
|
||||||
DefaultStatus = 0;
|
|
||||||
// For where zones need to connect to.
|
|
||||||
WorldIP = "127.0.0.1";
|
|
||||||
TelnetIP = "127.0.0.1";
|
|
||||||
// Dynamics to start
|
|
||||||
//DynamicCount=5;
|
|
||||||
MaxClients = -1;
|
|
||||||
LoginCount = 0;
|
|
||||||
}
|
}
|
||||||
virtual ~EQEmuConfig() {}
|
virtual ~EQEmuConfig() {}
|
||||||
|
|
||||||
@ -205,9 +132,7 @@ class EQEmuConfig : public XMLParser
|
|||||||
// Produce a const singleton
|
// Produce a const singleton
|
||||||
static const EQEmuConfig *get()
|
static const EQEmuConfig *get()
|
||||||
{
|
{
|
||||||
if (_config == nullptr) {
|
LoadConfig();
|
||||||
LoadConfig();
|
|
||||||
}
|
|
||||||
return (_config);
|
return (_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +149,25 @@ class EQEmuConfig : public XMLParser
|
|||||||
delete _config;
|
delete _config;
|
||||||
}
|
}
|
||||||
_config = new EQEmuConfig;
|
_config = new EQEmuConfig;
|
||||||
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(), "server");
|
|
||||||
|
return parseFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load config file and parse data
|
||||||
|
static bool parseFile() {
|
||||||
|
if (_config == nullptr) {
|
||||||
|
return LoadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ifstream fconfig(EQEmuConfig::ConfigFile, std::ifstream::binary);
|
||||||
|
try {
|
||||||
|
fconfig >> _config->_root;
|
||||||
|
_config->parse_config();
|
||||||
|
}
|
||||||
|
catch (std::exception) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dump() const;
|
void Dump() const;
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public:
|
|||||||
_chat_config=new queryservconfig;
|
_chat_config=new queryservconfig;
|
||||||
_config=_chat_config;
|
_config=_chat_config;
|
||||||
|
|
||||||
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
|
return _config->parseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public:
|
|||||||
_chat_config=new ucsconfig;
|
_chat_config=new ucsconfig;
|
||||||
_config=_chat_config;
|
_config=_chat_config;
|
||||||
|
|
||||||
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
|
return _config->parseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
2
utils/xmltojson/.gitignore
vendored
Normal file
2
utils/xmltojson/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
eqemu_config.xml
|
||||||
|
eqemu_config.json
|
||||||
1
utils/xmltojson/README.md
Normal file
1
utils/xmltojson/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
Converts the old eqemu_config.xml to eqemu_config.json
|
||||||
21
utils/xmltojson/build.bat
Normal file
21
utils/xmltojson/build.bat
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
set name="xmltojson"
|
||||||
|
|
||||||
|
echo Building Linux
|
||||||
|
set GOOS=linux
|
||||||
|
set GOARCH=amd64
|
||||||
|
go build -o %name%-linux-x64 main.go
|
||||||
|
set GOARCH=386
|
||||||
|
go build -o %name%-linux-x86 main.go
|
||||||
|
echo Building Windows
|
||||||
|
set GOOS=windows
|
||||||
|
set GOARCH=amd64
|
||||||
|
go build -o %name%-windows-x64.exe main.go
|
||||||
|
set GOARCH=386
|
||||||
|
go build -o %name%-windows-x86.exe main.go
|
||||||
|
echo Building OSX
|
||||||
|
REM set GOOS=darwin
|
||||||
|
REM set GOARCH=amd64
|
||||||
|
REM go build -o %name%-osx-x64 main.go
|
||||||
|
endlocal
|
||||||
11
utils/xmltojson/build.sh
Normal file
11
utils/xmltojson/build.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
export NAME="xmltojson"
|
||||||
|
echo Building Linux
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o $NAME-linux-x64 main.go
|
||||||
|
GOOS=linux GOARCH=386 go build -o $NAME-linux-x86 main.go
|
||||||
|
echo Building Windows
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o $NAME-windows-x64.exe main.go
|
||||||
|
GOOS=windows GOARCH=386 go build -o $NAME-windows-x86.exe main.go
|
||||||
|
#echo Building OSX
|
||||||
|
#GOOS=darwin GOARCH=amd64 go build -o $NAME-osx-x64 main.go
|
||||||
85
utils/xmltojson/main.go
Normal file
85
utils/xmltojson/main.go
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
xj "github.com/basgys/goxml2json"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var err error
|
||||||
|
var data []byte
|
||||||
|
var sData string
|
||||||
|
buf := &bytes.Buffer{}
|
||||||
|
var buf2 bytes.Buffer
|
||||||
|
|
||||||
|
if data, err = ioutil.ReadFile("eqemu_config.xml"); err != nil {
|
||||||
|
fmt.Println("Failed to open eqemu_config.xml:", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
//detect malformed xml in eqemuconfig
|
||||||
|
sData = strings.Replace(string(data), "<?xml version=\"1.0\">", "<?xml version=\"1.0\"?>", 1)
|
||||||
|
r := strings.NewReader(sData)
|
||||||
|
dec := xj.NewDecoder(r)
|
||||||
|
root := &xj.Node{}
|
||||||
|
if err = dec.DecodeWithCustomPrefixes(root, "", ""); err != nil {
|
||||||
|
fmt.Println("Failed to decode eqemu_config.xml:", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if root.Children["server"] == nil || len(root.Children["server"]) < 1 {
|
||||||
|
fmt.Println("Server element not found")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
server := root.Children["server"][0]
|
||||||
|
|
||||||
|
//locked: "true" is only way to trigger locked
|
||||||
|
if server.Children["world"] != nil && len(server.Children["world"]) > 0 {
|
||||||
|
world := server.Children["world"][0]
|
||||||
|
|
||||||
|
if world.Children["locked"] != nil && len(world.Children["locked"]) > 0 {
|
||||||
|
fmt.Println("Locked!")
|
||||||
|
world.Children["locked"][0].Data = "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elements := []string{
|
||||||
|
"chatserver",
|
||||||
|
"directories",
|
||||||
|
"files",
|
||||||
|
"launcher",
|
||||||
|
"mailserver",
|
||||||
|
"webinterface",
|
||||||
|
"world",
|
||||||
|
"zones",
|
||||||
|
}
|
||||||
|
for _, ele := range elements {
|
||||||
|
if server.Children[ele] != nil && len(server.Children[ele]) > 0 && len(server.Children[ele][0].Children) == 0 {
|
||||||
|
delete(server.Children, ele)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enc := xj.NewEncoder(buf)
|
||||||
|
err = enc.EncodeWithCustomPrefixes(root, "", "")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Failed to encode eqemu_config.xml:", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
//prettyprint
|
||||||
|
if err = json.Indent(&buf2, buf.Bytes(), "", "\t"); err != nil {
|
||||||
|
fmt.Println("Failed to encode json:", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = ioutil.WriteFile("eqemu_config.json", buf2.Bytes(), 0744); err != nil {
|
||||||
|
fmt.Println("Failed to write eqemu_config.json:", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
utils/xmltojson/xmltojson-linux-x64
Normal file
BIN
utils/xmltojson/xmltojson-linux-x64
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-linux-x86
Normal file
BIN
utils/xmltojson/xmltojson-linux-x86
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-windows-x64
Normal file
BIN
utils/xmltojson/xmltojson-windows-x64
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-windows-x64.exe
Normal file
BIN
utils/xmltojson/xmltojson-windows-x64.exe
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-windows-x86
Normal file
BIN
utils/xmltojson/xmltojson-windows-x86
Normal file
Binary file not shown.
BIN
utils/xmltojson/xmltojson-windows-x86.exe
Normal file
BIN
utils/xmltojson/xmltojson-windows-x86.exe
Normal file
Binary file not shown.
@ -166,7 +166,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(Logs::General, Logs::World_Server, "Connecting to MySQL...");
|
Log(Logs::General, Logs::World_Server, "Connecting to MySQL %s@%s:%i...", Config->DatabaseUsername.c_str(), Config->DatabaseHost.c_str(), Config->DatabasePort);
|
||||||
if (!database.Connect(
|
if (!database.Connect(
|
||||||
Config->DatabaseHost.c_str(),
|
Config->DatabaseHost.c_str(),
|
||||||
Config->DatabaseUsername.c_str(),
|
Config->DatabaseUsername.c_str(),
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public:
|
|||||||
_world_config=new WorldConfig;
|
_world_config=new WorldConfig;
|
||||||
_config=_world_config;
|
_config=_world_config;
|
||||||
|
|
||||||
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
|
return _config->parseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors for the static private object
|
// Accessors for the static private object
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class ZoneConfig : public EQEmuConfig {
|
|||||||
_zone_config=new ZoneConfig;
|
_zone_config=new ZoneConfig;
|
||||||
_config=_zone_config;
|
_config=_zone_config;
|
||||||
|
|
||||||
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
|
return _config->parseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors for the static private object
|
// Accessors for the static private object
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user