CSceneEntity::FindNamedEntityClosest
0x00810c90 · 1181 bytes · __thiscall
_ZN12CSceneEntity22FindNamedEntityClosestEPKcP11CBaseEntitybbS1_
Decompiled
undefined (6 params)
/* WARNING: Type propagation algorithm not settling */
/* CSceneEntity::FindNamedEntityClosest(char const*, CBaseEntity*, bool, bool, char const*) */
int __thiscall
CSceneEntity::FindNamedEntityClosest
(CSceneEntity *this,char *param_1,CBaseEntity *param_2,bool param_3,bool param_4,
char *param_5)
{
uint uVar1;
int iVar2;
int *piVar3;
CBaseEntity *pCVar4;
int *piVar5;
undefined *puVar6;
float fVar7;
float fVar8;
float fVar9;
CBaseHandle *this_00;
char *pcVar10;
iVar2 = _V_stricmp(param_1,"!activator");
if (iVar2 == 0) {
uVar1 = *(uint *)(this + 0x704);
if (uVar1 == 0xffffffff) {
return 0;
}
puVar6 = g_pEntityList + (uVar1 & 0xfff) * 0x10;
if (puVar6 == (undefined *)0xfffffffc) {
return 0;
}
if (*(uint *)(puVar6 + 8) != uVar1 >> 0xc) {
return 0;
}
return *(int *)(puVar6 + 4);
}
iVar2 = _V_stricmp(param_1,"Player");
if ((iVar2 == 0) || (iVar2 = _V_stricmp(param_1,"!player"), iVar2 == 0)) {
if (*(int *)(gpGlobals + 0x14) != 1) {
return 0;
}
iVar2 = UTIL_GetLocalPlayer();
return iVar2;
}
pcVar10 = "!target1";
iVar2 = _V_stricmp(param_1,"!target1");
if (iVar2 == 0) {
param_1 = *(char **)(this + 0x454);
}
else {
pcVar10 = "!target2";
iVar2 = _V_stricmp(param_1,"!target2");
if (iVar2 == 0) {
param_1 = *(char **)(this + 0x458);
}
else {
pcVar10 = "!target3";
iVar2 = _V_stricmp(param_1,"!target3");
if (iVar2 == 0) {
param_1 = *(char **)(this + 0x45c);
}
else {
pcVar10 = "!target4";
iVar2 = _V_stricmp(param_1,"!target4");
if (iVar2 == 0) {
param_1 = *(char **)(this + 0x460);
}
else {
pcVar10 = "!target5";
iVar2 = _V_stricmp(param_1,"!target5");
if (iVar2 == 0) {
param_1 = *(char **)(this + 0x464);
}
else {
pcVar10 = "!target6";
iVar2 = _V_stricmp(param_1,"!target6");
if (iVar2 == 0) {
param_1 = *(char **)(this + 0x468);
}
else {
pcVar10 = "!target7";
iVar2 = _V_stricmp(param_1,"!target7");
if (iVar2 != 0) goto LAB_00810d7a;
param_1 = *(char **)(this + 0x46c);
}
}
}
}
}
}
if ((IHandleEntity *)param_1 == (IHandleEntity *)0x0) {
param_1 = &DAT_00d539c2;
}
LAB_00810d7a:
if ((param_2 == (CBaseEntity *)0x0) || (iVar2 = CBaseEntity::MyNPCPointer(), iVar2 == 0)) {
pCVar4 = (CBaseEntity *)0x0;
iVar2 = 0;
do {
pCVar4 = (CBaseEntity *)
CGlobalEntityList::FindEntityByName
((CGlobalEntityList *)gEntList,pCVar4,param_1,(CBaseEntity *)0x0,param_2,
(CBaseEntity *)0x0,(IEntityFindFilter *)0x0);
if (pCVar4 != (CBaseEntity *)0x0) {
RandomInt(0,iVar2);
}
iVar2 = iVar2 + 1;
} while (iVar2 != 0x20);
return 0;
}
if ((param_5 != (char *)0x0) &&
((*param_5 != '\0' &&
(pCVar4 = (CBaseEntity *)(**(code **)(*(int *)this + 0x3ec))(this,param_5,param_2,0,0,0),
pcVar10 = param_5, pCVar4 != (CBaseEntity *)0x0)))) {
if (((byte)pCVar4[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar4);
}
piVar3 = ::operator_new(0x34);
*piVar3 = (int)&PTR_ShouldFindEntity_00cccc88;
piVar3[1] = -1;
piVar3[5] = *(int *)(pCVar4 + 0x2e0);
piVar3[6] = *(int *)(pCVar4 + 0x2e4);
iVar2 = *(int *)(pCVar4 + 0x2e8);
piVar3[8] = 0x475db3d7;
piVar3[9] = 0x475db3d7;
piVar3[7] = iVar2;
piVar3[10] = 0;
piVar3[0xb] = 0x475db3d7;
piVar3[0xc] = 0;
/* try { // try from 00810f10 to 00810f12 has its CatchHandler @ 0081111d */
piVar5 = (int *)(**(code **)(*(int *)param_2 + 0xc))(param_2);
piVar3[1] = *piVar5;
if (((byte)param_2[0x14d] & 8) != 0) {
/* try { // try from 0081103b to 0081103f has its CatchHandler @ 0081111d */
CBaseEntity::CalcAbsolutePosition(param_2);
}
fVar9 = *(float *)(param_2 + 0x2e0);
piVar3[2] = (int)fVar9;
fVar9 = fVar9 - (float)piVar3[5];
fVar7 = *(float *)(param_2 + 0x2e4);
piVar3[3] = (int)fVar7;
fVar7 = fVar7 - (float)piVar3[6];
fVar8 = *(float *)(param_2 + 0x2e8);
piVar3[4] = (int)fVar8;
fVar8 = fVar8 - (float)piVar3[7];
fVar9 = SQRT(fVar7 * fVar7 + fVar9 * fVar9 + fVar8 * fVar8);
if ((56754.84 < fVar9) || (fVar9 = fVar9 + 1.0, piVar3[8] = (int)fVar9, fVar9 <= 1.0)) {
piVar3[8] = 0x475db3d7;
}
piVar5 = (int *)CBaseEntity::MyNPCPointer();
pcVar10 = param_1;
iVar2 = (**(code **)(*piVar5 + 0x8cc))(piVar5,param_1,piVar3);
if (iVar2 != 0) {
return iVar2;
}
iVar2 = (**(code **)(*piVar3 + 4))(piVar3);
if (iVar2 != 0) {
return iVar2;
}
}
if (!param_4) {
piVar3 = (int *)CBaseEntity::MyNPCPointer();
/* WARNING: Could not recover jumptable at 0x00810dcd. Too many branches */
/* WARNING: Treating indirect jump as call */
iVar2 = (**(code **)(*piVar3 + 0x8cc))();
return iVar2;
}
this_00 = (CBaseHandle *)0xc;
piVar3 = ::operator_new(0xc);
*piVar3 = (int)&PTR_ShouldFindEntity_00cccc78;
piVar3[1] = -1;
piVar3[2] = -1;
CBaseHandle::Set(this_00,(IHandleEntity *)pcVar10);
piVar5 = (int *)CBaseEntity::MyNPCPointer();
iVar2 = (**(code **)(*piVar5 + 0x8cc))(piVar5,param_1,piVar3);
if (iVar2 == 0) {
/* WARNING: Could not recover jumptable at 0x008110cd. Too many branches */
/* WARNING: Treating indirect jump as call */
iVar2 = (**(code **)(*piVar3 + 4))();
return iVar2;
}
return iVar2;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.