diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-12-01 19:53:13 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-12-02 15:57:09 +0100 |
commit | eb50b29ab3d95c713bdc5cb508ec06a69704921d (patch) | |
tree | 48d50f659a2015e01af0d4c6556c43e8f6ba5544 /src/common/Utilities/Util.cpp | |
parent | e2b26f2038e40760a0f46ae587af9ec985d041eb (diff) |
Core/Misc: Added windows version checks during startup to avoid confusion about crashes when running on unsupported OS
(cherry picked from commit 333630b7de15c4090392fcbbc1bc58da4d5fb138)
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 8ca639ba6a4..9f9762980b5 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -31,11 +31,27 @@ #include <ctime> #include <boost/core/demangle.hpp> -#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) { |