mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Config: Refactored ConfigMgr
* Loading initial configuration files is now separate from loading any additional custom configs
This commit is contained in:
@@ -96,7 +96,7 @@ extern int main(int argc, char **argv)
|
||||
++c;
|
||||
}
|
||||
|
||||
if (!ConfigMgr::Load(cfg_file))
|
||||
if (!sConfigMgr->LoadInitial(cfg_file))
|
||||
{
|
||||
printf("Invalid or missing configuration file : %s\n", cfg_file);
|
||||
printf("Verify that the file exists and has \'[authserver]\' written in the top of the file!\n");
|
||||
@@ -118,7 +118,7 @@ extern int main(int argc, char **argv)
|
||||
TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "Max allowed open files is %d", ACE::max_handles());
|
||||
|
||||
// authserver PID file creation
|
||||
std::string pidfile = ConfigMgr::GetStringDefault("PidFile", "");
|
||||
std::string pidfile = sConfigMgr->GetStringDefault("PidFile", "");
|
||||
if (!pidfile.empty())
|
||||
{
|
||||
uint32 pid = CreatePIDFile(pidfile);
|
||||
@@ -135,7 +135,7 @@ extern int main(int argc, char **argv)
|
||||
return 1;
|
||||
|
||||
// Get the list of realms for the server
|
||||
sRealmList->Initialize(ConfigMgr::GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
sRealmList->Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||
if (sRealmList->size() == 0)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "No valid realms specified.");
|
||||
@@ -145,14 +145,14 @@ extern int main(int argc, char **argv)
|
||||
// Launch the listening network socket
|
||||
RealmAcceptor acceptor;
|
||||
|
||||
int32 rmport = ConfigMgr::GetIntDefault("RealmServerPort", 3724);
|
||||
int32 rmport = sConfigMgr->GetIntDefault("RealmServerPort", 3724);
|
||||
if (rmport < 0 || rmport > 0xFFFF)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Specified port out of allowed range (1-65535)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string bind_ip = ConfigMgr::GetStringDefault("BindIP", "0.0.0.0");
|
||||
std::string bind_ip = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
ACE_INET_Addr bind_addr(uint16(rmport), bind_ip.c_str());
|
||||
|
||||
@@ -175,7 +175,7 @@ extern int main(int argc, char **argv)
|
||||
{
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
uint32 Aff = ConfigMgr::GetIntDefault("UseProcessors", 0);
|
||||
uint32 Aff = sConfigMgr->GetIntDefault("UseProcessors", 0);
|
||||
if (Aff > 0)
|
||||
{
|
||||
ULONG_PTR appAff;
|
||||
@@ -195,7 +195,7 @@ extern int main(int argc, char **argv)
|
||||
|
||||
}
|
||||
|
||||
bool Prio = ConfigMgr::GetBoolDefault("ProcessPriority", false);
|
||||
bool Prio = sConfigMgr->GetBoolDefault("ProcessPriority", false);
|
||||
|
||||
if (Prio)
|
||||
{
|
||||
@@ -209,7 +209,7 @@ extern int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
// maximum counter for next ping
|
||||
uint32 numLoops = (ConfigMgr::GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000000 / 100000));
|
||||
uint32 numLoops = (sConfigMgr->GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000000 / 100000));
|
||||
uint32 loopCounter = 0;
|
||||
|
||||
// Wait for termination signal
|
||||
@@ -241,21 +241,21 @@ bool StartDB()
|
||||
{
|
||||
MySQL::Library_Init();
|
||||
|
||||
std::string dbstring = ConfigMgr::GetStringDefault("LoginDatabaseInfo", "");
|
||||
std::string dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Database not specified");
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 worker_threads = ConfigMgr::GetIntDefault("LoginDatabase.WorkerThreads", 1);
|
||||
int32 worker_threads = sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1);
|
||||
if (worker_threads < 1 || worker_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.WorkerThreads, defaulting to 1.");
|
||||
worker_threads = 1;
|
||||
}
|
||||
|
||||
int32 synch_threads = ConfigMgr::GetIntDefault("LoginDatabase.SynchThreads", 1);
|
||||
int32 synch_threads = sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1);
|
||||
if (synch_threads < 1 || synch_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_AUTHSERVER, "Improper value specified for LoginDatabase.SynchThreads, defaulting to 1.");
|
||||
|
||||
@@ -682,7 +682,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
|
||||
TC_LOG_DEBUG(LOG_FILTER_AUTHSERVER, "'%s:%d' [AuthChallenge] account %s tried to login with invalid password!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ());
|
||||
|
||||
uint32 MaxWrongPassCount = ConfigMgr::GetIntDefault("WrongPass.MaxCount", 0);
|
||||
uint32 MaxWrongPassCount = sConfigMgr->GetIntDefault("WrongPass.MaxCount", 0);
|
||||
if (MaxWrongPassCount > 0)
|
||||
{
|
||||
//Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
|
||||
@@ -699,8 +699,8 @@ bool AuthSocket::_HandleLogonProof()
|
||||
|
||||
if (failed_logins >= MaxWrongPassCount)
|
||||
{
|
||||
uint32 WrongPassBanTime = ConfigMgr::GetIntDefault("WrongPass.BanTime", 600);
|
||||
bool WrongPassBanType = ConfigMgr::GetBoolDefault("WrongPass.BanType", false);
|
||||
uint32 WrongPassBanTime = sConfigMgr->GetIntDefault("WrongPass.BanTime", 600);
|
||||
bool WrongPassBanType = sConfigMgr->GetBoolDefault("WrongPass.BanType", false);
|
||||
|
||||
if (WrongPassBanType)
|
||||
{
|
||||
|
||||
@@ -439,7 +439,7 @@ void AccountMgr::LoadRBAC()
|
||||
|
||||
TC_LOG_DEBUG(LOG_FILTER_RBAC, "AccountMgr::LoadRBAC: Loading default groups");
|
||||
// Load default groups to be added to any RBAC Object.
|
||||
std::string defaultGroups = ConfigMgr::GetStringDefault("RBAC.DefaultGroups", "");
|
||||
std::string defaultGroups = sConfigMgr->GetStringDefault("RBAC.DefaultGroups", "");
|
||||
Tokenizer tokens(defaultGroups, ',');
|
||||
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
|
||||
if (uint32 groupId = atoi(*itr))
|
||||
@@ -448,7 +448,7 @@ void AccountMgr::LoadRBAC()
|
||||
|
||||
void AccountMgr::UpdateAccountAccess(RBACData* rbac, uint32 accountId, uint8 securityLevel, int32 realmId)
|
||||
{
|
||||
int32 serverRealmId = realmId != -1 ? realmId : ConfigMgr::GetIntDefault("RealmID", 0);
|
||||
int32 serverRealmId = realmId != -1 ? realmId : sConfigMgr->GetIntDefault("RealmID", 0);
|
||||
bool needDelete = false;
|
||||
if (!rbac)
|
||||
{
|
||||
|
||||
@@ -2123,7 +2123,7 @@ bool Guild::Validate()
|
||||
_SetLeaderGUID(pLeader);
|
||||
|
||||
// Check config if multiple guildmasters are allowed
|
||||
if (!ConfigMgr::GetBoolDefault("Guild.AllowMultipleGuildMaster", 0))
|
||||
if (!sConfigMgr->GetBoolDefault("Guild.AllowMultipleGuildMaster", 0))
|
||||
for (Members::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
if (itr->second->GetRankId() == GR_GUILDMASTER && !itr->second->IsSamePlayer(m_leaderGuid))
|
||||
itr->second->ChangeRank(GR_OFFICER);
|
||||
|
||||
@@ -35,13 +35,13 @@ PacketLog::~PacketLog()
|
||||
|
||||
void PacketLog::Initialize()
|
||||
{
|
||||
std::string logsDir = ConfigMgr::GetStringDefault("LogsDir", "");
|
||||
std::string logsDir = sConfigMgr->GetStringDefault("LogsDir", "");
|
||||
|
||||
if (!logsDir.empty())
|
||||
if ((logsDir.at(logsDir.length()-1) != '/') && (logsDir.at(logsDir.length()-1) != '\\'))
|
||||
logsDir.push_back('/');
|
||||
|
||||
std::string logname = ConfigMgr::GetStringDefault("PacketLogFile", "");
|
||||
std::string logname = sConfigMgr->GetStringDefault("PacketLogFile", "");
|
||||
if (!logname.empty())
|
||||
_file = fopen((logsDir + logname).c_str(), "wb");
|
||||
}
|
||||
|
||||
@@ -230,9 +230,9 @@ WorldSocketMgr::~WorldSocketMgr()
|
||||
int
|
||||
WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
|
||||
{
|
||||
m_UseNoDelay = ConfigMgr::GetBoolDefault ("Network.TcpNodelay", true);
|
||||
m_UseNoDelay = sConfigMgr->GetBoolDefault ("Network.TcpNodelay", true);
|
||||
|
||||
int num_threads = ConfigMgr::GetIntDefault ("Network.Threads", 1);
|
||||
int num_threads = sConfigMgr->GetIntDefault ("Network.Threads", 1);
|
||||
|
||||
if (num_threads <= 0)
|
||||
{
|
||||
@@ -247,9 +247,9 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
|
||||
TC_LOG_DEBUG(LOG_FILTER_GENERAL, "Max allowed socket connections %d", ACE::max_handles());
|
||||
|
||||
// -1 means use default
|
||||
m_SockOutKBuff = ConfigMgr::GetIntDefault ("Network.OutKBuff", -1);
|
||||
m_SockOutKBuff = sConfigMgr->GetIntDefault ("Network.OutKBuff", -1);
|
||||
|
||||
m_SockOutUBuff = ConfigMgr::GetIntDefault ("Network.OutUBuff", 65536);
|
||||
m_SockOutUBuff = sConfigMgr->GetIntDefault ("Network.OutUBuff", 65536);
|
||||
|
||||
if (m_SockOutUBuff <= 0)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -153,7 +153,7 @@ public:
|
||||
sWorld->SetPlayerSecurityLimit(SEC_ADMINISTRATOR);
|
||||
else if (strncmp(paramStr, "reset", limit) == 0)
|
||||
{
|
||||
sWorld->SetPlayerAmountLimit(ConfigMgr::GetIntDefault("PlayerLimit", 100));
|
||||
sWorld->SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
|
||||
sWorld->LoadDBAllowedSecurityLevel();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -17,72 +17,79 @@
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
#include <ace/Auto_Ptr.h>
|
||||
#include <ace/Configuration_Import_Export.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include "Errors.h"
|
||||
|
||||
namespace ConfigMgr
|
||||
// Defined here as it must not be exposed to end-users.
|
||||
bool ConfigMgr::GetValueHelper(const char* name, ACE_TString &result)
|
||||
{
|
||||
GuardType guard(_configLock);
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef ACE_Thread_Mutex LockType;
|
||||
typedef ACE_Guard<LockType> GuardType;
|
||||
|
||||
std::string _filename;
|
||||
ACE_Auto_Ptr<ACE_Configuration_Heap> _config;
|
||||
LockType m_configLock;
|
||||
|
||||
// Defined here as it must not be exposed to end-users.
|
||||
bool GetValueHelper(const char* name, ACE_TString &result)
|
||||
{
|
||||
GuardType guard(m_configLock);
|
||||
|
||||
if (_config.get() == 0)
|
||||
return false;
|
||||
|
||||
ACE_TString section_name;
|
||||
ACE_Configuration_Section_Key section_key;
|
||||
const ACE_Configuration_Section_Key &root_key = _config->root_section();
|
||||
|
||||
int i = 0;
|
||||
while (_config->enumerate_sections(root_key, i, section_name) == 0)
|
||||
{
|
||||
_config->open_section(root_key, section_name.c_str(), 0, section_key);
|
||||
if (_config->get_string_value(section_key, name, result) == 0)
|
||||
return true;
|
||||
++i;
|
||||
}
|
||||
|
||||
if (_config.get() == 0)
|
||||
return false;
|
||||
|
||||
ACE_TString section_name;
|
||||
ACE_Configuration_Section_Key section_key;
|
||||
const ACE_Configuration_Section_Key &root_key = _config->root_section();
|
||||
|
||||
int i = 0;
|
||||
while (_config->enumerate_sections(root_key, i, section_name) == 0)
|
||||
{
|
||||
_config->open_section(root_key, section_name.c_str(), 0, section_key);
|
||||
if (_config->get_string_value(section_key, name, result) == 0)
|
||||
return true;
|
||||
++i;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Load(const char* file)
|
||||
bool ConfigMgr::LoadInitial(char const* file)
|
||||
{
|
||||
GuardType guard(m_configLock);
|
||||
ASSERT(file);
|
||||
|
||||
if (file)
|
||||
_filename = file;
|
||||
GuardType guard(_configLock);
|
||||
|
||||
_config.reset(new ACE_Configuration_Heap);
|
||||
_filename = file;
|
||||
_config.reset(new ACE_Configuration_Heap());
|
||||
if (_config->open() == 0)
|
||||
{
|
||||
ACE_Ini_ImpExp config_importer(*_config.get());
|
||||
if (config_importer.import_config(_filename.c_str()) == 0)
|
||||
if (LoadData(_filename.c_str()))
|
||||
return true;
|
||||
}
|
||||
|
||||
_config.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string GetStringDefault(const char* name, const std::string &def)
|
||||
bool ConfigMgr::LoadMore(char const* file)
|
||||
{
|
||||
ASSERT(file);
|
||||
ASSERT(_config);
|
||||
|
||||
GuardType guard(_configLock);
|
||||
|
||||
return LoadData(file);
|
||||
}
|
||||
|
||||
bool ConfigMgr::Reload()
|
||||
{
|
||||
return LoadInitial(_filename.c_str());
|
||||
}
|
||||
|
||||
bool ConfigMgr::LoadData(char const* file)
|
||||
{
|
||||
ACE_Ini_ImpExp config_importer(*_config.get());
|
||||
if (config_importer.import_config(file) == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string ConfigMgr::GetStringDefault(const char* name, const std::string &def)
|
||||
{
|
||||
ACE_TString val;
|
||||
return GetValueHelper(name, val) ? val.c_str() : def;
|
||||
}
|
||||
|
||||
bool GetBoolDefault(const char* name, bool def)
|
||||
bool ConfigMgr::GetBoolDefault(const char* name, bool def)
|
||||
{
|
||||
ACE_TString val;
|
||||
|
||||
@@ -93,22 +100,20 @@ bool GetBoolDefault(const char* name, bool def)
|
||||
val == "1");
|
||||
}
|
||||
|
||||
int GetIntDefault(const char* name, int def)
|
||||
int ConfigMgr::GetIntDefault(const char* name, int def)
|
||||
{
|
||||
ACE_TString val;
|
||||
return GetValueHelper(name, val) ? atoi(val.c_str()) : def;
|
||||
}
|
||||
|
||||
float GetFloatDefault(const char* name, float def)
|
||||
float ConfigMgr::GetFloatDefault(const char* name, float def)
|
||||
{
|
||||
ACE_TString val;
|
||||
return GetValueHelper(name, val) ? (float)atof(val.c_str()) : def;
|
||||
}
|
||||
|
||||
const std::string & GetFilename()
|
||||
std::string const& ConfigMgr::GetFilename()
|
||||
{
|
||||
GuardType guard(m_configLock);
|
||||
GuardType guard(_configLock);
|
||||
return _filename;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -20,17 +20,58 @@
|
||||
#define CONFIG_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Configuration_Import_Export.h>
|
||||
#include <ace/Thread_Mutex.h>
|
||||
#include <AutoPtr.h>
|
||||
|
||||
namespace ConfigMgr
|
||||
typedef Trinity::AutoPtr<ACE_Configuration_Heap, ACE_Null_Mutex> Config;
|
||||
|
||||
class ConfigMgr
|
||||
{
|
||||
bool Load(const char *file = NULL);
|
||||
friend class ACE_Singleton<ConfigMgr, ACE_Null_Mutex>;
|
||||
friend class ConfigLoader;
|
||||
|
||||
ConfigMgr() { }
|
||||
~ConfigMgr() { }
|
||||
|
||||
public:
|
||||
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
|
||||
bool LoadInitial(char const* file);
|
||||
|
||||
/**
|
||||
* This method loads additional configuration files
|
||||
* It is recommended to use this method in WorldScript::OnConfigLoad hooks
|
||||
*
|
||||
* @return true if loading was successful
|
||||
*/
|
||||
bool LoadMore(char const* file);
|
||||
|
||||
bool Reload();
|
||||
|
||||
std::string GetStringDefault(const char* name, const std::string& def);
|
||||
bool GetBoolDefault(const char* name, bool def);
|
||||
int GetIntDefault(const char* name, int def);
|
||||
float GetFloatDefault(const char* name, float def);
|
||||
|
||||
const std::string & GetFilename();
|
||||
}
|
||||
std::string const& GetFilename();
|
||||
|
||||
private:
|
||||
bool GetValueHelper(const char* name, ACE_TString &result);
|
||||
bool LoadData(char const* file);
|
||||
|
||||
typedef ACE_Thread_Mutex LockType;
|
||||
typedef ACE_Guard<LockType> GuardType;
|
||||
|
||||
std::string _filename;
|
||||
Config _config;
|
||||
LockType _configLock;
|
||||
|
||||
ConfigMgr(ConfigMgr const&);
|
||||
ConfigMgr& operator=(ConfigMgr const&);
|
||||
};
|
||||
|
||||
#define sConfigMgr ACE_Singleton<ConfigMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -48,13 +48,13 @@ uint8 Log::NextAppenderId()
|
||||
int32 GetConfigIntDefault(std::string base, const char* name, int32 value)
|
||||
{
|
||||
base.append(name);
|
||||
return ConfigMgr::GetIntDefault(base.c_str(), value);
|
||||
return sConfigMgr->GetIntDefault(base.c_str(), value);
|
||||
}
|
||||
|
||||
std::string GetConfigStringDefault(std::string base, const char* name, const char* value)
|
||||
{
|
||||
base.append(name);
|
||||
return ConfigMgr::GetStringDefault(base.c_str(), value);
|
||||
return sConfigMgr->GetStringDefault(base.c_str(), value);
|
||||
}
|
||||
|
||||
// Returns default logger if the requested logger is not found
|
||||
@@ -83,7 +83,7 @@ void Log::CreateAppenderFromConfig(const char* name)
|
||||
// if type = Console. optional1 = Color
|
||||
std::string options = "Appender.";
|
||||
options.append(name);
|
||||
options = ConfigMgr::GetStringDefault(options.c_str(), "");
|
||||
options = sConfigMgr->GetStringDefault(options.c_str(), "");
|
||||
Tokenizer tokens(options, ',');
|
||||
Tokenizer::const_iterator iter = tokens.begin();
|
||||
uint8 size = tokens.size();
|
||||
@@ -173,7 +173,7 @@ void Log::CreateLoggerFromConfig(const char* name)
|
||||
|
||||
std::string options = "Logger.";
|
||||
options.append(name);
|
||||
options = ConfigMgr::GetStringDefault(options.c_str(), "");
|
||||
options = sConfigMgr->GetStringDefault(options.c_str(), "");
|
||||
|
||||
if (options.empty())
|
||||
{
|
||||
@@ -235,7 +235,7 @@ void Log::CreateLoggerFromConfig(const char* name)
|
||||
|
||||
void Log::ReadAppendersFromConfig()
|
||||
{
|
||||
std::istringstream ss(ConfigMgr::GetStringDefault("Appenders", ""));
|
||||
std::istringstream ss(sConfigMgr->GetStringDefault("Appenders", ""));
|
||||
std::string name;
|
||||
|
||||
do
|
||||
@@ -249,7 +249,7 @@ void Log::ReadAppendersFromConfig()
|
||||
|
||||
void Log::ReadLoggersFromConfig()
|
||||
{
|
||||
std::istringstream ss(ConfigMgr::GetStringDefault("Loggers", ""));
|
||||
std::istringstream ss(sConfigMgr->GetStringDefault("Loggers", ""));
|
||||
std::string name;
|
||||
|
||||
do
|
||||
@@ -457,11 +457,11 @@ void Log::LoadFromConfig()
|
||||
{
|
||||
Close();
|
||||
|
||||
if (ConfigMgr::GetBoolDefault("Log.Async.Enable", false))
|
||||
if (sConfigMgr->GetBoolDefault("Log.Async.Enable", false))
|
||||
worker = new LogWorker();
|
||||
|
||||
AppenderId = 0;
|
||||
m_logsDir = ConfigMgr::GetStringDefault("LogsDir", "");
|
||||
m_logsDir = sConfigMgr->GetStringDefault("LogsDir", "");
|
||||
if (!m_logsDir.empty())
|
||||
if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\'))
|
||||
m_logsDir.push_back('/');
|
||||
|
||||
@@ -141,7 +141,7 @@ void CliRunnable::run()
|
||||
rl_event_hook = cli_hook_func;
|
||||
#endif
|
||||
|
||||
if (ConfigMgr::GetBoolDefault("BeepAtStart", true))
|
||||
if (sConfigMgr->GetBoolDefault("BeepAtStart", true))
|
||||
printf("\a"); // \a = Alert
|
||||
|
||||
// print this here the first time
|
||||
|
||||
@@ -129,7 +129,7 @@ extern int main(int argc, char **argv)
|
||||
++c;
|
||||
}
|
||||
|
||||
if (!ConfigMgr::Load(cfg_file))
|
||||
if (!sConfigMgr->LoadInitial(cfg_file))
|
||||
{
|
||||
printf("Invalid or missing configuration file : %s\n", cfg_file);
|
||||
printf("Verify that the file exists and has \'[worldserver]' written in the top of the file!\n");
|
||||
|
||||
@@ -138,7 +138,7 @@ int Master::Run()
|
||||
TC_LOG_INFO(LOG_FILTER_WORLDSERVER, "http://TrinityCore.org \\/__/\n");
|
||||
|
||||
/// worldserver PID file creation
|
||||
std::string pidfile = ConfigMgr::GetStringDefault("PidFile", "");
|
||||
std::string pidfile = sConfigMgr->GetStringDefault("PidFile", "");
|
||||
if (!pidfile.empty())
|
||||
{
|
||||
uint32 pid = CreatePIDFile(pidfile);
|
||||
@@ -182,9 +182,9 @@ int Master::Run()
|
||||
ACE_Based::Thread* cliThread = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (ConfigMgr::GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
|
||||
if (sConfigMgr->GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
|
||||
#else
|
||||
if (ConfigMgr::GetBoolDefault("Console.Enable", true))
|
||||
if (sConfigMgr->GetBoolDefault("Console.Enable", true))
|
||||
#endif
|
||||
{
|
||||
///- Launch CliRunnable thread
|
||||
@@ -198,7 +198,7 @@ int Master::Run()
|
||||
{
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
|
||||
uint32 Aff = ConfigMgr::GetIntDefault("UseProcessors", 0);
|
||||
uint32 Aff = sConfigMgr->GetIntDefault("UseProcessors", 0);
|
||||
if (Aff > 0)
|
||||
{
|
||||
ULONG_PTR appAff;
|
||||
@@ -222,7 +222,7 @@ int Master::Run()
|
||||
}
|
||||
}
|
||||
|
||||
bool Prio = ConfigMgr::GetBoolDefault("ProcessPriority", false);
|
||||
bool Prio = sConfigMgr->GetBoolDefault("ProcessPriority", false);
|
||||
|
||||
//if (Prio && (m_ServiceStatus == -1) /* need set to default process priority class in service mode*/)
|
||||
if (Prio)
|
||||
@@ -237,15 +237,15 @@ int Master::Run()
|
||||
//Start soap serving thread
|
||||
ACE_Based::Thread* soap_thread = NULL;
|
||||
|
||||
if (ConfigMgr::GetBoolDefault("SOAP.Enabled", false))
|
||||
if (sConfigMgr->GetBoolDefault("SOAP.Enabled", false))
|
||||
{
|
||||
TCSoapRunnable* runnable = new TCSoapRunnable();
|
||||
runnable->setListenArguments(ConfigMgr::GetStringDefault("SOAP.IP", "127.0.0.1"), uint16(ConfigMgr::GetIntDefault("SOAP.Port", 7878)));
|
||||
runnable->setListenArguments(sConfigMgr->GetStringDefault("SOAP.IP", "127.0.0.1"), uint16(sConfigMgr->GetIntDefault("SOAP.Port", 7878)));
|
||||
soap_thread = new ACE_Based::Thread(runnable);
|
||||
}
|
||||
|
||||
///- Start up freeze catcher thread
|
||||
if (uint32 freeze_delay = ConfigMgr::GetIntDefault("MaxCoreStuckTime", 0))
|
||||
if (uint32 freeze_delay = sConfigMgr->GetIntDefault("MaxCoreStuckTime", 0))
|
||||
{
|
||||
FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable();
|
||||
fdr->SetDelayTime(freeze_delay * 1000);
|
||||
@@ -255,7 +255,7 @@ int Master::Run()
|
||||
|
||||
///- Launch the world listener socket
|
||||
uint16 wsport = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
|
||||
std::string bind_ip = ConfigMgr::GetStringDefault("BindIP", "0.0.0.0");
|
||||
std::string bind_ip = sConfigMgr->GetStringDefault("BindIP", "0.0.0.0");
|
||||
|
||||
if (sWorldSocketMgr->StartNetwork(wsport, bind_ip.c_str()) == -1)
|
||||
{
|
||||
@@ -357,14 +357,14 @@ bool Master::_StartDB()
|
||||
std::string dbstring;
|
||||
uint8 async_threads, synch_threads;
|
||||
|
||||
dbstring = ConfigMgr::GetStringDefault("WorldDatabaseInfo", "");
|
||||
dbstring = sConfigMgr->GetStringDefault("WorldDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "World database not specified in configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
async_threads = uint8(ConfigMgr::GetIntDefault("WorldDatabase.WorkerThreads", 1));
|
||||
async_threads = uint8(sConfigMgr->GetIntDefault("WorldDatabase.WorkerThreads", 1));
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "World database: invalid number of worker threads specified. "
|
||||
@@ -372,7 +372,7 @@ bool Master::_StartDB()
|
||||
return false;
|
||||
}
|
||||
|
||||
synch_threads = uint8(ConfigMgr::GetIntDefault("WorldDatabase.SynchThreads", 1));
|
||||
synch_threads = uint8(sConfigMgr->GetIntDefault("WorldDatabase.SynchThreads", 1));
|
||||
///- Initialise the world database
|
||||
if (!WorldDatabase.Open(dbstring, async_threads, synch_threads))
|
||||
{
|
||||
@@ -381,14 +381,14 @@ bool Master::_StartDB()
|
||||
}
|
||||
|
||||
///- Get character database info from configuration file
|
||||
dbstring = ConfigMgr::GetStringDefault("CharacterDatabaseInfo", "");
|
||||
dbstring = sConfigMgr->GetStringDefault("CharacterDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Character database not specified in configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
async_threads = uint8(ConfigMgr::GetIntDefault("CharacterDatabase.WorkerThreads", 1));
|
||||
async_threads = uint8(sConfigMgr->GetIntDefault("CharacterDatabase.WorkerThreads", 1));
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Character database: invalid number of worker threads specified. "
|
||||
@@ -396,7 +396,7 @@ bool Master::_StartDB()
|
||||
return false;
|
||||
}
|
||||
|
||||
synch_threads = uint8(ConfigMgr::GetIntDefault("CharacterDatabase.SynchThreads", 2));
|
||||
synch_threads = uint8(sConfigMgr->GetIntDefault("CharacterDatabase.SynchThreads", 2));
|
||||
|
||||
///- Initialise the Character database
|
||||
if (!CharacterDatabase.Open(dbstring, async_threads, synch_threads))
|
||||
@@ -406,14 +406,14 @@ bool Master::_StartDB()
|
||||
}
|
||||
|
||||
///- Get login database info from configuration file
|
||||
dbstring = ConfigMgr::GetStringDefault("LoginDatabaseInfo", "");
|
||||
dbstring = sConfigMgr->GetStringDefault("LoginDatabaseInfo", "");
|
||||
if (dbstring.empty())
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Login database not specified in configuration file");
|
||||
return false;
|
||||
}
|
||||
|
||||
async_threads = uint8(ConfigMgr::GetIntDefault("LoginDatabase.WorkerThreads", 1));
|
||||
async_threads = uint8(sConfigMgr->GetIntDefault("LoginDatabase.WorkerThreads", 1));
|
||||
if (async_threads < 1 || async_threads > 32)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Login database: invalid number of worker threads specified. "
|
||||
@@ -421,7 +421,7 @@ bool Master::_StartDB()
|
||||
return false;
|
||||
}
|
||||
|
||||
synch_threads = uint8(ConfigMgr::GetIntDefault("LoginDatabase.SynchThreads", 1));
|
||||
synch_threads = uint8(sConfigMgr->GetIntDefault("LoginDatabase.SynchThreads", 1));
|
||||
///- Initialise the login database
|
||||
if (!LoginDatabase.Open(dbstring, async_threads, synch_threads))
|
||||
{
|
||||
@@ -430,7 +430,7 @@ bool Master::_StartDB()
|
||||
}
|
||||
|
||||
///- Get the realm Id from the configuration file
|
||||
realmID = ConfigMgr::GetIntDefault("RealmID", 0);
|
||||
realmID = sConfigMgr->GetIntDefault("RealmID", 0);
|
||||
if (!realmID)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_WORLDSERVER, "Realm ID not defined in configuration file");
|
||||
|
||||
@@ -56,13 +56,13 @@ RARunnable::~RARunnable()
|
||||
|
||||
void RARunnable::run()
|
||||
{
|
||||
if (!ConfigMgr::GetBoolDefault("Ra.Enable", false))
|
||||
if (!sConfigMgr->GetBoolDefault("Ra.Enable", false))
|
||||
return;
|
||||
|
||||
ACE_Acceptor<RASocket, ACE_SOCK_ACCEPTOR> acceptor;
|
||||
|
||||
uint16 raport = uint16(ConfigMgr::GetIntDefault("Ra.Port", 3443));
|
||||
std::string stringip = ConfigMgr::GetStringDefault("Ra.IP", "0.0.0.0");
|
||||
uint16 raport = uint16(sConfigMgr->GetIntDefault("Ra.Port", 3443));
|
||||
std::string stringip = sConfigMgr->GetStringDefault("Ra.IP", "0.0.0.0");
|
||||
ACE_INET_Addr listen_addr(raport, stringip.c_str());
|
||||
|
||||
if (acceptor.open(listen_addr, m_Reactor) == -1)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
RASocket::RASocket()
|
||||
{
|
||||
_minLevel = uint8(ConfigMgr::GetIntDefault("RA.MinLevel", 3));
|
||||
_minLevel = uint8(sConfigMgr->GetIntDefault("RA.MinLevel", 3));
|
||||
_commandExecuting = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user