Fuck those unit-tests on wine.

This commit is contained in:
momo5502 2016-11-06 14:26:03 +01:00
parent 5710f30376
commit f46f5590ff
3 changed files with 30 additions and 18 deletions

View File

@ -157,32 +157,35 @@ namespace Components
}).detach(); }).detach();
}); });
News::Terminate = false; if (!Utils::IsWineEnvironment())
News::Thread = std::thread([] ()
{ {
Localization::Set("MPUI_CHANGELOG_TEXT", Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/changelog.txt").SetTimeout(5000)->Get()); News::Terminate = false;
News::Thread = std::thread([] ()
std::string data = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/motd.txt").SetTimeout(5000)->Get();
if (!data.empty())
{ {
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()) std::string data = Utils::WebIO("IW4x", "https://iw4xcachep26muba.onion.to/iw4/motd.txt").SetTimeout(5000)->Get();
{
while (!News::Terminate) if (!data.empty())
{ {
News::CheckForUpdate(); Localization::Set("MPUI_MOTD_TEXT", data);
}
// Sleep for 3 minutes if (!Loader::PerformingUnitTests())
for (int i = 0; i < 180 && !News::Terminate; ++i) {
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() News::~News()

View File

@ -35,4 +35,11 @@ namespace Utils
LocalFree(messageBuffer); LocalFree(messageBuffer);
} }
bool IsWineEnvironment()
{
HMODULE hntdll = GetModuleHandleA("ntdll.dll");
if (!hntdll) return false;
return (GetProcAddress(hntdll, "wine_get_version") != nullptr);
}
} }

View File

@ -4,6 +4,8 @@ namespace Utils
std::string ParseChallenge(std::string data); std::string ParseChallenge(std::string data);
void OutputDebugLastError(); void OutputDebugLastError();
bool IsWineEnvironment();
template <typename T> void Merge(std::vector<T>* target, T* source, size_t length) template <typename T> void Merge(std::vector<T>* target, T* source, size_t length)
{ {
if (source) if (source)