[Scheduler] Fix startup

This commit is contained in:
momo5502 2017-07-03 15:40:32 +02:00
parent c68ac46d10
commit 41a85262f5
11 changed files with 18 additions and 18 deletions

View File

@ -112,7 +112,7 @@ namespace Components
for (auto component : Loader::Components) for (auto component : Loader::Components)
{ {
#ifdef DEBUG #ifdef DEBUG
if (!Loader::PerformingUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
Logger::Print("Unregistering component: %s\n", component->getName().data()); Logger::Print("Unregistering component: %s\n", component->getName().data());
} }
@ -178,7 +178,7 @@ namespace Components
return result; return result;
} }
bool Loader::PerformingUnitTests() bool Loader::IsPerformingUnitTests()
{ {
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) #if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
return Flags::HasFlag("tests"); return Flags::HasFlag("tests");
@ -192,7 +192,7 @@ namespace Components
if (component) if (component)
{ {
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) #if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
if (!Loader::PerformingUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
Logger::Print("Component registered: %s\n", component->getName().data()); Logger::Print("Component registered: %s\n", component->getName().data());
} }

View File

@ -32,7 +32,7 @@ namespace Components
static void PreDestroy(); static void PreDestroy();
static void PreDestroyNoPostGame(); static void PreDestroyNoPostGame();
static bool PerformUnitTests(); static bool PerformUnitTests();
static bool PerformingUnitTests(); static bool IsPerformingUnitTests();
static void Register(Component* component); static void Register(Component* component);
static bool IsPregame(); static bool IsPregame();

View File

@ -491,7 +491,7 @@ namespace Components
void Console::FreeNativeConsole() void Console::FreeNativeConsole()
{ {
if (!Monitor::IsEnabled() && !Flags::HasFlag("stdout") && (!Dedicated::IsEnabled() || Flags::HasFlag("console")) && !Loader::PerformingUnitTests()) if (!Monitor::IsEnabled() && !Flags::HasFlag("stdout") && (!Dedicated::IsEnabled() || Flags::HasFlag("console")) && !Loader::IsPerformingUnitTests())
{ {
FreeConsole(); FreeConsole();
} }
@ -583,7 +583,7 @@ namespace Components
} }
// Code below is not necessary when performing unit tests! // Code below is not necessary when performing unit tests!
if (Loader::PerformingUnitTests()) return; if (Loader::IsPerformingUnitTests()) return;
// External console // External console
if (Flags::HasFlag("stdout") || Monitor::IsEnabled()) if (Flags::HasFlag("stdout") || Monitor::IsEnabled())
@ -643,7 +643,7 @@ namespace Components
Utils::Hook(0x43D570, Console::Error, HOOK_JUMP).install()->quick(); Utils::Hook(0x43D570, Console::Error, HOOK_JUMP).install()->quick();
Utils::Hook(0x4859A5, Console::Input, HOOK_CALL).install()->quick(); Utils::Hook(0x4859A5, Console::Input, HOOK_CALL).install()->quick();
} }
else if(!Loader::PerformingUnitTests()) else if(!Loader::IsPerformingUnitTests())
{ {
FreeConsole(); FreeConsole();
} }

View File

