From f74371327ea1fb517348eacb21a70551c69e6b51 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sat, 21 May 2022 13:11:10 +0200 Subject: [PATCH] Reduce CPU time on dedicated server Don't run 'CInputSystem::RunFrameIME()' each frame --- r5dev/common/opcodes.cpp | 7 +++++++ r5dev/common/opcodes.h | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/r5dev/common/opcodes.cpp b/r5dev/common/opcodes.cpp index 954aac2f..c1d9bd10 100644 --- a/r5dev/common/opcodes.cpp +++ b/r5dev/common/opcodes.cpp @@ -178,6 +178,13 @@ void Dedicated_Init() CEngineVGui__ActivateGameUI.FindPatternSelf("74 08", CMemory::Direction::DOWN).Patch({ 0x90, 0x90 }); // JZ --> NOP | Remove condition to return early when engine attempts to activate UI on the server. } + //------------------------------------------------------------------------- + // CENGINEVGUI + //------------------------------------------------------------------------- + { + CInputSystem__RunFrameIME.Patch({ 0xB8, 0x00, 0x00, 0x00, 0x00, 0xC3 }); // FUN --> RET | Return early in 'CInputSystem::RunFrameIME()'. + } + //------------------------------------------------------------------------- // MM_HEARTBEAT //------------------------------------------------------------------------- diff --git a/r5dev/common/opcodes.h b/r5dev/common/opcodes.h index 164a329c..2b85797f 100644 --- a/r5dev/common/opcodes.h +++ b/r5dev/common/opcodes.h @@ -32,6 +32,11 @@ inline CMemory CVGui__RunFrame; inline CMemory CEngineVGui__Shutdown; inline CMemory CEngineVGui__ActivateGameUI; +//------------------------------------------------------------------------- +// CENGINEVGUI +//------------------------------------------------------------------------- +inline CMemory CInputSystem__RunFrameIME; + //------------------------------------------------------------------------- // RUNTIME: SYS_INITGAME //------------------------------------------------------------------------- @@ -104,6 +109,8 @@ class VOpcodes : public IDetour spdlog::debug("| FUN: CEngineVGui::Shutdown : {:#18x} |\n", CEngineVGui__Shutdown.GetPtr()); spdlog::debug("| FUN: CEngineVGui::ActivateGameUI : {:#18x} |\n", CEngineVGui__ActivateGameUI.GetPtr()); spdlog::debug("+----------------------------------------------------------------+\n"); + spdlog::debug("| FUN: CInputSystem::RunFrameIME : {:#18x} |\n", CInputSystem__RunFrameIME.GetPtr()); + spdlog::debug("+----------------------------------------------------------------+\n"); spdlog::debug("| FUN: Sys_InitGame : {:#18x} |\n", Sys_InitGame.GetPtr()); spdlog::debug("+----------------------------------------------------------------+\n"); spdlog::debug("| FUN: Host_Init_0 : {:#18x} |\n", gHost_Init_0.GetPtr()); @@ -120,6 +127,8 @@ class VOpcodes : public IDetour spdlog::debug("| FUN: HandleConfigFile : {:#18x} |\n", HandleConfigFile.GetPtr()); spdlog::debug("| FUN: ResetPreviousGameState : {:#18x} |\n", ResetPreviousGameState.GetPtr()); spdlog::debug("| FUN: LoadPlayerConfig : {:#18x} |\n", LoadPlayerConfig.GetPtr()); + spdlog::debug("| FUN: GetEngineClientThread : {:#18x} |\n", GetEngineClientThread.GetPtr()); + spdlog::debug("| FUN: MatchMaking_Frame : {:#18x} |\n", MatchMaking_Frame.GetPtr()); spdlog::debug("+----------------------------------------------------------------+\n"); #if !defined (GAMEDLL_S0) || !defined (GAMEDLL_S1) spdlog::debug("| FUN: CWin32Surface::initStaticData : {:#18x} |\n", CWin32Surface_initStaticData.GetPtr()); @@ -165,6 +174,13 @@ class VOpcodes : public IDetour CEngineVGui__ActivateGameUI = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x53\x48\x83\xEC\x20\xF6\x81\x00\x00\x00\x00\x00\x48\x8B\xD9\x74\x08"), "xxxxxxxx?????xxxxx"); // + //------------------------------------------------------------------------- +#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1) + CInputSystem__RunFrameIME = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x8B\xC4\x57\x41\x55"), "xxxxxx"); +#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3) + CInputSystem__RunFrameIME = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x40\x57\x41\x54\x41\x55\x48\x83\xEC\x70"), "xxxxxxxxxx"); +#endif + //------------------------------------------------------------------------- Sys_InitGame = g_mGameDll.FindPatternSIMD(reinterpret_cast("\x48\x89\x5C\x24\x00\x57\x48\x81\xEC\x00\x00\x00\x00\x80\x3D\x00\x00\x00\x00\x00\x41\x8B\xD8"), "xxxx?xxxx????xx?????xxx"); // 0x1402958D0 // 48 89 5C 24 ? 57 48 81 EC ? ? ? ? 80 3D ? ? ? ? ? 41 8B D8 //