Add TE_WriteEnt and TE_ReadEnt natives to SDKTools. (#1905)

This commit is contained in:
Nicholas Hastings
2023-01-14 14:48:05 +00:00
committed by GitHub
parent 27b1817b10
commit 8922ed0c5d
4 changed files with 111 additions and 0 deletions
+38
View File
@@ -30,6 +30,7 @@
*/
#include "tempents.h"
#include <basehandle.h>
TempEntityManager g_TEManager;
ICallWrapper *g_GetServerClass = NULL;
@@ -183,6 +184,43 @@ bool TempEntityInfo::TE_GetEntData(const char *name, int *value)
return true;
}
bool TempEntityInfo::TE_SetEntDataEnt(const char *name, IHandleEntity *value)
{
/* Search for our offset */
int offset = _FindOffset(name);
if (offset < 0)
{
return false;
}
auto *pHndl = (CBaseHandle *)((uint8_t *)m_Me + offset);
pHndl->Set(value);
return true;
}
bool TempEntityInfo::TE_GetEntDataEnt(const char *name, IHandleEntity **value)
{
/* Search for our offset */
int offset = _FindOffset(name);
if (offset < 0)
{
return false;
}
auto *pHndl = (CBaseHandle *)((uint8_t *)m_Me + offset);
auto *pEnt = reinterpret_cast<IHandleEntity *>(gamehelpers->ReferenceToEntity(pHndl->GetEntryIndex()));
if (!pEnt || *pHndl != pEnt->GetRefEHandle())
return false;
*value = pEnt;
return true;
}
bool TempEntityInfo::TE_SetEntDataFloat(const char *name, float value)
{
/* Search for our offset */