From c29d9e5806ad9db8e04484e2159358b63f5a0ba1 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Wed, 12 Apr 2023 18:43:16 +0200 Subject: [PATCH] Dispatch connect packet in the server thread --- src/client/component/auth.cpp | 5 ++++- src/client/component/scheduler.cpp | 11 ++++++----- src/client/game/symbols.hpp | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index 57346b8f..ef9f773c 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -196,7 +196,10 @@ namespace auth std::string final_packet{}; if (game::fragment_handler::handle(target, buffer, final_packet)) { - dispatch_connect_packet(target, final_packet); + scheduler::once([t = target, p = std::move(final_packet)] + { + dispatch_connect_packet(t, p); + }); } } } diff --git a/src/client/component/scheduler.cpp b/src/client/component/scheduler.cpp index d4ac94b8..a115b1d9 100644 --- a/src/client/component/scheduler.cpp +++ b/src/client/component/scheduler.cpp @@ -88,7 +88,6 @@ namespace scheduler task_pipeline pipelines[pipeline::count]; utils::hook::detour r_end_frame_hook; - utils::hook::detour g_run_frame_hook; utils::hook::detour main_frame_hook; @@ -98,9 +97,9 @@ namespace scheduler r_end_frame_hook.invoke(); } - void server_frame_stub() + void g_clear_vehicle_inputs_stub() { - g_run_frame_hook.invoke(); + game::G_ClearVehicleInputs(); execute(pipeline::server); } @@ -168,12 +167,14 @@ namespace scheduler { if (!game::is_server()) { - r_end_frame_hook.create(0x142272B00_g, r_end_frame_stub); // some func called before R_EndFrame, maybe SND_EndFrame? + r_end_frame_hook.create(0x142272B00_g, r_end_frame_stub); } - main_frame_hook.create(game::select(0x1420F8E00, 0x1405020E0), main_frame_stub); // Com_Frame_Try_Block_Function + main_frame_hook.create(game::select(0x1420F8E00, 0x1405020E0), main_frame_stub); + + utils::hook::call(game::select(0x14225522E, 0x140538427), g_clear_vehicle_inputs_stub); } void pre_destroy() override diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 8109ed95..3165a4b5 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -75,6 +75,9 @@ namespace game WEAK symbol DB_FileExists{0x141420B40}; WEAK symbol DB_ReleaseXAssets{0x1414247C0}; + // G + WEAK symbol G_ClearVehicleInputs{0x1423812E0, 0x1405C1200}; + // Live WEAK symbol Live_GetConnectivityInformation{0x141E0C380};