1
0
mirror of https://github.com/Mauler125/r5sdk.git synced 2025-02-09 19:15:03 +01:00

Fix crash during bots simulation

Wrong ptr to 'CUserCmd::Reset'.
This commit is contained in:
Kawe Mazidjatari 2023-01-31 00:03:40 +01:00
parent e783309d76
commit 918535ff0f
3 changed files with 12 additions and 7 deletions

@ -27,7 +27,7 @@ void Physics_RunBotSimulation(bool bSimulating)
if (pClient->IsActive() && pClient->IsFakeClient())
{
CPlayer* pPlayer = UTIL_PlayerByIndex(i + 1);
CPlayer* pPlayer = UTIL_PlayerByIndex(pClient->GetHandle());
if (pPlayer)
pPlayer->RunNullCommand();
}
@ -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);
return v_Physics_RunThinkFunctions(bSimulating);
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)>();
///////////////////////////////////////////////////////////////////////////////
class VPhysics_Main : public IDetour
@ -20,7 +20,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 { }

@ -33,7 +33,7 @@ class CUserCmd
public:
CUserCmd() // Cannot be constructed during DLL init.
{
v_CUserCmd__Reset(this);
Reset();
}
CUserCmd* Copy(CUserCmd* pSource)
@ -41,6 +41,11 @@ public:
return v_CUserCmd__Copy(this, pSource);
}
void Reset()
{
v_CUserCmd__Reset(this);
}
int32_t command_number;
int32_t tick_count;
float curtime;
@ -69,7 +74,7 @@ class VUserCmd : public IDetour
}
virtual void GetFun(void) const
{
p_CUserCmd__Reset = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 83 FD FF 74 0A").FollowNearCallSelf();
p_CUserCmd__Reset = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 48 8B DF 66 83 FE FF").FollowNearCallSelf();
v_CUserCmd__Reset = p_CUserCmd__Reset.RCast<void(*)(CUserCmd*)>();
p_CUserCmd__Copy = g_GameDll.FindPatternSIMD("E8 ?? ?? ?? ?? 4C 8B 9B ?? ?? ?? ??").FollowNearCallSelf();