eqemu_config.cpp & .h header cleanup, code style cleanup of eqemu_config.h

This commit is contained in:
Akkadius 2014-12-15 21:01:52 -06:00
parent e048c5cf17
commit bbea7f4f53
2 changed files with 162 additions and 168 deletions

View File

@ -15,9 +15,11 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../common/debug.h"
#include "eqemu_config.h"
#include "misc_functions.h"
#include <iostream>
#include <sstream>

View File

@ -28,8 +28,9 @@ struct LoginConfig {
uint16 LoginPort;
};
class EQEmuConfig : public XMLParser {
public:
class EQEmuConfig : public XMLParser
{
public:
virtual std::string GetByName(const std::string &var_name) const;
// From <world/>
@ -104,7 +105,7 @@ public:
// map<string,uint16> StaticZones;
protected:
protected:
static EQEmuConfig *_config;
@ -112,63 +113,54 @@ protected:
#define ELEMENT(name) \
void do_##name(TiXmlElement *ele);
#include "eqemu_config_elements.h"
#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"
#include "eqemu_config_elements.h"
// Set sane defaults
// Login server
LoginHost="eqemulator.net";
LoginPort=5998;
LoginHost = "eqemulator.net";
LoginPort = 5998;
// World
Locked=false;
WorldTCPPort=9000;
TelnetEnabled=false;
WorldHTTPEnabled=false;
WorldHTTPPort=9080;
WorldHTTPMimeFile="mime.types";
Locked = false;
WorldTCPPort = 9000;
TelnetEnabled = false;
WorldHTTPEnabled = false;
WorldHTTPPort = 9080;
WorldHTTPMimeFile = "mime.types";
SharedKey = ""; //blank disables authentication
// Mail
ChatHost="eqchat.eqemulator.net";
ChatPort=7778;
ChatHost = "eqchat.eqemulator.net";
ChatPort = 7778;
// Mail
MailHost="eqmail.eqemulator.net";
MailPort=7779;
MailHost = "eqmail.eqemulator.net";
MailPort = 7779;
// Mysql
DatabaseHost="localhost";
DatabasePort=3306;
DatabaseUsername="eq";
DatabasePassword="eq";
DatabaseDB="eq";
DatabaseHost = "localhost";
DatabasePort = 3306;
DatabaseUsername = "eq";
DatabasePassword = "eq";
DatabaseDB = "eq";
// QueryServ Database
QSDatabaseHost="localhost";
QSDatabasePort=3306;
QSDatabaseUsername="eq";
QSDatabasePassword="eq";
QSDatabaseDB="eq";
QSDatabaseHost = "localhost";
QSDatabasePort = 3306;
QSDatabaseUsername = "eq";
QSDatabasePassword = "eq";
QSDatabaseDB = "eq";
// Files
SpellsFile="spells_us.txt";
OpCodesFile="opcodes.conf";
EQTimeFile="eqtime.cfg";
LogSettingsFile="log.ini";
SpellsFile = "spells_us.txt";
OpCodesFile = "opcodes.conf";
EQTimeFile = "eqtime.cfg";
LogSettingsFile = "log.ini";
// Dirs
MapDir="Maps";
QuestDir="quests";
PluginDir="plugins";
MapDir = "Maps";
QuestDir = "quests";
PluginDir = "plugins";
// Launcher
LogPrefix = "logs/zone-";
LogSuffix = ".log";
@ -176,49 +168,49 @@ protected:
TerminateWait = 10000; //milliseconds
InitialBootWait = 20000; //milliseconds
ZoneBootInterval = 2000; //milliseconds
#ifdef WIN32
#ifdef WIN32
ZoneExe = "zone.exe";
#else
#else
ZoneExe = "./zone";
#endif
#endif
// Zones
ZonePortLow=7000;
ZonePortHigh=7999;
DefaultStatus=0;
ZonePortLow = 7000;
ZonePortHigh = 7999;
DefaultStatus = 0;
// For where zones need to connect to.
WorldIP="127.0.0.1";
WorldIP = "127.0.0.1";
// Dynamics to start
//DynamicCount=5;
MaxClients=-1;
LoginCount=0;
MaxClients = -1;
LoginCount = 0;
}
virtual ~EQEmuConfig() {}
public:
public:
// Produce a const singleton
static const EQEmuConfig *get() {
if (_config == nullptr)
static const EQEmuConfig *get()
{
if (_config == nullptr) {
LoadConfig();
return(_config);
}
return (_config);
}
// Allow the use to set the conf file to be used.
static void SetConfigFile(std::string file) { EQEmuConfig::ConfigFile = file; }
static void SetConfigFile(std::string file)
{
EQEmuConfig::ConfigFile = file;
}
// Load the config
static bool LoadConfig() {
if (_config != nullptr)
static bool LoadConfig()
{
if (_config != nullptr) {
delete _config;
_config=new EQEmuConfig;
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
}
_config = new EQEmuConfig;
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(), "server");
}
void Dump() const;