Potential fix dedicated servers loading offline classes

This commit is contained in:
BrentVL-1952840 2023-02-26 14:31:23 +01:00
parent 5024886ad1
commit ca3c3a12d7
3 changed files with 19 additions and 5 deletions

View File

@ -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);
}
};
}

View File

@ -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,

View File

@ -130,6 +130,7 @@ namespace game
WEAK symbol<void*()> SV_AddTestClient{0x1422499A0, 0x14052E3E0};
WEAK symbol<void(client_s* cl_0, svscmd_type type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x140537F10};
WEAK symbol<bool(int clientNum)> SV_IsTestClient{0x14224B5C0, 0x14052FF40};
WEAK symbol<void(int controllerIndex, const char* server, MapPreload preload, bool savegame)> SV_SpawnServer{0x142253320, 0x140535B20};
// Utils
WEAK symbol<const char* (char* str)> I_CleanStr{0x1422E9C10, 0x140580E80};