From 7b971d03989113456fbabde36910e5837c7608c8 Mon Sep 17 00:00:00 2001 From: Amos <48657826+Mauler125@users.noreply.github.com> Date: Sat, 19 Feb 2022 20:30:09 +0100 Subject: [PATCH] Disable starpak error handling on the dedicated server Server could be ran without any starpak files --- r5dev/common/opcodes.cpp | 12 +++++++++++- r5dev/rtech/rtech_game.h | 14 ++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index 2685d87c..5256f83b 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -3,9 +3,9 @@ *-----------------------------------------------------------------------------*/ #include "core/stdafx.h" +#include "launcher/IApplication.h" #include "common/opcodes.h" #include "common/netmessages.h" -#include "launcher/IApplication.h" #include "engine/cmodel_bsp.h" #include "engine/host_cmd.h" #include "engine/gl_screen.h" @@ -13,6 +13,7 @@ #include "engine/cl_main.h" #include "engine/sv_main.h" #include "engine/sys_getmodes.h" +#include "rtech/rtech_game.h" #include "client/cdll_engine_int.h" #include "game/server/fairfight_impl.h" #include "materialsystem/materialsystem.h" @@ -202,6 +203,15 @@ void Dedicated_Init() #endif } + //------------------------------------------------------------------------- + // RUNTIME: RTECH_GAME + //------------------------------------------------------------------------- + { +#if defined (GAMEDLL_S2) || defined (GAMEDLL_S3) + p_RTech_LoadPak.Offset(0x890).FindPatternSelf("75", ADDRESS::Direction::DOWN, 200).Patch({ 0xEB }); // JNZ --> JMP | Disable error handling for missing streaming files on the server. The server does not need streamed data from the starpak files. +#endif + } + //------------------------------------------------------------------------- // RUNTIME: EBISUSDK //------------------------------------------------------------------------- diff --git a/r5dev/rtech/rtech_game.h b/r5dev/rtech/rtech_game.h index a80f7bfd..9729d0de 100644 --- a/r5dev/rtech/rtech_game.h +++ b/r5dev/rtech/rtech_game.h @@ -13,11 +13,14 @@ namespace #endif #if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) || defined (GAMEDLL_S2) - ADDRESS p_RTech_AsyncLoad = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x40\x48\x89\x6C\x24\x00\x41\x8B\xE8", "xxxxxxxxxx?xxx"); - unsigned int (*RTech_AsyncLoad)(void* Src, __int64 a2, int a3, char pakfile) = (unsigned int (*)(void*, __int64, int, char))p_RTech_AsyncLoad.GetPtr(); /*40 53 48 83 EC 40 48 89 6C 24 ? 41 8B E8*/ + ADDRESS p_RTech_AsyncLoad = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x40\x48\x89\x6C\x24\x00\x41\x8B\xE8", "xxxxxxxxxx?xxx"); /*40 53 48 83 EC 40 48 89 6C 24 ? 41 8B E8*/ + unsigned int (*RTech_AsyncLoad)(void* Src, std::uintptr_t pMalloc, int nIdx, char szPakFile) = (unsigned int (*)(void*, std::uintptr_t, int, char))p_RTech_AsyncLoad.GetPtr(); #elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) - ADDRESS p_RTech_AsyncLoad = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x40\x48\x89\x6C\x24\x00\x41\x0F\xB6\xE9", "xxxxxxxxxx?xxxx"); - unsigned int (*RTech_AsyncLoad)(void* Src, __int64 a2, int a3, char pakfile) = (unsigned int (*)(void*, __int64, int, char))p_RTech_AsyncLoad.GetPtr(); /*40 53 48 83 EC 40 48 89 6C 24 ? 41 0F B6 E9*/ + ADDRESS p_RTech_AsyncLoad = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x40\x53\x48\x83\xEC\x40\x48\x89\x6C\x24\x00\x41\x0F\xB6\xE9", "xxxxxxxxxx?xxxx"); /*40 53 48 83 EC 40 48 89 6C 24 ? 41 0F B6 E9*/ + unsigned int (*RTech_AsyncLoad)(void* Src, std::uintptr_t pMalloc, int nIdx, char szPakFile) = (unsigned int (*)(void*, std::uintptr_t, int, char))p_RTech_AsyncLoad.GetPtr(); + + ADDRESS p_RTech_LoadPak = g_mGameDll.FindPatternSIMD((std::uint8_t*)"\x48\x89\x4C\x24\x00\x56\x41\x55", "xxxx?xxx"); /*48 89 4C 24 ? 56 41 55*/ + unsigned int (*RTech_LoadPak)(void* thisptr, void* a2, std::uint64_t a3) = (unsigned int (*)(void*, void*, std::uint64_t))p_RTech_LoadPak.GetPtr(); #endif } void HRTech_UnloadAsset(std::int64_t a1, std::int64_t a2); @@ -33,6 +36,9 @@ class HRTechGame : public IDetour { std::cout << "| FUN: RTech_UnloadAsset : 0x" << std::hex << std::uppercase << p_RTech_UnloadAsset.GetPtr() << std::setw(npad) << " |" << std::endl; std::cout << "| FUN: RTech_AsyncLoad : 0x" << std::hex << std::uppercase << p_RTech_AsyncLoad.GetPtr() << std::setw(npad) << " |" << std::endl; +#if defined (GAMEDLL_S2) || defined (GAMEDLL_S3) + std::cout << "| FUN: RTech_LoadPak : 0x" << std::hex << std::uppercase << p_RTech_LoadPak.GetPtr() << std::setw(npad) << " |" << std::endl; +#endif // GAMEDLL_S2 || GAMEDLL_S3 std::cout << "+----------------------------------------------------------------+" << std::endl; } };