diff --git a/r5dev/game/server/gameinterface.cpp b/r5dev/game/server/gameinterface.cpp index 14649e95..eb76ddfd 100644 --- a/r5dev/game/server/gameinterface.cpp +++ b/r5dev/game/server/gameinterface.cpp @@ -6,10 +6,14 @@ //=============================================================================// #include "core/stdafx.h" -#include "engine/server/sv_main.h" -#include "game/server/gameinterface.h" +#include "tier1/cvar.h" #include "public/server_class.h" #include "public/eiface.h" +#include "public/const.h" +#include "engine/server/sv_main.h" +#include "gameinterface.h" +#include "entitylist.h" +#include "baseanimating.h" //----------------------------------------------------------------------------- // This is called when a new game is started. (restart, map) @@ -78,11 +82,50 @@ void __fastcall CServerGameDLL::OnReceivedSayTextMessage(void* thisptr, int send #endif } +void DrawServerHitboxes(bool bRunOverlays) +{ + int nVal = sv_showhitboxes->GetInt(); + Assert(nVal < NUM_ENT_ENTRIES); + + if (nVal == -1) + return; + + std::function fnLookupAndDraw = [&](int iEntity) + { + IHandleEntity* pEntity = LookupEntityByIndex(iEntity); + CBaseAnimating* pAnimating = dynamic_cast(pEntity); + + if (pAnimating) + { + pAnimating->DrawServerHitboxes(); + } + }; + + if (nVal == 0) + { + for (int i = 0; i < NUM_ENT_ENTRIES; i++) + { + fnLookupAndDraw(i); + } + } + else // Lookup entity manually by index from 'sv_showhitboxes'. + { + fnLookupAndDraw(nVal); + } +} + +void RunFrameServer(double flFrameTime, bool bRunOverlays, bool bUniformUpdate) +{ + DrawServerHitboxes(bRunOverlays); + v_RunFrameServer(flFrameTime, bRunOverlays, bUniformUpdate); +} + void CServerGameDLL_Attach() { #if defined(GAMEDLL_S3) DetourAttach((LPVOID*)&CServerGameDLL__OnReceivedSayTextMessage, &CServerGameDLL::OnReceivedSayTextMessage); #endif + DetourAttach(&v_RunFrameServer, &RunFrameServer); } void CServerGameDLL_Detach() @@ -90,6 +133,7 @@ void CServerGameDLL_Detach() #if defined(GAMEDLL_S3) DetourDetach((LPVOID*)&CServerGameDLL__OnReceivedSayTextMessage, &CServerGameDLL::OnReceivedSayTextMessage); #endif + DetourDetach(&v_RunFrameServer, &RunFrameServer); } CServerGameDLL* g_pServerGameDLL = nullptr; diff --git a/r5dev/game/server/gameinterface.h b/r5dev/game/server/gameinterface.h index c26acc73..c9b9ecd1 100644 --- a/r5dev/game/server/gameinterface.h +++ b/r5dev/game/server/gameinterface.h @@ -46,6 +46,9 @@ class CServerGameEnts : public IServerGameEnts inline CMemory p_CServerGameDLL__OnReceivedSayTextMessage; inline auto CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast(); +inline CMemory p_RunFrameServer; +inline auto v_RunFrameServer = p_RunFrameServer.RCast(); + extern CServerGameDLL* g_pServerGameDLL; extern CServerGameClients* g_pServerGameClients; extern CServerGameEnts* g_pServerGameEntities; @@ -61,6 +64,7 @@ class VServerGameDLL : public IDetour virtual void GetAdr(void) const { spdlog::debug("| FUN: OnReceivedSayTextMessage : {:#18x} |\n", p_CServerGameDLL__OnReceivedSayTextMessage.GetPtr()); + spdlog::debug("| FUN: RunFrameServer : {:#18x} |\n", p_RunFrameServer.GetPtr()); spdlog::debug("| VAR: g_pServerGameDLL : {:#18x} |\n", reinterpret_cast(g_pServerGameDLL)); spdlog::debug("| VAR: g_pServerGameClients : {:#18x} |\n", reinterpret_cast(g_pServerGameClients)); spdlog::debug("| VAR: g_pServerGameEntities : {:#18x} |\n", reinterpret_cast(g_pServerGameEntities)); @@ -72,6 +76,9 @@ class VServerGameDLL : public IDetour #if defined(GAMEDLL_S3) p_CServerGameDLL__OnReceivedSayTextMessage = g_GameDll.FindPatternSIMD("85 D2 0F 8E ?? ?? ?? ?? 4C 8B DC"); CServerGameDLL__OnReceivedSayTextMessage = p_CServerGameDLL__OnReceivedSayTextMessage.RCast(); + + p_RunFrameServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??"); + v_RunFrameServer = p_RunFrameServer.RCast(); #endif } virtual void GetVar(void) const diff --git a/r5dev/public/utility/sigcache.h b/r5dev/public/utility/sigcache.h index 16fbd4f5..01ed0124 100644 --- a/r5dev/public/utility/sigcache.h +++ b/r5dev/public/utility/sigcache.h @@ -7,7 +7,7 @@ #define SIGDB_DICT_SIZE 20 #define SIGDB_MAJOR_VERSION 0x1 // Increment when library changes are made. -#define SIGDB_MINOR_VERSION 0x7 // Increment when SDK updates are released. +#define SIGDB_MINOR_VERSION 0x8 // Increment when SDK updates are released. #ifdef DEDICATED #define SIGDB_FILE "cfg\\server\\startup.bin" diff --git a/r5dev/server/vengineserver_impl.h b/r5dev/server/vengineserver_impl.h index 04bd127b..7a9f1fab 100644 --- a/r5dev/server/vengineserver_impl.h +++ b/r5dev/server/vengineserver_impl.h @@ -6,9 +6,6 @@ inline CMemory p_IVEngineServer__PersistenceAvailable; inline auto IVEngineServer__PersistenceAvailable = p_IVEngineServer__PersistenceAvailable.RCast(); -//inline CMemory p_RunFrameServer; -//inline auto v_RunFrameServer = p_RunFrameServer.RCast(); - inline bool* g_bDedicated = nullptr; /////////////////////////////////////////////////////////////////////////////// @@ -59,7 +56,6 @@ class HVEngineServer : public IDetour virtual void GetAdr(void) const { spdlog::debug("| FUN: CVEngineServer::PersistenceAvailable : {:#18x} |\n", p_IVEngineServer__PersistenceAvailable.GetPtr()); - //spdlog::debug("| FUN: RunFrameServer : {:#18x} |\n", p_RunFrameServer.GetPtr()); spdlog::debug("| VAR: g_bDedicated : {:#18x} |\n", reinterpret_cast(g_bDedicated)); spdlog::debug("| VAR: g_pEngineServerVFTable : {:#18x} |\n", reinterpret_cast(g_pEngineServerVFTable)); spdlog::debug("+----------------------------------------------------------------+\n"); @@ -67,10 +63,7 @@ class HVEngineServer : public IDetour virtual void GetFun(void) const { p_IVEngineServer__PersistenceAvailable = g_GameDll.FindPatternSIMD("3B 15 ?? ?? ?? ?? 7D 33"); -// p_RunFrameServer = g_GameDll.FindPatternSIMD("48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??"); - - IVEngineServer__PersistenceAvailable = p_IVEngineServer__PersistenceAvailable.RCast(); /*3B 15 ?? ?? ?? ?? 7D 33*/ -// v_RunFrameServer = p_RunFrameServer.RCast(); /*48 89 5C 24 ?? 57 48 83 EC 30 0F 29 74 24 ?? 48 8D 0D ?? ?? ?? ??*/ + IVEngineServer__PersistenceAvailable = p_IVEngineServer__PersistenceAvailable.RCast(); } virtual void GetVar(void) const { diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index 318a3b8e..6a2a7515 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -12,6 +12,7 @@ #include "tier1/utlvector.h" #include "mathlib/fbits.h" #include "vstdlib/callback.h" +#include "public/const.h" #include "public/iconvar.h" #include "public/iconcommand.h" @@ -274,6 +275,11 @@ void ConVar::InitShipped(void) host_hasIrreversibleShutdown = g_pCVar->FindVar("host_hasIrreversibleShutdown"); net_usesocketsforloopback = g_pCVar->FindVar("net_usesocketsforloopback"); #ifndef CLIENT_DLL + sv_showhitboxes = g_pCVar->FindVar("sv_showhitboxes"); + + sv_showhitboxes->SetMin(-1); // Allow user to go over each entity manually without going out of bounds. + sv_showhitboxes->SetMax(NUM_ENT_ENTRIES - 1); + sv_forceChatToTeamOnly = g_pCVar->FindVar("sv_forceChatToTeamOnly"); sv_forceChatToTeamOnly->RemoveFlags(FCVAR_DEVELOPMENTONLY); @@ -481,6 +487,26 @@ const char* ConVar::GetString(void) const return str ? str : ""; } +//----------------------------------------------------------------------------- +// Purpose: +// Input : flMaxVal - +//----------------------------------------------------------------------------- +void ConVar::SetMax(float flMaxVal) +{ + m_pParent->m_fMaxVal = flMaxVal; + m_pParent->m_bHasMax = true; +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : flMinVal - +//----------------------------------------------------------------------------- +void ConVar::SetMin(float flMinVal) +{ + m_pParent->m_fMinVal = flMinVal; + m_pParent->m_bHasMin = true; +} + //----------------------------------------------------------------------------- // Purpose: // Input : flMinVal - diff --git a/r5dev/tier1/IConVar.h b/r5dev/tier1/IConVar.h index 015ef401..7e1dc61d 100644 --- a/r5dev/tier1/IConVar.h +++ b/r5dev/tier1/IConVar.h @@ -37,6 +37,8 @@ public: Color GetColor(void) const; const char* GetString(void) const; + void SetMax(float flMaxValue); + void SetMin(float flMinValue); bool GetMin(float& flMinValue) const; bool GetMax(float& flMaxValue) const; float GetMinValue(void) const; diff --git a/r5dev/tier1/cvar.cpp b/r5dev/tier1/cvar.cpp index f0c6c13a..cdca990d 100644 --- a/r5dev/tier1/cvar.cpp +++ b/r5dev/tier1/cvar.cpp @@ -80,6 +80,7 @@ ConVar* sv_autoReloadRate = nullptr; ConVar* sv_quota_stringCmdsPerSecond = nullptr; ConVar* sv_simulateBots = nullptr; +ConVar* sv_showhitboxes = nullptr; #ifdef DEDICATED ConVar* sv_rcon_debug = nullptr; diff --git a/r5dev/tier1/cvar.h b/r5dev/tier1/cvar.h index 747926e6..d3533443 100644 --- a/r5dev/tier1/cvar.h +++ b/r5dev/tier1/cvar.h @@ -76,6 +76,7 @@ extern ConVar* sv_autoReloadRate; extern ConVar* sv_quota_stringCmdsPerSecond; extern ConVar* sv_simulateBots; +extern ConVar* sv_showhitboxes; #ifdef DEDICATED extern ConVar* sv_rcon_debug;