mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fix 'g_pGlobals' and 'UTIL_PlayerByIndex()'
'UTIL_PlayerByIndex' now returns the player from the edict array properly, 'g_pGlobals' had to be dereferenced twice.
This commit is contained in:
parent
05d2c5e3ea
commit
9720d8b0f1
@ -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;
|
||||
|
@ -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<CGlobalVars*>();
|
||||
g_pGlobals = g_GameDll.FindPatternSIMD("4C 8B 0D ?? ?? ?? ?? 48 8B D1").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CGlobalVars**>();
|
||||
}
|
||||
virtual void GetCon(void) const { }
|
||||
virtual void Attach(void) const { }
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -8,7 +8,7 @@
|
||||
#define PHYSICS_MAIN_H
|
||||
|
||||
inline CMemory p_Physics_RunThinkFunctions;
|
||||
inline auto v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast<void (*)(bool bSimulating)>();
|
||||
inline auto v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast<void* (*)(bool bSimulating)>();
|
||||
|
||||
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<void (*)(bool)>();
|
||||
v_Physics_RunThinkFunctions = p_Physics_RunThinkFunctions.RCast<void* (*)(bool)>();
|
||||
}
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const { }
|
||||
|
@ -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;
|
||||
|
@ -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 ) )
|
||||
|
@ -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<CPlayer**>(g_pGlobals->m_pInterlock + nIndex + 0x7808);
|
||||
CPlayer* pPlayer = reinterpret_cast<CPlayer*>((*g_pGlobals)->m_pInterlock[nIndex + 0x7808]);
|
||||
return pPlayer;
|
||||
}
|
||||
#endif // CLIENT_DLL
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user