From f46f5590ff222013c64fd12e8af03562aa466e5d Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 6 Nov 2016 14:26:03 +0100 Subject: [PATCH] Fuck those unit-tests on wine. --- src/Components/Modules/News.cpp | 39 ++++++++++++++++++--------------- src/Utils/Utils.cpp | 7 ++++++ src/Utils/Utils.hpp | 2 ++ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index f36dcbfc..d8a81c27 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -157,32 +157,35 @@ namespace Components }).detach(); }); - News::Terminate = false; - News::Thread = std::thread([] () + if (!Utils::IsWineEnvironment()) { - Localization::Set("MPUI_CHANGELOG_TEXT", Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/changelog.txt").SetTimeout(5000)->Get()); - - std::string data = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/motd.txt").SetTimeout(5000)->Get(); - - if (!data.empty()) + News::Terminate = false; + News::Thread = std::thread([] () { - Localization::Set("MPUI_MOTD_TEXT", data); - } + Localization::Set("MPUI_CHANGELOG_TEXT", Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/changelog.txt").SetTimeout(5000)->Get()); - if (!Loader::PerformingUnitTests()) - { - while (!News::Terminate) + std::string data = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/motd.txt").SetTimeout(5000)->Get(); + + if (!data.empty()) { - News::CheckForUpdate(); + Localization::Set("MPUI_MOTD_TEXT", data); + } - // Sleep for 3 minutes - for (int i = 0; i < 180 && !News::Terminate; ++i) + if (!Loader::PerformingUnitTests()) + { + while (!News::Terminate) { - std::this_thread::sleep_for(1s); + News::CheckForUpdate(); + + // Sleep for 3 minutes + for (int i = 0; i < 180 && !News::Terminate; ++i) + { + std::this_thread::sleep_for(1s); + } } } - } - }); + }); + } } News::~News() diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index f35d1e79..a0262043 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -35,4 +35,11 @@ namespace Utils LocalFree(messageBuffer); } + + bool IsWineEnvironment() + { + HMODULE hntdll = GetModuleHandleA("ntdll.dll"); + if (!hntdll) return false; + return (GetProcAddress(hntdll, "wine_get_version") != nullptr); + } } diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index 399b34d7..b05856a8 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -4,6 +4,8 @@ namespace Utils std::string ParseChallenge(std::string data); void OutputDebugLastError(); + bool IsWineEnvironment(); + template void Merge(std::vector* target, T* source, size_t length) { if (source)