Initial 'EntityByIndex' implementation

This commit is contained in:
Kawe Mazidjatari 2023-01-23 23:40:40 +01:00
parent 66ef9fb6a0
commit 2c7636ec0d
4 changed files with 13 additions and 4 deletions

View File

@ -272,7 +272,7 @@ class VBaseEntity : public IDetour
}
virtual void GetVar(void) const
{
g_pEntityList = p_CBaseEntity__GetBaseEntity.FindPattern("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CEntInfo*>();
g_pEntityList = p_CBaseEntity__GetBaseEntity.FindPattern("48 8D 0D").ResolveRelativeAddressSelf(0x3, 0x7).RCast<CEntInfo**>();
}
virtual void GetCon(void) const { }
virtual void Attach(void) const { }

View File

@ -6,4 +6,12 @@
#include "core/stdafx.h"
#include "entitylist.h"
CEntInfo* g_pEntityList = nullptr;
IHandleEntity* LookupEntityByIndex(int iEntity)
{
Assert(iEntity >= 0 && iEntity < NUM_ENT_ENTRIES); // Programmer error!
IHandleEntity* pHandle = reinterpret_cast<IHandleEntity*>(*&g_pEntityList[6 * iEntity]);
return pHandle; // !TODO: implement CBaseEntityList properly.
}
CEntInfo** g_pEntityList = nullptr;

View File

@ -8,6 +8,7 @@
#define ENTITYLIST_H
#include "game/shared/entitylist_base.h"
extern CEntInfo* g_pEntityList;
IHandleEntity* LookupEntityByIndex(int iEntity);
extern CEntInfo** g_pEntityList;
#endif // ENTITYLIST_H

View File

@ -14,7 +14,7 @@
#define MAX_EDICTS (1<<MAX_EDICT_BITS)
// Used for networking ehandles.
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 2)
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS) // !TODO: is this correct?
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS) // Value is correct for r5.
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF
#define NUM_SERIAL_NUM_BITS 16 // (32 - NUM_ENT_ENTRY_BITS)