CSceneEntity::FindNamedEntity
0x008125b0 · 1981 bytes · __thiscall
_ZN12CSceneEntity15FindNamedEntityEPKcP11CBaseEntitybb
Decompiled
undefined (5 params)
/* CSceneEntity::FindNamedEntity(char const*, CBaseEntity*, bool, bool) */
int __thiscall
CSceneEntity::FindNamedEntity
(CSceneEntity *this,char *param_1,CBaseEntity *param_2,bool param_3,bool param_4)
{
int iVar1;
uint *puVar2;
uint uVar3;
int *piVar4;
CBaseEntity *pCVar5;
int *piVar6;
uint uVar7;
undefined *puVar8;
CSceneEntity *pCVar9;
CBaseHandle *this_00;
char *pcVar10;
IHandleEntity *pIVar11;
int aiStack_9c [35];
iVar1 = _V_stricmp(param_1,"Player");
if ((iVar1 == 0) || (iVar1 = _V_stricmp(param_1,"!player"), iVar1 == 0)) {
if (*(int *)(gpGlobals + 0x14) != 1) goto LAB_008125fa;
iVar1 = UTIL_GetLocalPlayer();
LAB_008126d5:
if (iVar1 != 0) {
return iVar1;
}
LAB_008125fa:
GetCharacterFromName(param_1);
iVar1 = CTerrorPlayer::GetPlayerByCharacter();
return iVar1;
}
iVar1 = _V_stricmp(param_1,"!target1");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x474);
if (uVar3 != 0xffffffff) {
uVar7 = uVar3 & 0xfff;
piVar6 = (int *)(g_pEntityList + uVar7 * 0x10 + 4);
if (((piVar6 != (int *)0x0) && (*(uint *)(g_pEntityList + uVar7 * 0x10 + 8) == uVar3 >> 0xc))
&& (*(int *)(g_pEntityList + uVar7 * 0x10 + 4) != 0)) {
LAB_008127cd:
return *piVar6;
}
}
piVar6 = (int *)FindNamedTarget(this,*(undefined4 *)(this + 0x454),param_3);
if (piVar6 == (int *)0x0) {
*(undefined4 *)(this + 0x474) = 0xffffffff;
return 0;
}
puVar2 = (uint *)(**(code **)(*piVar6 + 0xc))(piVar6);
puVar8 = g_pEntityList;
uVar3 = *puVar2;
*(uint *)(this + 0x474) = uVar3;
joined_r0x008126b3:
if (((uVar3 != 0xffffffff) &&
(piVar6 = (int *)(puVar8 + (uVar3 & 0xfff) * 0x10 + 4), piVar6 != (int *)0x0)) &&
(piVar6[1] == uVar3 >> 0xc)) {
return *piVar6;
}
return 0;
}
iVar1 = _V_stricmp(param_1,"!target2");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x478);
if (uVar3 != 0xffffffff) {
uVar7 = uVar3 & 0xfff;
piVar6 = (int *)(g_pEntityList + uVar7 * 0x10 + 4);
if (((piVar6 != (int *)0x0) && (*(uint *)(g_pEntityList + uVar7 * 0x10 + 8) == uVar3 >> 0xc))
&& (*(int *)(g_pEntityList + uVar7 * 0x10 + 4) != 0)) goto LAB_008127cd;
}
piVar6 = (int *)FindNamedTarget(this,*(undefined4 *)(this + 0x458),param_3);
if (piVar6 == (int *)0x0) {
*(undefined4 *)(this + 0x478) = 0xffffffff;
return 0;
}
puVar2 = (uint *)(**(code **)(*piVar6 + 0xc))(piVar6);
puVar8 = g_pEntityList;
uVar3 = *puVar2;
*(uint *)(this + 0x478) = uVar3;
goto joined_r0x008126b3;
}
iVar1 = _V_stricmp(param_1,"!target3");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x47c);
if (uVar3 != 0xffffffff) {
uVar7 = uVar3 & 0xfff;
if ((((int *)(g_pEntityList + uVar7 * 0x10 + 4) != (int *)0x0) &&
(*(uint *)(g_pEntityList + uVar7 * 0x10 + 8) == uVar3 >> 0xc)) &&
(*(int *)(g_pEntityList + uVar7 * 0x10 + 4) != 0)) {
return *(int *)(g_pEntityList + uVar7 * 0x10 + 4);
}
}
pIVar11 = *(IHandleEntity **)(this + 0x45c);
pCVar9 = this;
iVar1 = FindNamedTarget(this,pIVar11,param_3);
if (iVar1 == 0) {
*(undefined4 *)(this + 0x47c) = 0xffffffff;
}
else {
CBaseHandle::Set((CBaseHandle *)pCVar9,pIVar11);
}
uVar3 = *(uint *)(this + 0x47c);
}
else {
iVar1 = _V_stricmp(param_1,"!target4");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x480);
if ((((uVar3 != 0xffffffff) &&
(puVar8 = g_pEntityList + (uVar3 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar8 + 8) == uVar3 >> 0xc)) && (*(int *)(puVar8 + 4) != 0)) {
LAB_00812a0b:
piVar6 = (int *)(g_pEntityList + (uVar3 & 0xfff) * 0x10 + 4);
goto LAB_0081287f;
}
pIVar11 = *(IHandleEntity **)(this + 0x460);
pCVar9 = this;
iVar1 = FindNamedTarget(this,pIVar11,param_3);
if (iVar1 == 0) {
*(undefined4 *)(this + 0x480) = 0xffffffff;
}
else {
CBaseHandle::Set((CBaseHandle *)pCVar9,pIVar11);
}
uVar3 = *(uint *)(this + 0x480);
}
else {
iVar1 = _V_stricmp(param_1,"!target5");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x484);
if (((uVar3 != 0xffffffff) &&
(puVar8 = g_pEntityList + (uVar3 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc)) &&
((*(uint *)(puVar8 + 8) == uVar3 >> 0xc && (*(int *)(puVar8 + 4) != 0))))
goto LAB_00812a0b;
pIVar11 = *(IHandleEntity **)(this + 0x464);
pCVar9 = this;
iVar1 = FindNamedTarget(this,pIVar11,param_3);
if (iVar1 == 0) {
*(undefined4 *)(this + 0x484) = 0xffffffff;
}
else {
CBaseHandle::Set((CBaseHandle *)pCVar9,pIVar11);
}
uVar3 = *(uint *)(this + 0x484);
}
else {
iVar1 = _V_stricmp(param_1,"!target6");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x488);
if (((uVar3 != 0xffffffff) &&
(puVar8 = g_pEntityList + (uVar3 & 0xfff) * 0x10, puVar8 != (undefined *)0xfffffffc))
&& ((*(uint *)(puVar8 + 8) == uVar3 >> 0xc && (*(int *)(puVar8 + 4) != 0))))
goto LAB_00812a0b;
pIVar11 = *(IHandleEntity **)(this + 0x468);
pCVar9 = this;
iVar1 = FindNamedTarget(this,pIVar11,param_3);
if (iVar1 == 0) {
*(undefined4 *)(this + 0x488) = 0xffffffff;
}
else {
CBaseHandle::Set((CBaseHandle *)pCVar9,pIVar11);
}
uVar3 = *(uint *)(this + 0x488);
}
else {
iVar1 = _V_stricmp(param_1,"!target7");
if (iVar1 == 0) {
uVar3 = *(uint *)(this + 0x48c);
if (uVar3 != 0xffffffff) {
uVar7 = uVar3 & 0xfff;
piVar6 = (int *)(g_pEntityList + uVar7 * 0x10 + 4);
if (((piVar6 != (int *)0x0) &&
(*(uint *)(g_pEntityList + uVar7 * 0x10 + 8) == uVar3 >> 0xc)) &&
(*(int *)(g_pEntityList + uVar7 * 0x10 + 4) != 0)) goto LAB_0081287f;
}
pIVar11 = *(IHandleEntity **)(this + 0x46c);
pCVar9 = this;
iVar1 = FindNamedTarget(this,pIVar11,param_3);
if (iVar1 == 0) {
*(undefined4 *)(this + 0x48c) = 0xffffffff;
}
else {
CBaseHandle::Set((CBaseHandle *)pCVar9,pIVar11);
}
uVar3 = *(uint *)(this + 0x48c);
}
else {
pcVar10 = "!target8";
iVar1 = _V_stricmp(param_1,"!target8");
if (iVar1 != 0) {
if ((param_2 == (CBaseEntity *)0x0) ||
(iVar1 = CBaseEntity::MyNPCPointer(), iVar1 == 0)) {
iVar1 = 0;
pCVar5 = (CBaseEntity *)0x0;
do {
pCVar5 = (CBaseEntity *)
CGlobalEntityList::FindEntityByName
((CGlobalEntityList *)gEntList,pCVar5,param_1,
(CBaseEntity *)0x0,param_2,(CBaseEntity *)0x0,
(IEntityFindFilter *)0x0);
if (pCVar5 == (CBaseEntity *)0x0) {
if (iVar1 == 0) goto LAB_008125fa;
break;
}
aiStack_9c[iVar1] = (int)pCVar5;
iVar1 = iVar1 + 1;
} while (iVar1 != 0x20);
iVar1 = RandomInt(0,iVar1 + -1);
iVar1 = aiStack_9c[iVar1];
}
else if (param_4) {
this_00 = (CBaseHandle *)0xc;
piVar6 = ::operator_new(0xc);
*piVar6 = (int)&PTR_ShouldFindEntity_00cccc78;
piVar6[1] = -1;
piVar6[2] = -1;
CBaseHandle::Set(this_00,(IHandleEntity *)pcVar10);
piVar4 = (int *)CBaseEntity::MyNPCPointer();
iVar1 = (**(code **)(*piVar4 + 0x8cc))(piVar4,param_1,piVar6);
if (iVar1 != 0) {
return iVar1;
}
iVar1 = (**(code **)(*piVar6 + 4))(piVar6);
}
else {
piVar6 = (int *)CBaseEntity::MyNPCPointer();
iVar1 = (**(code **)(*piVar6 + 0x8cc))(piVar6,param_1,0);
}
goto LAB_008126d5;
}
uVar3 = *(uint *)(this + 0x490);
if (uVar3 != 0xffffffff) {
uVar7 = uVar3 & 0xfff;
piVar6 = (int *)(g_pEntityList + uVar7 * 0x10 + 4);
if (((piVar6 != (int *)0x0) &&
(*(uint *)(g_pEntityList + uVar7 * 0x10 + 8) == uVar3 >> 0xc)) &&
(*(int *)(g_pEntityList + uVar7 * 0x10 + 4) != 0)) goto LAB_0081287f;
}
pIVar11 = *(IHandleEntity **)(this + 0x470);
pCVar9 = this;
iVar1 = FindNamedTarget(this,pIVar11,param_3);
if (iVar1 == 0) {
*(undefined4 *)(this + 0x490) = 0xffffffff;
}
else {
CBaseHandle::Set((CBaseHandle *)pCVar9,pIVar11);
}
uVar3 = *(uint *)(this + 0x490);
}
}
}
}
}
if (uVar3 == 0xffffffff) {
return 0;
}
piVar6 = (int *)(g_pEntityList + (uVar3 & 0xfff) * 0x10 + 4);
if (piVar6 == (int *)0x0) {
return 0;
}
LAB_0081287f:
if (piVar6[1] == uVar3 >> 0xc) {
return *piVar6;
}
return 0;
}
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.