From ca3c3a12d79534f56bf4c5982907e501cc189b93 Mon Sep 17 00:00:00 2001 From: BrentVL-1952840 <70229620+Brentdevent@users.noreply.github.com> Date: Sun, 26 Feb 2023 14:31:23 +0100 Subject: [PATCH] Potential fix dedicated servers loading offline classes --- src/client/component/dedicated_patches.cpp | 16 +++++++++++----- src/client/game/structs.hpp | 7 +++++++ src/client/game/symbols.hpp | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/client/component/dedicated_patches.cpp b/src/client/component/dedicated_patches.cpp index 3d68008b..0592acc1 100644 --- a/src/client/component/dedicated_patches.cpp +++ b/src/client/component/dedicated_patches.cpp @@ -10,6 +10,8 @@ namespace dedicated_patches { namespace { + utils::hook::detour spawn_server_hook; + void scr_are_textures_loaded_stub([[maybe_unused]] game::scriptInstance_t inst) { game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1); @@ -58,6 +60,14 @@ namespace dedicated_patches utils::hook::call(address, is_mod_loaded_stub); } } + + void spawn_server_stub(int controllerIndex, const char* server, game::MapPreload preload, bool savegame) + { + game::Com_SessionMode_SetNetworkMode(game::MODE_NETWORK_ONLINE); + game::Com_SessionMode_SetGameMode(game::MODE_GAME_MATCHMAKING_PLAYLIST); + + spawn_server_hook.invoke(controllerIndex, server, preload, savegame); + } } struct component final : server_component @@ -77,11 +87,7 @@ namespace dedicated_patches utils::hook::jump(0x1402565D0_g, is_online_stub); patch_is_mod_loaded_checks(); - scheduler::once([]() - { - game::Com_SessionMode_SetNetworkMode(game::MODE_NETWORK_ONLINE); - game::Com_SessionMode_SetGameMode(game::MODE_GAME_MATCHMAKING_PLAYLIST); - }, scheduler::pipeline::main, 1s); + spawn_server_hook.create(game::SV_SpawnServer, spawn_server_stub); } }; } diff --git a/src/client/game/structs.hpp b/src/client/game/structs.hpp index 56a00d63..bc497701 100644 --- a/src/client/game/structs.hpp +++ b/src/client/game/structs.hpp @@ -48,6 +48,13 @@ namespace game MODE_NETWORK_INVALID = 0x3, }; + enum MapPreload + { + MAP_PRELOAD_NONE = 0x0, + MAP_PRELOAD_FRONTEND = 0x1, + MAP_PRELOAD_IN_GAME = 0x2, + }; + enum bdLobbyErrorCode { BD_NO_ERROR = 0x0, diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 473b7302..66ead02a 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -130,6 +130,7 @@ namespace game WEAK symbol SV_AddTestClient{0x1422499A0, 0x14052E3E0}; WEAK symbol SV_SendServerCommand{0x0, 0x140537F10}; WEAK symbol SV_IsTestClient{0x14224B5C0, 0x14052FF40}; + WEAK symbol SV_SpawnServer{0x142253320, 0x140535B20}; // Utils WEAK symbol I_CleanStr{0x1422E9C10, 0x140580E80};