diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-12-01 19:53:13 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-12-01 19:53:13 +0100 |
commit | 333630b7de15c4090392fcbbc1bc58da4d5fb138 (patch) | |
tree | fc40b0467ea09379a8f18059ebc029ea0a18c38a /src/common/Utilities/Util.cpp | |
parent | 8d6578b58025e71f88297cb2b6d222251b4bbe75 (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/Util.cpp')
-rw-r--r-- | src/common/Utilities/Util.cpp | 24 |
1 files changed, 20 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) { |