mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335)
(cherry picked from commit cd30e0b86c)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
#include "StringConvert.h"
|
||||
#include "Util.h"
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
#include <algorithm>
|
||||
@@ -137,7 +138,15 @@ bool ConfigMgr::GetBoolDefault(std::string const& name, bool def, bool quiet) co
|
||||
{
|
||||
std::string val = GetValueDefault(name, std::string(def ? "1" : "0"), quiet);
|
||||
val.erase(std::remove(val.begin(), val.end(), '"'), val.end());
|
||||
return StringToBool(val);
|
||||
Optional<bool> boolVal = Trinity::StringTo<bool>(val);
|
||||
if (boolVal)
|
||||
return *boolVal;
|
||||
else
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "Bad value defined for name %s in config file %s, going to use '%s' instead",
|
||||
name.c_str(), _filename.c_str(), def ? "true" : "false");
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
int32 ConfigMgr::GetIntDefault(std::string const& name, int32 def, bool quiet) const
|
||||
|
||||
Reference in New Issue
Block a user