mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 16:43:47 +00:00
feat(Core/Config): rework configs load system (#2566)
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef _ACORE_REALM_CONFIG
|
||||
# define _ACORE_REALM_CONFIG "authserver.conf"
|
||||
#define _ACORE_REALM_CONFIG "authserver.conf"
|
||||
#endif
|
||||
|
||||
bool StartDB();
|
||||
@@ -92,19 +92,10 @@ extern int main(int argc, char** argv)
|
||||
++count;
|
||||
}
|
||||
|
||||
std::string cfg_def_file=_ACORE_REALM_CONFIG;
|
||||
cfg_def_file += ".dist";
|
||||
sConfigMgr->SetConfigList(std::string(configFile));
|
||||
|
||||
if (!sConfigMgr->LoadInitial(cfg_def_file.c_str())) {
|
||||
printf("ERROR: Invalid or missing default configuration file : %s\n", cfg_def_file.c_str());
|
||||
if (!sConfigMgr->LoadAppConfigs("authserver"))
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!sConfigMgr->LoadMore(configFile))
|
||||
{
|
||||
printf("WARNING: Invalid or missing configuration file : %s\n", configFile);
|
||||
printf("Verify that the file exists and has \'[authserver]\' written in the top of the file!\n");
|
||||
}
|
||||
|
||||
sLog->outString("%s (authserver)", GitRevision::GetFullVersion());
|
||||
sLog->outString("<Ctrl-C> to stop.\n");
|
||||
|
||||
@@ -124,8 +124,6 @@ World::World()
|
||||
|
||||
m_CleaningFlags = 0;
|
||||
|
||||
m_configFileList = "";
|
||||
|
||||
memset(rate_values, 0, sizeof(rate_values));
|
||||
memset(m_int_configs, 0, sizeof(m_int_configs));
|
||||
memset(m_bool_configs, 0, sizeof(m_bool_configs));
|
||||
@@ -414,46 +412,6 @@ bool World::RemoveQueuedPlayer(WorldSession* sess)
|
||||
return found;
|
||||
}
|
||||
|
||||
void World::LoadModuleConfigSettings()
|
||||
{
|
||||
Tokenizer configFileList(GetConfigFileList(), ',');
|
||||
for (auto i = configFileList.begin(); i != configFileList.end(); i++)
|
||||
{
|
||||
std::string configFile = (*i) + std::string(".conf");
|
||||
|
||||
std::string conf_path = _CONF_DIR;
|
||||
std::string cfg_file = conf_path + "/" + configFile;
|
||||
|
||||
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
|
||||
cfg_file = configFile;
|
||||
#endif
|
||||
std::string cfg_def_file = cfg_file + ".dist";
|
||||
|
||||
// Load .conf.dist config
|
||||
if (!sConfigMgr->LoadMore(cfg_def_file.c_str()))
|
||||
{
|
||||
sLog->outString();
|
||||
sLog->outError("Module config: Invalid or missing configuration (*.conf.dist) file : %s", cfg_def_file.c_str());
|
||||
sLog->outError("Module config: Verify that this file exists and has \'[worldserver]' written at the top of the file!");
|
||||
|
||||
// If .conf exists, it will load it so it will NOT use the default hardcoded settings
|
||||
if (!sConfigMgr->LoadMore(cfg_file.c_str()))
|
||||
{
|
||||
sLog->outError("Module config: Using default hardcoded settings.");
|
||||
}
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
// Load .conf config
|
||||
if (!sConfigMgr->LoadMore(cfg_file.c_str()))
|
||||
{
|
||||
sLog->outString();
|
||||
sLog->outString("Module config: %s not found (or invalid), using default settings from %s", cfg_file.c_str(), cfg_def_file.c_str());
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize config values
|
||||
void World::LoadConfigSettings(bool reload)
|
||||
{
|
||||
@@ -466,8 +424,6 @@ void World::LoadConfigSettings(bool reload)
|
||||
}
|
||||
}
|
||||
|
||||
LoadModuleConfigSettings();
|
||||
|
||||
#ifdef ELUNA
|
||||
///- Initialize Lua Engine
|
||||
if (!reload)
|
||||
@@ -487,6 +443,7 @@ void World::LoadConfigSettings(bool reload)
|
||||
///- Read the player limit and the Message of the day from the config file
|
||||
if (!reload)
|
||||
SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
|
||||
|
||||
Motd::SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to an AzerothCore server"));
|
||||
|
||||
///- Read ticket system setting from the config file
|
||||
|
||||
@@ -703,7 +703,6 @@ class World
|
||||
|
||||
void SetInitialWorldSettings();
|
||||
void LoadConfigSettings(bool reload = false);
|
||||
void LoadModuleConfigSettings();
|
||||
|
||||
void SendWorldText(uint32 string_id, ...);
|
||||
void SendGlobalText(const char* text, WorldSession* self);
|
||||
@@ -837,9 +836,6 @@ class World
|
||||
std::string const& GetRealmName() const { return _realmName; } // pussywizard
|
||||
void SetRealmName(std::string name) { _realmName = name; } // pussywizard
|
||||
|
||||
std::string GetConfigFileList() { return m_configFileList; }
|
||||
void SetConfigFileList(std::string list) { m_configFileList = list; }
|
||||
|
||||
protected:
|
||||
void _UpdateGameTime();
|
||||
// callback for UpdateRealmCharacters
|
||||
@@ -939,8 +935,6 @@ class World
|
||||
|
||||
void ProcessQueryCallbacks();
|
||||
ACE_Future_Set<PreparedQueryResult> m_realmCharCallbacks;
|
||||
|
||||
std::string m_configFileList;
|
||||
};
|
||||
|
||||
#define sWorld World::instance()
|
||||
|
||||
@@ -319,7 +319,6 @@ public:
|
||||
{
|
||||
sLog->outString("Re-Loading config settings...");
|
||||
sWorld->LoadConfigSettings(true);
|
||||
sWorld->LoadModuleConfigSettings();//reload modules config setting
|
||||
sMapMgr->InitializeVisibilityDistanceInfo();
|
||||
handler->SendGlobalGMSysMessage("World config settings reloaded.");
|
||||
return true;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "Master.h"
|
||||
|
||||
#ifndef _ACORE_CORE_CONFIG
|
||||
# define _ACORE_CORE_CONFIG "worldserver.conf"
|
||||
#define _ACORE_CORE_CONFIG "worldserver.conf"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -61,7 +61,7 @@ void usage(const char* prog)
|
||||
extern int main(int argc, char** argv)
|
||||
{
|
||||
///- Command line parsing to get the configuration file name
|
||||
char const* cfg_file = _ACORE_CORE_CONFIG;
|
||||
char const* configFile = _ACORE_CORE_CONFIG;
|
||||
int c = 1;
|
||||
while (c < argc)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ extern int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
cfg_file = argv[c];
|
||||
configFile = argv[c];
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -118,22 +118,12 @@ extern int main(int argc, char** argv)
|
||||
++c;
|
||||
}
|
||||
|
||||
std::string cfg_def_file=_ACORE_CORE_CONFIG;
|
||||
cfg_def_file += ".dist";
|
||||
sConfigMgr->SetConfigList(std::string(configFile), std::string(CONFIG_FILE_LIST));
|
||||
|
||||
if (!sConfigMgr->LoadInitial(cfg_def_file.c_str())) {
|
||||
printf("ERROR: Invalid or missing default configuration file : %s\n", cfg_def_file.c_str());
|
||||
if (!sConfigMgr->LoadAppConfigs())
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!sConfigMgr->LoadMore(cfg_file))
|
||||
{
|
||||
printf("WARNING: 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");
|
||||
}
|
||||
|
||||
sLog->outString("Using configuration file %s.", cfg_file);
|
||||
|
||||
sLog->outString("Using configuration file %s.", configFile);
|
||||
sLog->outString("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
sLog->outString("Using ACE version: %s", ACE_VERSION);
|
||||
|
||||
|
||||
@@ -156,8 +156,8 @@ int Master::Run()
|
||||
// set server offline (not connectable)
|
||||
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = (flag & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID);
|
||||
|
||||
//set module config file list
|
||||
sWorld->SetConfigFileList(CONFIG_FILE_LIST);
|
||||
// Loading modules configs
|
||||
sConfigMgr->LoadModulesConfigs();
|
||||
|
||||
///- Initialize the World
|
||||
sWorld->SetInitialWorldSettings();
|
||||
|
||||
Reference in New Issue
Block a user