diff --git a/r5dev/game/server/gameinterface.cpp b/r5dev/game/server/gameinterface.cpp index 78e61418..14649e95 100644 --- a/r5dev/game/server/gameinterface.cpp +++ b/r5dev/game/server/gameinterface.cpp @@ -97,4 +97,4 @@ CServerGameClients* g_pServerGameClients = nullptr; CServerGameEnts* g_pServerGameEntities = nullptr; // Holds global variables shared between engine and game. -CGlobalVars* g_pGlobals = nullptr; +CGlobalVars** g_pGlobals = nullptr; diff --git a/r5dev/game/server/gameinterface.h b/r5dev/game/server/gameinterface.h index c6a944c7..c26acc73 100644 --- a/r5dev/game/server/gameinterface.h +++ b/r5dev/game/server/gameinterface.h @@ -50,7 +50,7 @@ extern CServerGameDLL* g_pServerGameDLL; extern CServerGameClients* g_pServerGameClients; extern CServerGameEnts* g_pServerGameEntities; -extern CGlobalVars* g_pGlobals; +extern CGlobalVars** g_pGlobals; void CServerGameDLL_Attach(); void CServerGameDLL_Detach(); @@ -76,7 +76,7 @@ class VServerGameDLL : public IDetour } virtual void GetVar(void) const { - g_pGlobals = g_GameDll.FindPatternSIMD("4C 8B 0D ?? ?? ?? ?? 48 8B D1").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); + g_pGlobals = g_GameDll.FindPatternSIMD("4C 8B 0D ?? ?? ?? ?? 48 8B D1").ResolveRelativeAddressSelf(0x3, 0x7).RCast(); } virtual void GetCon(void) const { } virtual void Attach(void) const { } diff --git a/r5dev/game/server/physics_main.cpp b/r5dev/game/server/physics_main.cpp index 6aa1ebfd..4eb665ee 100644 --- a/r5dev/game/server/physics_main.cpp +++ b/r5dev/game/server/physics_main.cpp @@ -37,10 +37,10 @@ void Physics_RunBotSimulation(bool bSimulating) //----------------------------------------------------------------------------- // Purpose: Runs the main physics simulation loop against all entities ( except players ) //----------------------------------------------------------------------------- -void Physics_RunThinkFunctions(bool bSimulating) +void* Physics_RunThinkFunctions(bool bSimulating) { Physics_RunBotSimulation(bSimulating); - v_Physics_RunThinkFunctions(bSimulating); + return v_Physics_RunThinkFunctions(bSimulating); } /////////////////////////////////////////////////////////////////////////////// diff --git a/r5dev/game/server/physics_main.h b/r5dev/game/server/physics_main.h index 4499814c..4cb3b0fe 100644 --- a/r5dev/game/server/physics_main.h +++ b/r5dev/game/server/physics_main.h @@ -8,7 +8,7 @@ #define PHYSICS_MAIN_H inline CMemory p_Physics_RunThinkFunctions; -inline auto v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast(); +inline auto v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast(); void Physics_Main_Attach(); void Physics_Main_Detach(); @@ -23,7 +23,7 @@ class VPhysics_Main : public IDetour virtual void GetFun(void) const { p_Physics_RunThinkFunctions = g_GameDll.FindPatternSIMD("88 4C 24 08 55 56 57 41 54 41 55 41 56 41 57 48 81 EC ?? ?? ?? ??"); - v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast(); + v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast(); } virtual void GetVar(void) const { } virtual void GetCon(void) const { } diff --git a/r5dev/game/server/player.cpp b/r5dev/game/server/player.cpp index 44302905..48d2fc06 100644 --- a/r5dev/game/server/player.cpp +++ b/r5dev/game/server/player.cpp @@ -17,21 +17,20 @@ void CPlayer::RunNullCommand(void) { CUserCmd cmd; - float flOldFrameTime = g_pGlobals->m_fFrameTime; - float flOldCurTime = g_pGlobals->m_fCurTime; + float flOldFrameTime = (*g_pGlobals)->m_fFrameTime; + float flOldCurTime = (*g_pGlobals)->m_fCurTime; pl.fixangle = FIXANGLE_NONE; - EyeAngles(&cmd.viewangles); - SetTimeBase(g_pGlobals->m_fCurTime); + SetTimeBase((*g_pGlobals)->m_fCurTime); MoveHelperServer()->SetHost(this); PlayerRunCommand(&cmd, MoveHelperServer()); SetLastUserCommand(&cmd); - g_pGlobals->m_fFrameTime = flOldFrameTime; - g_pGlobals->m_fCurTime = flOldCurTime; + (*g_pGlobals)->m_fFrameTime = flOldFrameTime; + (*g_pGlobals)->m_fCurTime = flOldCurTime; MoveHelperServer()->SetHost(NULL); } @@ -59,7 +58,7 @@ inline void CPlayer::SetTimeBase(float flTimeBase) SetLastUCmdSimulationRemainderTime(flTime); - float flSomeTime = flTimeBase - m_lastUCmdSimulationRemainderTime * g_pGlobals->m_nTickInterval; + float flSomeTime = flTimeBase - m_lastUCmdSimulationRemainderTime * (*g_pGlobals)->m_nTickInterval; if (flSomeTime >= 0.0) { flTime = flSomeTime; @@ -79,7 +78,7 @@ void CPlayer::SetLastUCmdSimulationRemainderTime(float flRemainderTime) edict_t nEdict = NetworkProp()->GetEdict(); if (nEdict != FL_EDICT_INVALID) { - _InterlockedOr16(g_pGlobals->m_pInterlock + nEdict + 32, 0x200u); + _InterlockedOr16((SHORT*)(*g_pGlobals)->m_pInterlock + nEdict + 32, 0x200u); } m_lastUCmdSimulationRemainderTime = flRemainderTime; @@ -97,7 +96,7 @@ void CPlayer::SetTotalExtraClientCmdTimeAttempted(float flAttemptedTime) edict_t nEdict = NetworkProp()->GetEdict(); if (nEdict != FL_EDICT_INVALID) { - _InterlockedOr16(g_pGlobals->m_pInterlock + nEdict + 32, 0x200u); + _InterlockedOr16((SHORT*)(*g_pGlobals)->m_pInterlock + nEdict + 32, 0x200u); } m_totalExtraClientCmdTimeAttempted = flAttemptedTime; diff --git a/r5dev/game/shared/shareddefs.h b/r5dev/game/shared/shareddefs.h index 74a90c87..1c858927 100644 --- a/r5dev/game/shared/shareddefs.h +++ b/r5dev/game/shared/shareddefs.h @@ -14,7 +14,7 @@ #ifndef CLIENT_DLL #include "game/server/gameinterface.h" -#define TICK_INTERVAL (g_pGlobals->m_nTickInterval) +#define TICK_INTERVAL ((*g_pGlobals)->m_nTickInterval) #define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) ) #define TICKS_TO_TIME( t ) ( TICK_INTERVAL *( t ) ) diff --git a/r5dev/game/shared/util_shared.cpp b/r5dev/game/shared/util_shared.cpp index 1ad82542..69fa7fdf 100644 --- a/r5dev/game/shared/util_shared.cpp +++ b/r5dev/game/shared/util_shared.cpp @@ -15,11 +15,11 @@ CPlayer* UTIL_PlayerByIndex(int nIndex) { - if (nIndex < 1 || nIndex > g_pGlobals->m_nMaxClients || nIndex == FL_EDICT_INVALID) + if (nIndex < 1 || nIndex > (*g_pGlobals)->m_nMaxClients || nIndex == FL_EDICT_INVALID) return nullptr; // !TODO: Improve this!!! - CPlayer* pPlayer = *reinterpret_cast(g_pGlobals->m_pInterlock + nIndex + 0x7808); + CPlayer* pPlayer = reinterpret_cast((*g_pGlobals)->m_pInterlock[nIndex + 0x7808]); return pPlayer; } #endif // CLIENT_DLL diff --git a/r5dev/public/edict.h b/r5dev/public/edict.h index 169aea69..a839cc95 100644 --- a/r5dev/public/edict.h +++ b/r5dev/public/edict.h @@ -34,7 +34,7 @@ public: MapLoadType_t m_eLoadType; // How the current map was loaded. bool m_bMapLoadFailed; // Map has failed to load, we need to kick back to the main menu (unused?). - SHORT* m_pInterlock; // r5apex_ds.exe 'CBaseServer::Clear() + 0x7E' + int64_t* m_pInterlock; // r5apex_ds.exe 'CBaseServer::Clear() + 0x7E' void* m_pUnk1; // r5apex_ds.exe 'CBaseServer::Clear() + 0x93' void* m_pUnk2; // r5apex_ds.exe 'CServer::FrameJob() + 0x20' void* m_pUnk3;