Fix crash when setting persistence var in CClient struct

This commit is contained in:
Amos 2021-12-27 02:06:03 +01:00
parent c7987f8f6b
commit 77c2be57ec
3 changed files with 5 additions and 5 deletions

View File

@ -2,4 +2,4 @@
#include "client/client.h"
///////////////////////////////////////////////////////////////////////////////
CClient* g_pClient = reinterpret_cast<CClient*>(p_IVEngineServer_PersistenceAvailable.FindPatternSelf("48 8D 0D", ADDRESS::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7).GetPtr());
CClient* g_pClient = reinterpret_cast<CClient*>(g_pClientBuffer.GetPtr());

View File

@ -21,6 +21,7 @@ namespace
const std::uintptr_t g_dwPersistenceVar = 0x5BC;
const std::uintptr_t g_dwCClientPadding = 303360;
#endif
static ADDRESS g_pClientBuffer = p_IVEngineServer_PersistenceAvailable.FindPatternSelf("48 8D 0D", ADDRESS::Direction::DOWN, 150).ResolveRelativeAddressSelf(0x3, 0x7);
}
class CClient
@ -28,7 +29,7 @@ class CClient
public:
inline CClient* GetClientInstance(int nIndex)
{
return (CClient*)(std::uintptr_t)(g_pClient + (nIndex * g_dwCClientSize));
return (CClient*)(std::uintptr_t)(g_pClientBuffer.GetPtr() + (nIndex * g_dwCClientSize));
}
void*& GetNetChan()

View File

@ -15,9 +15,8 @@
//-----------------------------------------------------------------------------
bool HIVEngineServer_PersistenceAvailable(void* entidx, int clientidx)
{
CClient* pClient = g_pClient->GetClientInstance(clientidx); // Get client instance.
std::uintptr_t targetInstance = (std::uintptr_t)pClient;
*(char*)(targetInstance + g_dwPersistenceVar) = (char)0x5; // Set the client instance to 'ready'.
CClient* pClient = g_pClient->GetClientInstance(clientidx); // Get client instance.
*(char*)((std::uintptr_t)pClient + g_dwPersistenceVar) = (char)0x5; // Set the client instance to 'ready'.
if (!g_bIsPersistenceVarSet[clientidx] && sv_showconnecting->m_pParent->m_iValue > 0)
{