aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Configuration/Config.cpp10
-rw-r--r--src/common/Utilities/Util.cpp8
-rw-r--r--src/common/Utilities/Util.h3
3 files changed, 4 insertions, 17 deletions
diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp
index d9af7ae1187..fa0e546ccc3 100644
--- a/src/common/Configuration/Config.cpp
+++ b/src/common/Configuration/Config.cpp
@@ -137,15 +137,7 @@ 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());
- Optional<bool> 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;
- }
+ return StringToBool(val);
}
int ConfigMgr::GetIntDefault(std::string const& name, int def, bool quiet) const
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index cb70cc114d3..da086c6b6cc 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -651,13 +651,9 @@ void Trinity::Impl::HexStrToByteArray(std::string_view str, uint8* out, size_t o
}
}
-Optional<bool> StringToBool(std::string_view str)
+bool StringToBool(std::string_view str)
{
- if (str == "1" || StringEqualI(str, "y") || StringEqualI(str, "on") || StringEqualI(str, "yes") || StringEqualI(str, "true"))
- return true;
- if (str == "0" || StringEqualI(str, "n") || StringEqualI(str, "off") || StringEqualI(str, "no") || StringEqualI(str, "false"))
- return false;
- return std::nullopt;
+ return ((str == "1") || StringEqualI(str, "true") || StringEqualI(str, "yes"));
}
bool StringEqualI(std::string_view str1, std::string_view str2)
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 8c97f99fe63..cd8765b309f 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -20,7 +20,6 @@
#include "Define.h"
#include "Errors.h"
-#include "Optional.h"
#include <array>
#include <string>
@@ -346,7 +345,7 @@ inline std::vector<uint8> HexStrToByteVector(std::string_view str, bool reverse
return buf;
}
-TC_COMMON_API Optional<bool> StringToBool(std::string_view str);
+TC_COMMON_API bool StringToBool(std::string_view str);
TC_COMMON_API bool StringEqualI(std::string_view str1, std::string_view str2);
TC_COMMON_API bool StringStartsWith(std::string_view haystack, std::string_view needle);