eqemu_config.cpp code structure cleanup

This commit is contained in:
Akkadius 2014-12-15 21:03:09 -06:00
parent bbea7f4f53
commit 6f747c3678

View File

@ -26,53 +26,54 @@
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
EQEmuConfig *EQEmuConfig::_config = nullptr;
void EQEmuConfig::do_world(TiXmlElement *ele) {
void EQEmuConfig::do_world(TiXmlElement *ele)
{
const char *text;
TiXmlElement * sub_ele;;
text = ParseTextBlock(ele, "shortname");
if (text)
if (text) {
ShortName = text;
}
text = ParseTextBlock(ele, "longname");
if (text)
if (text) {
LongName = text;
}
text = ParseTextBlock(ele, "address", true);
if (text)
if (text) {
WorldAddress = text;
}
text = ParseTextBlock(ele, "localaddress", true);
if (text)
if (text) {
LocalAddress = text;
}
text = ParseTextBlock(ele, "maxclients", true);
if (text)
if (text) {
MaxClients = atoi(text);
}
// Get the <key> element
text = ParseTextBlock(ele, "key", true);
if (text)
if (text) {
SharedKey = text;
}
// Get the <loginserver> element
sub_ele = ele->FirstChildElement("loginserver");
if (sub_ele) {
text = ParseTextBlock(sub_ele, "host", true);
if (text)
if (text) {
LoginHost = text;
}
text = ParseTextBlock(sub_ele, "port", true);
if (text)
if (text) {
LoginPort = atoi(text);
}
text = ParseTextBlock(sub_ele, "account", true);
if (text)
if (text) {
LoginAccount = text;
}
text = ParseTextBlock(sub_ele, "password", true);
if (text)
if (text) {
LoginPassword = text;
}
} else {
char str[32];
do {
@ -81,325 +82,369 @@ void EQEmuConfig::do_world(TiXmlElement *ele) {
if (sub_ele) {
LoginConfig* loginconfig = new LoginConfig;
text = ParseTextBlock(sub_ele, "host", true);
if (text)
if (text) {
loginconfig->LoginHost = text;
}
text = ParseTextBlock(sub_ele, "port", true);
if (text)
if (text) {
loginconfig->LoginPort = atoi(text);
}
text = ParseTextBlock(sub_ele, "account", true);
if (text)
if (text) {
loginconfig->LoginAccount = text;
}
text = ParseTextBlock(sub_ele, "password", true);
if (text)
if (text) {
loginconfig->LoginPassword = text;
}
loginlist.Insert(loginconfig);
}
} while (sub_ele);
}
// Check for locked
sub_ele = ele->FirstChildElement("locked");
if (sub_ele != nullptr)
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)
if (text) {
WorldIP = text;
text = sub_ele->Attribute("port");
if (text)
WorldTCPPort=atoi(text);
text = sub_ele->Attribute("telnet");
if (text && !strcasecmp(text,"enabled"))
TelnetEnabled=true;
}
text = sub_ele->Attribute("port");
if (text) {
WorldTCPPort = atoi(text);
}
text = sub_ele->Attribute("telnet");
if (text && !strcasecmp(text, "enabled")) {
TelnetEnabled = true;
}
}
// Get the <http> element
sub_ele = ele->FirstChildElement("http");
if (sub_ele != nullptr) {
// text = sub_ele->Attribute("ip");
// if (text)
// WorldIP=text;
text = sub_ele->Attribute("mimefile");
if (text)
if (text) {
WorldHTTPMimeFile = text;
}
text = sub_ele->Attribute("port");
if (text)
if (text) {
WorldHTTPPort = atoi(text);
}
text = sub_ele->Attribute("enabled");
if (text && !strcasecmp(text,"true"))
if (text && !strcasecmp(text, "true")) {
WorldHTTPEnabled = true;
}
}
}
void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
void EQEmuConfig::do_chatserver(TiXmlElement *ele)
{
const char *text;
text = ParseTextBlock(ele, "host", true);
if (text)
if (text) {
ChatHost = text;
}
text = ParseTextBlock(ele, "port", true);
if (text)
if (text) {
ChatPort = atoi(text);
}
}
void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
void EQEmuConfig::do_mailserver(TiXmlElement *ele)
{
const char *text;
text = ParseTextBlock(ele, "host", true);
if (text)
if (text) {
MailHost = text;
}
text = ParseTextBlock(ele, "port", true);
if (text)
if (text) {
MailPort = atoi(text);
}
}
void EQEmuConfig::do_database(TiXmlElement *ele) {
void EQEmuConfig::do_database(TiXmlElement *ele)
{
const char *text;
text = ParseTextBlock(ele, "host", true);
if (text)
if (text) {
DatabaseHost = text;
}
text = ParseTextBlock(ele, "port", true);
if (text)
if (text) {
DatabasePort = atoi(text);
}
text = ParseTextBlock(ele, "username", true);
if (text)
if (text) {
DatabaseUsername = text;
}
text = ParseTextBlock(ele, "password", true);
if (text)
if (text) {
DatabasePassword = text;
}
text = ParseTextBlock(ele, "db", true);
if (text)
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) {
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)
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);;
if (text) {
ZonePortLow = atoi(text);
};
text = sub_ele->Attribute("high");
if (text)
if (text) {
ZonePortHigh = atoi(text);
}
}
}
void EQEmuConfig::do_files(TiXmlElement *ele) {
void EQEmuConfig::do_files(TiXmlElement *ele)
{
const char *text;
text = ParseTextBlock(ele, "spells", true);
if (text)
if (text) {
SpellsFile = text;
}
text = ParseTextBlock(ele, "opcodes", true);
if (text)
if (text) {
OpCodesFile = text;
}
text = ParseTextBlock(ele, "logsettings", true);
if (text)
if (text) {
LogSettingsFile = text;
}
text = ParseTextBlock(ele, "eqtime", true);
if (text)
if (text) {
EQTimeFile = text;
}
void EQEmuConfig::do_directories(TiXmlElement *ele) {
const char *text;
text=ParseTextBlock(ele,"maps",true);
if (text)
MapDir=text;
text=ParseTextBlock(ele,"quests",true);
if (text)
QuestDir=text;
text=ParseTextBlock(ele,"plugins",true);
if (text)
PluginDir=text;
}
void EQEmuConfig::do_launcher(TiXmlElement *ele) {
void EQEmuConfig::do_directories(TiXmlElement *ele)
{
const char *text;
text = ParseTextBlock(ele, "maps", true);
if (text) {
MapDir = text;
}
text = ParseTextBlock(ele, "quests", true);
if (text) {
QuestDir = text;
}
text = ParseTextBlock(ele, "plugins", true);
if (text) {
PluginDir = text;
}
}
void EQEmuConfig::do_launcher(TiXmlElement *ele)
{
const char *text;
TiXmlElement *sub_ele;
text = ParseTextBlock(ele, "logprefix", true);
if (text)
if (text) {
LogPrefix = text;
}
text = ParseTextBlock(ele, "logsuffix", true);
if (text)
if (text) {
LogSuffix = text;
}
// Get the <exe> element
text = ParseTextBlock(ele, "exe", true);
if (text)
if (text) {
ZoneExe = text;
}
// Get the <timers> element
sub_ele = ele->FirstChildElement("timers");
if (sub_ele != nullptr) {
text = sub_ele->Attribute("restart");
if (text)
if (text) {
RestartWait = atoi(text);
}
text = sub_ele->Attribute("reterminate");
if (text)
if (text) {
TerminateWait = atoi(text);
}
text = sub_ele->Attribute("initial");
if (text)
if (text) {
InitialBootWait = atoi(text);
}
text = sub_ele->Attribute("interval");
if (text)
if (text) {
ZoneBootInterval = atoi(text);
}
}
}
std::string EQEmuConfig::GetByName(const std::string &var_name) const {
if(var_name == "ShortName")
std::string EQEmuConfig::GetByName(const std::string &var_name) const
{
if (var_name == "ShortName") {
return (ShortName);
if(var_name == "LongName")
}
if (var_name == "LongName") {
return (LongName);
if(var_name == "WorldAddress")
}
if (var_name == "WorldAddress") {
return (WorldAddress);
if(var_name == "LoginHost")
}
if (var_name == "LoginHost") {
return (LoginHost);
if(var_name == "LoginAccount")
}
if (var_name == "LoginAccount") {
return (LoginAccount);
if(var_name == "LoginPassword")
}
if (var_name == "LoginPassword") {
return (LoginPassword);
if(var_name == "LoginPort")
}
if (var_name == "LoginPort") {
return (itoa(LoginPort));
if(var_name == "Locked")
}
if (var_name == "Locked") {
return (Locked ? "true" : "false");
if(var_name == "WorldTCPPort")
}
if (var_name == "WorldTCPPort") {
return (itoa(WorldTCPPort));
if(var_name == "WorldIP")
}
if (var_name == "WorldIP") {
return (WorldIP);
if(var_name == "TelnetEnabled")
}
if (var_name == "TelnetEnabled") {
return (TelnetEnabled ? "true" : "false");
if(var_name == "WorldHTTPPort")
}
if (var_name == "WorldHTTPPort") {
return (itoa(WorldHTTPPort));
if(var_name == "WorldHTTPMimeFile")
}
if (var_name == "WorldHTTPMimeFile") {
return (WorldHTTPMimeFile);
if(var_name == "WorldHTTPEnabled")
}
if (var_name == "WorldHTTPEnabled") {
return (WorldHTTPEnabled ? "true" : "false");
if(var_name == "ChatHost")
}
if (var_name == "ChatHost") {
return (ChatHost);
if(var_name == "ChatPort")
}
if (var_name == "ChatPort") {
return (itoa(ChatPort));
if(var_name == "MailHost")
}
if (var_name == "MailHost") {
return (MailHost);
if(var_name == "MailPort")
}
if (var_name == "MailPort") {
return (itoa(MailPort));
if(var_name == "DatabaseHost")
}
if (var_name == "DatabaseHost") {
return (DatabaseHost);
if(var_name == "DatabaseUsername")
}
if (var_name == "DatabaseUsername") {
return (DatabaseUsername);
if(var_name == "DatabasePassword")
}
if (var_name == "DatabasePassword") {
return (DatabasePassword);
if(var_name == "DatabaseDB")
}
if (var_name == "DatabaseDB") {
return (DatabaseDB);
if(var_name == "DatabasePort")
}
if (var_name == "DatabasePort") {
return (itoa(DatabasePort));
if(var_name == "QSDatabaseHost")
}
if (var_name == "QSDatabaseHost") {
return (QSDatabaseHost);
if(var_name == "QSDatabaseUsername")
}
if (var_name == "QSDatabaseUsername") {
return (QSDatabaseUsername);
if(var_name == "QSDatabasePassword")
}
if (var_name == "QSDatabasePassword") {
return (QSDatabasePassword);
if(var_name == "QSDatabaseDB")
}
if (var_name == "QSDatabaseDB") {
return (QSDatabaseDB);
if(var_name == "QSDatabasePort")
}
if (var_name == "QSDatabasePort") {
return (itoa(QSDatabasePort));
if(var_name == "SpellsFile")
}
if (var_name == "SpellsFile") {
return (SpellsFile);
if(var_name == "OpCodesFile")
}
if (var_name == "OpCodesFile") {
return (OpCodesFile);
if(var_name == "EQTimeFile")
}
if (var_name == "EQTimeFile") {
return (EQTimeFile);
if(var_name == "LogSettingsFile")
}
if (var_name == "LogSettingsFile") {
return (LogSettingsFile);
if(var_name == "MapDir")
}
if (var_name == "MapDir") {
return (MapDir);
if(var_name == "QuestDir")
}
if (var_name == "QuestDir") {
return (QuestDir);
if(var_name == "PluginDir")
}
if (var_name == "PluginDir") {
return (PluginDir);
if(var_name == "LogPrefix")
}
if (var_name == "LogPrefix") {
return (LogPrefix);
if(var_name == "LogSuffix")
}
if (var_name == "LogSuffix") {
return (LogSuffix);
if(var_name == "ZoneExe")
}
if (var_name == "ZoneExe") {
return (ZoneExe);
if(var_name == "ZonePortLow")
}
if (var_name == "ZonePortLow") {
return (itoa(ZonePortLow));
if(var_name == "ZonePortHigh")
}
if (var_name == "ZonePortHigh") {
return (itoa(ZonePortHigh));
if(var_name == "DefaultStatus")
}
if (var_name == "DefaultStatus") {
return (itoa(DefaultStatus));
}
// if(var_name == "DynamicCount")
// return(itoa(DynamicCount));
return ("");