From 212d9a58b6c9b24a61cfeae7c3dc81a4f3dfeab5 Mon Sep 17 00:00:00 2001 From: quaK <38787176+Joelrau@users.noreply.github.com> Date: Sun, 21 Mar 2021 15:24:17 +0200 Subject: [PATCH] Minor fixes - fixes /map command on the same map disconnecting - fixes disconnect with virtuallobby on --- src/client/component/party.cpp | 53 +++++++++++++++------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp index 335cc72..320913e 100644 --- a/src/client/component/party.cpp +++ b/src/client/component/party.cpp @@ -208,17 +208,6 @@ namespace party return; } - if (!game::environment::is_dedi()) - { - if(game::SV_Loaded()) - { - const auto* args = "Leave"; - game::UI_RunMenuScript(0, &args); - } - - perform_game_initialization(); - } - auto* current_mapname = game::Dvar_FindVar("mapname"); if (current_mapname && utils::string::to_lower(current_mapname->current.string) == utils::string::to_lower(mapname) && (game::SV_Loaded() && !game::VirtualLobby_Loaded())) @@ -228,6 +217,17 @@ namespace party return; } + if (!game::environment::is_dedi()) + { + if (game::SV_Loaded()) + { + const auto* args = "Leave"; + game::UI_RunMenuScript(0, &args); + } + + perform_game_initialization(); + } + printf("Starting map: %s\n", mapname.data()); auto* gametype = game::Dvar_FindVar("g_gametype"); @@ -249,29 +249,22 @@ namespace party } } - void send_disconnect() + void disconnect_stub() { - if (game::CL_IsCgameInitialized() && !game::VirtualLobby_Loaded()) + if (!game::VirtualLobby_Loaded()) { - // CL_ForwardCommandToServer - reinterpret_cast(0x14020B310)(0, "disconnect"); - // CL_WritePacket - reinterpret_cast(0x1402058F0)(0); + if (game::CL_IsCgameInitialized()) + { + // CL_ForwardCommandToServer + reinterpret_cast(0x14020B310)(0, "disconnect"); + // CL_WritePacket + reinterpret_cast(0x1402058F0)(0); + } + // CL_Disconnect + reinterpret_cast(0x140209EC0)(0); } } - const auto disconnect_stub = utils::hook::assemble([](utils::hook::assembler& a) - { - a.pushad64(); - a.call_aligned(send_disconnect); - a.popad64(); - - a.mov(edx, 1); - a.xor_(ecx, ecx); - - a.jmp(0x140209EC0); - }); - class component final : public component_interface { public: @@ -283,7 +276,7 @@ namespace party } // hook disconnect command function - utils::hook::jump(0x14020A010, disconnect_stub, true); + utils::hook::jump(0x14020A010, disconnect_stub); command::add("map", [](const command::params& argument) {