diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index a570a6fd..1a931fbe 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -213,7 +213,7 @@ namespace Components }); // Invocation handler - QuickPatch::OnReady(ConnectProtocol::Invocation); + Scheduler::OnReady(ConnectProtocol::Invocation); ConnectProtocol::InstallProtocol(); ConnectProtocol::EvaluateProtocol(); diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 1a7bbeac..7a86af52 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -572,7 +572,7 @@ namespace Components if (Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) { - Dedicated::OnFrame(Console::RefreshStatus); + Scheduler::OnFrame(Console::RefreshStatus); } // Code below is not necessary when performing unit tests! diff --git a/src/Components/Modules/Dedicated.cpp b/src/Components/Modules/Dedicated.cpp index c9052e7c..c8fa2471 100644 --- a/src/Components/Modules/Dedicated.cpp +++ b/src/Components/Modules/Dedicated.cpp @@ -380,7 +380,7 @@ namespace Components Utils::Hook(0x60BFBF, Dedicated::PostInitializationStub, HOOK_JUMP).install()->quick(); // Transmit custom data - Dedicated::OnFrame([]() + Scheduler::OnFrame([]() { static std::uint64_t LastUpdate = 0; @@ -396,7 +396,7 @@ namespace Components #ifdef USE_LEGACY_SERVER_LIST // Heartbeats - Dedicated::OnFrame([] () + Scheduler::OnFrame([] () { static int LastHeartbeat = 0; diff --git a/src/Components/Modules/Dvar.cpp b/src/Components/Modules/Dvar.cpp index 8ffde0fc..8b585623 100644 --- a/src/Components/Modules/Dvar.cpp +++ b/src/Components/Modules/Dvar.cpp @@ -142,7 +142,7 @@ namespace Components Dvar::RegistrationSignal(); // Name watcher - Renderer::OnFrame([] () + Scheduler::OnFrame([] () { static std::string lastValidName = "Unknown Soldier"; std::string name = Dvar::Var("name").get(); diff --git a/src/Components/Modules/Friends.cpp b/src/Components/Modules/Friends.cpp index 84576cf2..2bd98479 100644 --- a/src/Components/Modules/Friends.cpp +++ b/src/Components/Modules/Friends.cpp @@ -640,7 +640,7 @@ namespace Components UIFeeder::Add(61.0f, Friends::GetFriendCount, Friends::GetFriendText, Friends::SelectFriend); - QuickPatch::OnShutdown([]() + Scheduler::OnShutdown([]() { Friends::ClearPresence("iw4x_server"); Friends::ClearPresence("iw4x_playing"); diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index 3f140a01..664393b3 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -1003,7 +1003,7 @@ namespace Components Command::Add("delayReconnect", [](Command::Params*) { - Renderer::OnDelay([]() + Scheduler::OnDelay([]() { Command::Execute("closemenu popup_reconnectingtoparty", false); Command::Execute("reconnect", false); @@ -1077,7 +1077,7 @@ namespace Components // Allow hiding specific smodels Utils::Hook(0x50E67C, Maps::HideModelStub, HOOK_CALL).install()->quick(); - Renderer::OnFrame([]() + Scheduler::OnFrame([]() { Game::GfxWorld*& gameWorld = *reinterpret_cast(0x66DEE94); if (!Game::CL_IsCgameInitialized() || !gameWorld || !Dvar::Var("r_listSModels").get()) return; diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index bcd7e145..e18efc4f 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -405,7 +405,7 @@ namespace Components // Send deadline when shutting down if (Dedicated::IsEnabled()) { - QuickPatch::OnShutdown([] () + Scheduler::OnShutdown([] () { if (Dvar::Var("sv_lanOnly").get()) return; diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index bafa7959..5fc8252f 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -271,7 +271,7 @@ namespace Components Party::Connect(Party::Container.target); }); - Renderer::OnFrame([] () + Scheduler::OnFrame([] () { if (Party::Container.valid) { diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 3643389b..050dbe57 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -334,8 +334,6 @@ namespace Components Utils::Hook::Set(0x60B279, CLIENT_CONFIG); Utils::Hook::Set(0x60BBD4, CLIENT_CONFIG); - Utils::Hook(0x4D697A, QuickPatch::ShutdownStub, HOOK_CALL).install()->quick(); - // Disable profile system // Utils::Hook::Nop(0x60BEB1, 5); // GamerProfile_InitAllProfiles - Causes an error, when calling a harrier killstreak. // Utils::Hook::Nop(0x60BEB8, 5); // GamerProfile_LogInProfile @@ -657,7 +655,7 @@ namespace Components // Constantly draw the mini console Utils::Hook::Set(0x412A45, 0xEB); - Renderer::OnFrame([] () + Scheduler::OnFrame([] () { if (*reinterpret_cast(0x62E4BAC)) { diff --git a/src/Components/Modules/Scheduler.cpp b/src/Components/Modules/Scheduler.cpp index 9626fed8..1a7e2793 100644 --- a/src/Components/Modules/Scheduler.cpp +++ b/src/Components/Modules/Scheduler.cpp @@ -15,14 +15,28 @@ namespace Components Scheduler::FrameOnceSignal.connect(callback); } + void Scheduler::OnShutdown(Utils::Slot callback) + { + Scheduler::ShutdownSignal.connect(callback); + } + void Scheduler::OnFrame(Utils::Slot callback) { Scheduler::FrameSignal.connect(callback); } + void Scheduler::OnReady(Utils::Slot callback) + { + if (Scheduler::ReadyPassed) Scheduler::Once(callback); + else Scheduler::ReadySignal.connect(callback); + } + void Scheduler::ReadyHandler() { - if (!FastFiles::Ready()) Scheduler::Once(Scheduler::ReadyHandler); + if (!FastFiles::Ready()) + { + Scheduler::Once(Scheduler::ReadyHandler); + } else { Scheduler::ReadyPassed = true; @@ -69,15 +83,30 @@ namespace Components signal(); } + void Scheduler::ShutdownStub(int num) + { + Scheduler::ShutdownSignal(); + Utils::Hook::Call(0x46B370)(num); + } + + Scheduler::Scheduler() { Scheduler::ReadyPassed = false; Scheduler::Once(Scheduler::ReadyHandler); + + Utils::Hook(0x4D697A, Scheduler::ShutdownStub, HOOK_CALL).install()->quick(); } Scheduler::~Scheduler() { - Scheduler::FrameOnceSignal.clear(); + Scheduler::ReadySignal.clear(); + Scheduler::ShutdownSignal.clear(); + Scheduler::FrameSignal.clear(); + Scheduler::FrameOnceSignal.clear(); + Scheduler::DelayedSlots.clear(); + + Scheduler::ReadyPassed = false; } } diff --git a/src/Components/Modules/Scheduler.hpp b/src/Components/Modules/Scheduler.hpp index 475d8f68..dbf363ae 100644 --- a/src/Components/Modules/Scheduler.hpp +++ b/src/Components/Modules/Scheduler.hpp @@ -37,5 +37,7 @@ namespace Components static void ReadyHandler(); static void DelaySignal(); + + static void ShutdownStub(int num); }; } diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index 6c3c6b64..cbfe1f41 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -853,7 +853,7 @@ namespace Components // This is placed here in case the anticheat has been disabled! #if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) && defined(PROCTECT_PROCESS) - Scheduler::OnFrame(AntiCheat::ReadIntegrityCheck); + if(!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled()) Scheduler::OnFrame(AntiCheat::ReadIntegrityCheck); #endif } diff --git a/src/Components/Modules/Toast.cpp b/src/Components/Modules/Toast.cpp index d38c1ab4..b544bcb0 100644 --- a/src/Components/Modules/Toast.cpp +++ b/src/Components/Modules/Toast.cpp @@ -157,7 +157,7 @@ namespace Components WinToastLib::WinToast::instance()->initialize(); } - QuickPatch::OnReady([]() + Scheduler::OnReady([]() { Scheduler::OnFrame(Toast::Handler); });