aboutsummaryrefslogtreecommitdiff
path: root/src/common/Utilities
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-12-01 19:53:13 +0100
committerShauren <shauren.trinity@gmail.com>2023-12-01 19:53:13 +0100
commit333630b7de15c4090392fcbbc1bc58da4d5fb138 (patch)
treefc40b0467ea09379a8f18059ebc029ea0a18c38a /src/common/Utilities
parent8d6578b58025e71f88297cb2b6d222251b4bbe75 (diff)
Core/Misc: Added windows version checks during startup to avoid confusion about crashes when running on unsupported OS
Diffstat (limited to 'src/common/Utilities')
-rw-r--r--src/common/Utilities/Util.cpp24
-rw-r--r--src/common/Utilities/Util.h2
2 files changed, 22 insertions, 4 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index d852ed655a0..5fb34c59948 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -31,11 +31,27 @@
#include <cstdarg>
#include <ctime>
-#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
+void Trinity::VerifyOsVersion()
+{
+#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
+ auto isWindowsBuildGreaterOrEqual = [](DWORD build)
+ {
+ OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, build, 0, {0}, 0, 0, 0, 0 };
+ ULONGLONG conditionMask = 0;
+ VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
+
+ return VerifyVersionInfo(&osvi, VER_BUILDNUMBER, conditionMask);
+ };
+
+ if (!isWindowsBuildGreaterOrEqual(TRINITY_REQUIRED_WINDOWS_BUILD))
+ {
+ OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, {0}, 0, 0, 0, 0 };
+ GetVersionEx((LPOSVERSIONINFO)&osvi);
+ ABORT_MSG("TrinityCore requires Windows 10 19H1 (1903) or Windows Server 2019 (1903) - require build number 10.0.%d but found %d.%d.%d",
+ TRINITY_REQUIRED_WINDOWS_BUILD, osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber);
+ }
#endif
+}
std::vector<std::string_view> Trinity::Tokenize(std::string_view str, char sep, bool keepEmpty)
{
diff --git a/src/common/Utilities/Util.h b/src/common/Utilities/Util.h
index 334b3ab6ac0..e847eaab24a 100644
--- a/src/common/Utilities/Util.h
+++ b/src/common/Utilities/Util.h
@@ -40,6 +40,8 @@ enum class TimeFormat : uint8
namespace Trinity
{
+ TC_COMMON_API void VerifyOsVersion();
+
TC_COMMON_API std::vector<std::string_view> Tokenize(std::string_view str, char sep, bool keepEmpty);
/* this would return string_view into temporary otherwise */