From 6372e6214b24074621071b709e26ddaa0f7d6536 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Sat, 26 Feb 2022 20:12:05 +0100 Subject: [PATCH] Fix connecting + scheduler mp addresses --- src/client/component/auth.cpp | 3 ++ src/client/component/patches.cpp | 6 ++-- src/client/component/scheduler.cpp | 50 +++++++++++++++--------------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index 0f0484c8..ceb96188 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -225,6 +225,9 @@ namespace auth utils::hook::jump(0x140488BC1, get_direct_connect_stub(), true); // H1(1.4) utils::hook::call(0x140250ED2, send_connect_data_stub); // H1(1.4) + + // Check for sending connect packet + utils::hook::set(0x14059A6E0, 0xC301B0); } command::add("guid", []() diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index 8555004d..29045d23 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -174,9 +174,9 @@ namespace patches // Fix mouse lag utils::hook::nop(SELECT_VALUE(0x1403E3C05, 0x1404DB1AF), 6); scheduler::loop([]() - { - SetThreadExecutionState(ES_DISPLAY_REQUIRED); - }, scheduler::pipeline::main); + { + SetThreadExecutionState(ES_DISPLAY_REQUIRED); + }, scheduler::pipeline::main); // Prevent game from overriding cg_fov and cg_fovscale values gscr_set_save_dvar_hook.create(SELECT_VALUE(0x1402AE020, 0x14036B600), &gscr_set_save_dvar_stub); diff --git a/src/client/component/scheduler.cpp b/src/client/component/scheduler.cpp index a6d742d5..5fe843cc 100644 --- a/src/client/component/scheduler.cpp +++ b/src/client/component/scheduler.cpp @@ -36,33 +36,33 @@ namespace scheduler void execute() { callbacks_.access([&](task_list& tasks) + { + this->merge_callbacks(); + + for (auto i = tasks.begin(); i != tasks.end();) { - this->merge_callbacks(); + const auto now = std::chrono::high_resolution_clock::now(); + const auto diff = now - i->last_call; - for (auto i = tasks.begin(); i != tasks.end();) + if (diff < i->interval) { - const auto now = std::chrono::high_resolution_clock::now(); - const auto diff = now - i->last_call; - - if (diff < i->interval) - { - ++i; - continue; - } - - i->last_call = now; - - const auto res = i->handler(); - if (res == cond_end) - { - i = tasks.erase(i); - } - else - { - ++i; - } + ++i; + continue; } - }); + + i->last_call = now; + + const auto res = i->handler(); + if (res == cond_end) + { + i = tasks.erase(i); + } + else + { + ++i; + } + } + }); } private: @@ -181,8 +181,8 @@ namespace scheduler void post_unpack() override { r_end_frame_hook.create(SELECT_VALUE(0x1404F7310, 0x1405FE470), scheduler::r_end_frame_stub); // H1(1.4) - g_run_frame_hook.create(SELECT_VALUE(0x1402772D0, 0x1402772D0), scheduler::server_frame_stub); // H1(1.4) - main_frame_hook.create(SELECT_VALUE(0x1401CE8D0, 0x1401CE8D0), scheduler::main_frame_stub); // H1(1.4) + g_run_frame_hook.create(SELECT_VALUE(0x1402772D0, 0x14033A640), scheduler::server_frame_stub); // H1(1.4) + main_frame_hook.create(SELECT_VALUE(0x1401CE8D0, 0x1400D82A0), scheduler::main_frame_stub); // H1(1.4) } void pre_destroy() override