mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 01:08:35 +00:00
refactor(Core/Misc): add braces and impove codestyle (#6402)
This commit is contained in:
@@ -153,7 +153,9 @@ namespace
|
||||
|
||||
// No lines read
|
||||
if (!count)
|
||||
{
|
||||
throw ConfigException(Acore::StringFormat("Config::LoadFile: Empty file '%s'", file.c_str()));
|
||||
}
|
||||
|
||||
// Add correct keys if file load without errors
|
||||
for (auto const& [entry, key] : fileConfigs)
|
||||
@@ -200,7 +202,9 @@ ConfigMgr* ConfigMgr::instance()
|
||||
bool ConfigMgr::Reload()
|
||||
{
|
||||
if (!LoadAppConfigs())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return LoadModulesConfigs();
|
||||
}
|
||||
@@ -287,7 +291,9 @@ std::vector<std::string> ConfigMgr::GetKeysByString(std::string const& name)
|
||||
|
||||
for (auto const& [optionName, key] : _configOptions)
|
||||
if (!optionName.compare(0, name.length(), name))
|
||||
{
|
||||
keys.emplace_back(optionName);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
@@ -324,7 +330,9 @@ void ConfigMgr::Configure(std::string const& initFileName, std::vector<std::stri
|
||||
{
|
||||
Tokenizer configFileList(modulesConfigList, ',');
|
||||
for (auto const& itr : configFileList)
|
||||
{
|
||||
_additonalFiles.emplace_back(std::string(itr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,11 +340,15 @@ bool ConfigMgr::LoadAppConfigs()
|
||||
{
|
||||
// #1 - Load init config file .conf.dist
|
||||
if (!LoadInitial(_filename + ".dist"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// #2 - Load .conf file
|
||||
if (!LoadAdditionalFile(_filename))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -344,7 +356,9 @@ bool ConfigMgr::LoadAppConfigs()
|
||||
bool ConfigMgr::LoadModulesConfigs()
|
||||
{
|
||||
if (_additonalFiles.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Start loading module configs
|
||||
std::string const& moduleConfigPath = GetConfigPath() + "modules/";
|
||||
@@ -356,20 +370,30 @@ bool ConfigMgr::LoadModulesConfigs()
|
||||
std::string defaultFileName = distFileName;
|
||||
|
||||
if (!defaultFileName.empty())
|
||||
{
|
||||
defaultFileName.erase(defaultFileName.end() - 5, defaultFileName.end());
|
||||
}
|
||||
|
||||
// Load .conf.dist config
|
||||
if (!LoadAdditionalFile(moduleConfigPath + distFileName))
|
||||
{
|
||||
isExistDistConfig = false;
|
||||
}
|
||||
|
||||
// Load .conf config
|
||||
if (!LoadAdditionalFile(moduleConfigPath + defaultFileName))
|
||||
{
|
||||
isExistDefaultConfig = false;
|
||||
}
|
||||
|
||||
if (isExistDefaultConfig && isExistDistConfig)
|
||||
{
|
||||
_moduleConfigFiles.emplace_back(defaultFileName);
|
||||
}
|
||||
else if (!isExistDefaultConfig && isExistDistConfig)
|
||||
{
|
||||
_moduleConfigFiles.emplace_back(distFileName);
|
||||
}
|
||||
}
|
||||
|
||||
// If module configs not exist - no load
|
||||
@@ -383,7 +407,9 @@ void ConfigMgr::PrintLoadedModulesConfigs()
|
||||
LOG_INFO("server.loading", "Using modules configuration:");
|
||||
|
||||
for (auto const& itr : _moduleConfigFiles)
|
||||
{
|
||||
LOG_INFO("server.loading", "> %s", itr.c_str());
|
||||
}
|
||||
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user