Re-introduce Address as int64 and remove the opt-in (#2414)

This commit is contained in:
Benoist
2026-03-15 00:43:25 +01:00
committed by GitHub
parent b492426a79
commit 155cdc318c
28 changed files with 287 additions and 404 deletions
+60 -18
View File
@@ -465,20 +465,6 @@ HookReturnStruct *GetReturnStruct(DHooksCallback *dg)
return res;
}
cell_t GetThisPtr(IPluginContext* pContext, void *iface, ThisPointerType type)
{
if (type == ThisPointer_CBaseEntity)
{
if (!iface)
return -1;
return gamehelpers->EntityToBCompatRef((CBaseEntity *)iface);
}
if (pContext->GetRuntime()->FindPubvarByName("__Virtual_Address__", nullptr) == SP_ERROR_NONE) {
return g_pSM->ToPseudoAddress(iface);
}
return (cell_t)iface;
}
#if defined( WIN32 ) && !defined( KE_ARCH_X64 )
void *Callback(DHooksCallback *dg, void **argStack, size_t *argsizep)
#else
@@ -499,7 +485,21 @@ void *Callback(DHooksCallback *dg, void **argStack)
if(dg->thisType == ThisPointer_CBaseEntity || dg->thisType == ThisPointer_Address)
{
dg->plugin_callback->PushCell(GetThisPtr(dg->plugin_callback->GetParentContext(), g_SHPtr->GetIfacePtr(), dg->thisType));
auto thisAddr = g_SHPtr->GetIfacePtr();
if (dg->thisType == ThisPointer_CBaseEntity) {
if (thisAddr == nullptr) {
dg->plugin_callback->PushCell(-1);
} else {
dg->plugin_callback->PushCell(gamehelpers->EntityToBCompatRef((CBaseEntity *)thisAddr));
}
} else {
if (dg->int64_address) {
std::int64_t addr = reinterpret_cast<std::int64_t>(thisAddr);
dg->plugin_callback->PushArray(reinterpret_cast<cell_t*>(&addr), 2);
} else {
dg->plugin_callback->PushCell((cell_t)thisAddr);
}
}
}
if(dg->returnType != ReturnType_Void)
{
@@ -683,7 +683,21 @@ float Callback_float(DHooksCallback *dg, void **argStack)
if(dg->thisType == ThisPointer_CBaseEntity || dg->thisType == ThisPointer_Address)
{
dg->plugin_callback->PushCell(GetThisPtr(dg->plugin_callback->GetParentContext(), g_SHPtr->GetIfacePtr(), dg->thisType));
auto thisAddr = g_SHPtr->GetIfacePtr();
if (dg->thisType == ThisPointer_CBaseEntity) {
if (thisAddr == nullptr) {
dg->plugin_callback->PushCell(-1);
} else {
dg->plugin_callback->PushCell(gamehelpers->EntityToBCompatRef((CBaseEntity *)thisAddr));
}
} else {
if (dg->int64_address) {
std::int64_t addr = reinterpret_cast<std::int64_t>(thisAddr);
dg->plugin_callback->PushArray(reinterpret_cast<cell_t*>(&addr), 2);
} else {
dg->plugin_callback->PushCell((cell_t)thisAddr);
}
}
}
returnStruct = GetReturnStruct(dg);
@@ -840,7 +854,21 @@ SDKVector *Callback_vector(DHooksCallback *dg, void **argStack)
if(dg->thisType == ThisPointer_CBaseEntity || dg->thisType == ThisPointer_Address)
{
dg->plugin_callback->PushCell(GetThisPtr(dg->plugin_callback->GetParentContext(), g_SHPtr->GetIfacePtr(), dg->thisType));
auto thisAddr = g_SHPtr->GetIfacePtr();
if (dg->thisType == ThisPointer_CBaseEntity) {
if (thisAddr == nullptr) {
dg->plugin_callback->PushCell(-1);
} else {
dg->plugin_callback->PushCell(gamehelpers->EntityToBCompatRef((CBaseEntity *)thisAddr));
}
} else {
if (dg->int64_address) {
std::int64_t addr = reinterpret_cast<std::int64_t>(thisAddr);
dg->plugin_callback->PushArray(reinterpret_cast<cell_t*>(&addr), 2);
} else {
dg->plugin_callback->PushCell((cell_t)thisAddr);
}
}
}
returnStruct = GetReturnStruct(dg);
@@ -994,7 +1022,21 @@ string_t *Callback_stringt(DHooksCallback *dg, void **argStack)
if(dg->thisType == ThisPointer_CBaseEntity || dg->thisType == ThisPointer_Address)
{
dg->plugin_callback->PushCell(GetThisPtr(dg->plugin_callback->GetParentContext(), g_SHPtr->GetIfacePtr(), dg->thisType));
auto thisAddr = g_SHPtr->GetIfacePtr();
if (dg->thisType == ThisPointer_CBaseEntity) {
if (thisAddr == nullptr) {
dg->plugin_callback->PushCell(-1);
} else {
dg->plugin_callback->PushCell(gamehelpers->EntityToBCompatRef((CBaseEntity *)thisAddr));
}
} else {
if (dg->int64_address) {
std::int64_t addr = reinterpret_cast<std::int64_t>(thisAddr);
dg->plugin_callback->PushArray(reinterpret_cast<cell_t*>(&addr), 2);
} else {
dg->plugin_callback->PushCell((cell_t)thisAddr);
}
}
}
returnStruct = GetReturnStruct(dg);