From 11c4a60fbe9d471618e0579f588706746ff3e439 Mon Sep 17 00:00:00 2001 From: Treeston Date: Mon, 24 Aug 2020 16:17:56 +0200 Subject: [3.3.5] Core/ChatCommands: C++17 cleanup (if constexpr + std::string_view) --- src/common/Configuration/Config.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/common/Configuration/Config.cpp') diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index fa0e546ccc3..d9af7ae1187 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -137,7 +137,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 boolVal = StringToBool(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; + } } int ConfigMgr::GetIntDefault(std::string const& name, int def, bool quiet) const -- cgit v1.2.3