From f341919aade6b15423bcb2e56f03f4e7cb5e4da7 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 7 Nov 2022 23:11:12 +0100 Subject: [PATCH] Properly initialize VPK and cache system for the dedicated server server loads "vpk/server_mp_lobby.bsp" instead of "vpk/client_mp_common.bsp" and "vpk/client_frontend.bsp". Also removed the old hack we used to patch string constants to format VPK string paths as we have a proper implementation now using CEngineAPI::SetStartupInfo. --- r5dev/common/opcodes.cpp | 12 ------------ r5dev/common/opcodes.h | 28 +--------------------------- r5dev/engine/sys_dll2.cpp | 7 ++++++- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index e3d56079..586fc20e 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -340,18 +340,6 @@ void Dedicated_Init() KeyboardLayout_Init.Patch({ 0xC3 }); // FUN --> RET | Prevent keyboard layout initialization for IME in CInit. #endif } - - // This mandatory pak file should only exist on the server. - if (FileExists("vpk\\server_mp_common.bsp.pak000_000.vpk")) - { - // Patch 'client' pak file string constants to 'server' if this is a standalone dedicated server. - g_pClientVPKDir.PatchString("vpk/%sserver_%s.bsp.pak000%s"); - g_pClientBSP.PatchString("vpk/server_%s.bsp"); - g_pClientCommonBSP.PatchString("vpk/server_mp_common.bsp"); - g_pClientMPLobby.PatchString("vpk/server_mp_lobby"); - g_pClientMP.PatchString("vpk/server_mp"); - g_pClientSP.PatchString("vpk/server_sp"); - } } #endif // DEDICATED diff --git a/r5dev/common/opcodes.h b/r5dev/common/opcodes.h index 051c61ce..f3b5b596 100644 --- a/r5dev/common/opcodes.h +++ b/r5dev/common/opcodes.h @@ -80,17 +80,6 @@ inline CMemory CWin32Surface_initStaticData; inline CMemory KeyboardLayout_Init; #endif -//------------------------------------------------------------------------- -// .RDATA -//------------------------------------------------------------------------- -inline CMemory g_pClientVPKDir; -inline CMemory g_pClientBSP; -inline CMemory g_pClientCommonBSP; -inline CMemory g_pClientMPLobby; -inline CMemory g_pClientMP; -inline CMemory g_pClientSP; - - /////////////////////////////////////////////////////////////////////////////// class VOpcodes : public IDetour { @@ -128,13 +117,6 @@ class VOpcodes : public IDetour #endif spdlog::debug("| FUN: KeyboardLayout_Init : {:#18x} |\n", KeyboardLayout_Init.GetPtr()); spdlog::debug("+----------------------------------------------------------------+\n"); - spdlog::debug("| CON: g_pClientVPKDir : {:#18x} |\n", g_pClientVPKDir.GetPtr()); - spdlog::debug("| CON: g_pClientBSP : {:#18x} |\n", g_pClientBSP.GetPtr()); - spdlog::debug("| CON: g_pClientCommonBSP : {:#18x} |\n", g_pClientCommonBSP.GetPtr()); - spdlog::debug("| CON: g_pClientMPLobby : {:#18x} |\n", g_pClientMPLobby.GetPtr()); - spdlog::debug("| CON: g_pClientMP : {:#18x} |\n", g_pClientMP.GetPtr()); - spdlog::debug("| CON: g_pClientSP : {:#18x} |\n", g_pClientSP.GetPtr()); - spdlog::debug("+----------------------------------------------------------------+\n"); } virtual void GetFun(void) const { } virtual void GetVar(void) const @@ -231,15 +213,7 @@ class VOpcodes : public IDetour KeyboardLayout_Init = g_GameDll.FindPatternSIMD(reinterpret_cast("\x48\x83\xEC\x28\x33\xC9\xFF\x15\x00\x00\x00\x00\x48\x8D\x0D\x00\x00\x00\x00"), "xxxxxxxx????xxx????"); #endif //48 83 EC 28 33 C9 FF 15 ? ? ? ? 48 8D 0D ? ? ? ? } - virtual void GetCon(void) const - { - g_pClientVPKDir = g_GameDll.FindStringReadOnly("vpk/%sclient_%s.bsp.pak000%s", true); - g_pClientBSP = g_GameDll.FindStringReadOnly("vpk/client_%s.bsp", true); - g_pClientCommonBSP = g_GameDll.FindStringReadOnly("vpk/client_mp_common.bsp", true); - g_pClientMPLobby = g_GameDll.FindStringReadOnly("vpk/client_mp_lobby", true); - g_pClientMP = g_GameDll.FindStringReadOnly("vpk/client_mp_", true); - g_pClientSP = g_GameDll.FindStringReadOnly("vpk/client_sp_", true); - } + virtual void GetCon(void) const { } virtual void Attach(void) const { } virtual void Detach(void) const { } }; diff --git a/r5dev/engine/sys_dll2.cpp b/r5dev/engine/sys_dll2.cpp index c2c10707..4094d3c0 100644 --- a/r5dev/engine/sys_dll2.cpp +++ b/r5dev/engine/sys_dll2.cpp @@ -115,9 +115,14 @@ void CEngineAPI::VSetStartupInfo(CEngineAPI* pEngineAPI, StartupInfo_t* pStartup } if (!CommandLine()->CheckParm("-novpk") && FileSystem()->FileExists(szCacheEnableFilePath, nullptr)) { - FileSystem()->SetVPKCacheModeClient(); FileSystem()->AddSearchPath(".", "MAIN", SearchPathAdd_t::PATH_ADD_TO_TAIL); +#ifndef DEDICATED + FileSystem()->SetVPKCacheModeClient(); FileSystem()->MountVPKFile("vpk/client_frontend.bsp"); +#else // Dedicated runs server vpk's and must have 'vpk/mp_lobby.bsp' mounted. + FileSystem()->SetVPKCacheModeServer(); + FileSystem()->MountVPKFile("vpk/server_mp_lobby.bsp"); +#endif // !DEDICATED } v_TRACEINIT(NULL, "COM_InitFilesystem( m_StartupInfo.m_szInitialMod )", "COM_ShutdownFileSystem()"); COM_InitFilesystem(pEngineAPI->m_StartupInfo.m_szInitialMod);