Core/Config: Refactored ConfigMgr

* Loading initial configuration files is now separate from loading any additional custom configs
This commit is contained in:
Shauren
2013-07-15 17:31:44 +02:00
parent baeecba6c9
commit 779a59e7e2
16 changed files with 470 additions and 424 deletions

View File

@@ -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");