@ -63,7 +63,7 @@ namespace Components
if (INVALID_HANDLE_VALUE != this->pipe && this->pipe) if (INVALID_HANDLE_VALUE != this->pipe && this->pipe)
{ {
// Only create the thread, when not performing unit tests! // Only create the thread, when not performing unit tests!
if (!Loader::PerformingUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
this->threadAttached = true; this->threadAttached = true;
this->thread = std::thread(Pipe::ReceiveThread, this); this->thread = std::thread(Pipe::ReceiveThread, this);
@ -204,7 +204,7 @@ namespace Components
IPCPipe::IPCPipe() IPCPipe::IPCPipe()
{ {
if (Dedicated::IsEnabled() || Monitor::IsEnabled() || Loader::PerformingUnitTests() || ZoneBuilder::IsEnabled()) return; if (Dedicated::IsEnabled() || Monitor::IsEnabled() || Loader::IsPerformingUnitTests() || ZoneBuilder::IsEnabled()) return;
// Server pipe // Server pipe
IPCPipe::ServerPipe.onConnect(IPCPipe::ConnectClient); IPCPipe::ServerPipe.onConnect(IPCPipe::ConnectClient);

View File

@ -287,7 +287,7 @@ namespace Components
}); });
// #ifndef DISABLE_ANTICHEAT // #ifndef DISABLE_ANTICHEAT
// if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && !Utils::IsWineEnvironment() && !Loader::PerformingUnitTests()) // if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && !Utils::IsWineEnvironment() && !Loader::IsPerformingUnitTests())
// { // {
// AntiCheat::PatchVirtualProtect(VirtualProtect, VirtualProtectEx); // AntiCheat::PatchVirtualProtect(VirtualProtect, VirtualProtectEx);
// } // }

View File

@ -29,7 +29,7 @@ namespace Components
void Logger::MessagePrint(int channel, std::string message) void Logger::MessagePrint(int channel, std::string message)
{ {
if (Flags::HasFlag("stdout") || Loader::PerformingUnitTests()) if (Flags::HasFlag("stdout") || Loader::IsPerformingUnitTests())
{ {
printf("%s", message.data()); printf("%s", message.data());
fflush(stdout); fflush(stdout);
@ -252,7 +252,7 @@ namespace Components
Utils::Hook(0x4B0218, Logger::GameLogStub, HOOK_CALL).install()->quick(); Utils::Hook(0x4B0218, Logger::GameLogStub, HOOK_CALL).install()->quick();
Utils::Hook(Game::Com_PrintMessage, Logger::PrintMessageStub, HOOK_JUMP).install()->quick(); Utils::Hook(Game::Com_PrintMessage, Logger::PrintMessageStub, HOOK_JUMP).install()->quick();
if (Loader::PerformingUnitTests()) if (Loader::IsPerformingUnitTests())
{ {
Utils::Hook(Game::Com_Printf, Logger::PrintStub, HOOK_JUMP).install()->quick(); Utils::Hook(Game::Com_Printf, Logger::PrintStub, HOOK_JUMP).install()->quick();
} }

View File

@ -235,7 +235,7 @@ namespace Components
News::LaunchUpdater("-update -c"); News::LaunchUpdater("-update -c");
}); });
if (!Utils::IsWineEnvironment() && !Loader::PerformingUnitTests()) if (!Utils::IsWineEnvironment() && !Loader::IsPerformingUnitTests())
{ {
News::Terminate = false; News::Terminate = false;
News::Thread = std::thread([]() News::Thread = std::thread([]()
@ -249,7 +249,7 @@ namespace Components
Localization::Set("MPUI_MOTD_TEXT", data); Localization::Set("MPUI_MOTD_TEXT", data);
} }
if (!Loader::PerformingUnitTests() && !News::Terminate) if (!Loader::IsPerformingUnitTests() && !News::Terminate)
{ {
News::GetLatestUpdater(); News::GetLatestUpdater();

View File

@ -117,7 +117,7 @@ namespace Components
Utils::Hook(0x4D697A, Scheduler::ShutdownStub, HOOK_CALL).install()->quick(); Utils::Hook(0x4D697A, Scheduler::ShutdownStub, HOOK_CALL).install()->quick();
if (!Loader::PerformUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
Scheduler::AsyncTerminate = false; Scheduler::AsyncTerminate = false;
Scheduler::AsyncThread = std::thread([]() Scheduler::AsyncThread = std::thread([]()

View File

@ -117,7 +117,7 @@ namespace Components
Session::SignatureKey = Utils::Cryptography::ECC::GenerateKey(512); Session::SignatureKey = Utils::Cryptography::ECC::GenerateKey(512);
//Scheduler::OnFrame(Session::RunFrame); //Scheduler::OnFrame(Session::RunFrame);
if (!Loader::PerformingUnitTests()) if (!Loader::IsPerformingUnitTests())
{ {
Session::Terminate = false; Session::Terminate = false;
Session::Thread = std::thread([]() Session::Thread = std::thread([]()

View File

@ -20,7 +20,7 @@ namespace Components
Console::FreeNativeConsole(); Console::FreeNativeConsole();
if (Loader::PerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return; if (Loader::IsPerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return;
Singleton::FirstInstance = (CreateMutexA(nullptr, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS); Singleton::FirstInstance = (CreateMutexA(nullptr, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS);

View File

@ -9,7 +9,7 @@ namespace Main
Components::Loader::Initialize(); Components::Loader::Initialize();
#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) #if defined(DEBUG) || defined(FORCE_UNIT_TESTS)
if (Components::Loader::PerformingUnitTests()) if (Components::Loader::IsPerformingUnitTests())
{ {
DWORD result = (Components::Loader::PerformUnitTests() ? 0 : -1); DWORD result = (Components::Loader::PerformUnitTests() ? 0 : -1);
Components::Loader::Uninitialize(); Components::Loader::Uninitialize();