CSurvivorRescue::GetDistanceToNearestSurvivor
0x0096b810 · 807 bytes · __thiscall
_ZN15CSurvivorRescue28GetDistanceToNearestSurvivorEf
Decompiled
undefined (2 params)
/* CSurvivorRescue::GetDistanceToNearestSurvivor(float) */
longdouble __thiscall
CSurvivorRescue::GetDistanceToNearestSurvivor(CSurvivorRescue *this,float param_1)
{
float *pfVar1;
float *pfVar2;
float *pfVar3;
CBaseEntity *this_00;
int iVar4;
int iVar5;
bool bVar6;
CNavArea *pCVar7;
CNavArea *pCVar8;
int iVar9;
float fVar10;
float fVar11;
float fVar12;
float fVar13;
float local_54;
undefined4 local_4c;
float local_48;
float local_44;
float local_40;
float local_3c;
float local_38;
float local_34;
int local_30 [8];
pCVar7 = (CNavArea *)GetRescueNavArea(this);
if (pCVar7 != (CNavArea *)0x0) {
if (((byte)this[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition((CBaseEntity *)this);
}
local_48 = *(float *)(this + 0x2e0);
local_30[0] = 0;
local_30[1] = 0;
local_30[2] = 0;
local_30[3] = 0;
local_44 = *(float *)(this + 0x2e4);
local_30[4] = 0;
local_40 = *(float *)(this + 0x2e8) + 18.0;
/* try { // try from 0096b891 to 0096b93f has its CatchHandler @ 0096bb3c */
ForEachSurvivor<SurvivorCollector>((SurvivorCollector *)local_30);
if (local_30[3] < 1) {
local_54 = -1.0;
}
else {
iVar9 = 0;
local_54 = -1.0;
do {
this_00 = *(CBaseEntity **)(local_30[0] + iVar9 * 4);
fVar11 = local_54;
if (this_00 != (CBaseEntity *)0x0) {
if (((byte)this_00[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(this_00);
}
local_3c = *(float *)(this_00 + 0x2e0);
local_4c = 3;
local_38 = *(float *)(this_00 + 0x2e4);
local_34 = *(float *)(this_00 + 0x2e8);
pCVar8 = (CNavArea *)(**(code **)(*(int *)this_00 + 0x52c))(this_00);
bVar6 = NavAreaBuildPath<SurvivorPathCost>
(pCVar8,pCVar7,(Vector *)&local_3c,(Vector *)&local_48,
(SurvivorPathCost *)&local_4c,(CNavArea **)0x0,param_1,2,false);
if (bVar6) {
iVar4 = *(int *)(pCVar7 + 0x78);
if (iVar4 == 0) {
fVar11 = SQRT((local_44 - local_38) * (local_44 - local_38) +
(local_40 - local_34) * (local_40 - local_34) +
(local_48 - local_3c) * (local_48 - local_3c));
}
else {
fVar11 = local_48 - *(float *)(iVar4 + 0x2c);
fVar12 = local_40 - *(float *)(iVar4 + 0x34);
fVar13 = local_44 - *(float *)(iVar4 + 0x30);
fVar11 = SQRT(fVar12 * fVar12 + fVar11 * fVar11 + fVar13 * fVar13);
fVar12 = *(float *)(iVar4 + 0x2c);
fVar13 = *(float *)(iVar4 + 0x34);
fVar10 = *(float *)(iVar4 + 0x30);
for (iVar5 = *(int *)(iVar4 + 0x78); iVar5 != 0; iVar5 = *(int *)(iVar5 + 0x78)) {
pfVar1 = (float *)(iVar5 + 0x2c);
pfVar2 = (float *)(iVar5 + 0x34);
fVar12 = fVar12 - *pfVar1;
pfVar3 = (float *)(iVar5 + 0x30);
fVar13 = fVar13 - *pfVar2;
fVar10 = fVar10 - *pfVar3;
fVar11 = fVar11 + SQRT(fVar13 * fVar13 + fVar12 * fVar12 + fVar10 * fVar10);
fVar12 = *pfVar1;
fVar13 = *pfVar2;
fVar10 = *pfVar3;
}
fVar11 = SQRT((local_38 - fVar10) * (local_38 - fVar10) +
(local_34 - fVar13) * (local_34 - fVar13) +
(local_3c - fVar12) * (local_3c - fVar12)) + fVar11;
}
if (local_54 <= fVar11) {
fVar11 = (float)(~-(uint)(local_54 < 0.0) & (uint)local_54 |
(uint)fVar11 & -(uint)(local_54 < 0.0));
}
}
}
local_54 = fVar11;
iVar9 = iVar9 + 1;
} while (iVar9 < local_30[3]);
}
local_30[3] = 0;
CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_30);
local_30[4] = local_30[0];
CUtlMemory<CTerrorPlayer*,int>::Purge((CUtlMemory<CTerrorPlayer*,int> *)local_30);
return (longdouble)local_54;
}
return (longdouble)-1.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.