TerrorNavMesh::ComputeFlowDistances
0x00983ba0 · 2354 bytes · __thiscall
_ZN13TerrorNavMesh20ComputeFlowDistancesEv
Decompiled
undefined (1 param)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* TerrorNavMesh::ComputeFlowDistances() */
int __thiscall TerrorNavMesh::ComputeFlowDistances(TerrorNavMesh *this)
{
uint *puVar1;
uint uVar2;
char cVar3;
int iVar4;
CBaseEntity *pCVar5;
int iVar6;
CNavArea *pCVar7;
int *piVar8;
uint uVar9;
int iVar10;
float fVar11;
double dVar12;
double dVar13;
double dVar14;
undefined4 uVar15;
CNavArea *local_98;
CUtlMemory<TerrorNavArea*,int> *local_94;
CUtlMemory<TerrorNavArea*,int> *local_90;
int local_84;
TerrorNavArea *local_80;
undefined4 local_7c;
undefined4 local_78;
undefined4 local_74;
undefined4 local_70;
int local_6c;
undefined4 local_68;
undefined4 local_64;
undefined4 local_60;
undefined4 local_5c;
undefined4 local_58;
undefined4 local_54;
float local_50;
float local_4c;
float local_48;
int *local_44;
undefined4 local_40;
undefined4 local_3c;
int local_38;
int *local_34;
int local_30 [8];
local_7c = 0;
local_78 = 0;
if (_towlower == 0) {
local_6c = 0;
}
else {
(**(code **)(_towlower + 0x50))
(_towlower,&local_7c,0,0,0,0,"/data/src/game/server/terror/terrornav.cpp",0xe15,
&ComputeFlowDistances()::tm_fmt,"(%s)%s","ZOMBIE",
"TerrorNavMesh::ComputeFlowDistances");
local_6c = _towlower;
}
iVar4 = _DAT_0105db00;
local_74 = local_7c;
local_70 = local_78;
/* try { // try from 00983de6 to 00983e46 has its CatchHandler @ 0098453e */
if (((_DAT_0105d154 != 0) || (DAT_0105d158 == '\0')) &&
(iVar10 = ThreadGetCurrentId(), iVar4 == iVar10)) {
if ((char *)*_DAT_0105d15c != "TerrorNavMesh::ComputeFlowDistances") {
_DAT_0105d15c =
(int *)CVProfNode::GetSubNode((char *)_DAT_0105d15c,0xd109b4,(char *)0x0,0xc0db47);
}
puVar1 = (uint *)(_DAT_0105d1e8 + 4 + _DAT_0105d15c[0x1c] * 8);
*puVar1 = *puVar1 | 4;
CVProfNode::EnterScope();
DAT_0105d158 = '\0';
}
/* try { // try from 00983c59 to 00983c62 has its CatchHandler @ 00984542 */
ProcessBreakables(this);
iVar4 = GetWorldEntity();
local_68 = *(undefined4 *)(iVar4 + 0x448);
local_44 = (int *)0x0;
local_40 = 0;
local_64 = *(undefined4 *)(iVar4 + 0x44c);
local_3c = 0;
local_60 = *(undefined4 *)(iVar4 + 0x450);
local_38 = 0;
local_5c = *(undefined4 *)(iVar4 + 0x454);
local_34 = (int *)0x0;
local_58 = *(undefined4 *)(iVar4 + 0x458);
local_30[0] = 0;
local_54 = *(undefined4 *)(iVar4 + 0x45c);
local_30[1] = 0;
local_30[2] = 0;
local_30[3] = 0;
local_30[4] = 0;
if (0 < DAT_00fe6000) {
iVar4 = 0;
do {
local_80 = *(TerrorNavArea **)(TheNavAreas + iVar4 * 4);
/* try { // try from 00983d3e to 00983da9 has its CatchHandler @ 00984501 */
cVar3 = CNavArea::IsBlocked((CNavArea *)local_80,-1,true);
if (cVar3 == '\0') {
iVar10 = 0;
if (((byte)*(CNavArea *)(local_80 + 0x57) & 0x10) == 0) {
do {
if (iVar10 == 3) {
local_48 = *(float *)(local_80 + 0x28);
local_4c = *(float *)(local_80 + 0x14);
local_50 = *(float *)(local_80 + 4);
}
else if (iVar10 == 1) {
local_48 = *(float *)(local_80 + 0x24);
local_4c = *(float *)(local_80 + 8);
local_50 = *(float *)(local_80 + 0x10);
}
else {
local_50 = *(float *)(local_80 + 4);
local_4c = *(float *)(local_80 + 8);
local_48 = *(float *)(local_80 + 0xc);
}
while( true ) {
cVar3 = IsPointInBox((Vector *)&local_50,(Vector *)&local_68,(Vector *)&local_5c);
if (cVar3 == '\0') goto LAB_00983e58;
iVar10 = iVar10 + 1;
if (iVar10 == 4) goto LAB_00983e80;
if (iVar10 != 2) break;
local_50 = *(float *)(local_80 + 0x10);
local_4c = *(float *)(local_80 + 0x14);
local_48 = *(float *)(local_80 + 0x18);
}
} while( true );
}
LAB_00983e58:
/* try { // try from 00983e58 to 009840ae has its CatchHandler @ 00984501 */
pCVar5 = (CBaseEntity *)GetWorldEntity();
CNavArea::MarkAsBlocked((CNavArea *)local_80,-1,pCVar5,false);
}
LAB_00983e80:
*(undefined4 *)(local_80 + 0x158) = 0xc61c3c00;
uVar2 = *(uint *)(local_80 + 300);
*(undefined4 *)(local_80 + 0x154) = 0xc61c3c00;
uVar9 = uVar2 & 0xfffdffff;
*(uint *)(local_80 + 300) = uVar9;
if ((uVar2 & 0x20) != 0) {
CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>>::InsertBefore
((CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>> *)&local_44,local_38,
&local_80);
uVar9 = *(uint *)(local_80 + 300);
}
if ((uVar9 & 0x8000) != 0) {
/* try { // try from 009841d7 to 009844fb has its CatchHandler @ 00984501 */
CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>>::InsertBefore
((CUtlVector<TerrorNavArea*,CUtlMemory<TerrorNavArea*,int>> *)local_30,local_30[3]
,&local_80);
}
iVar4 = iVar4 + 1;
} while (iVar4 < DAT_00fe6000);
}
iVar4 = local_38;
local_90 = (CUtlMemory<TerrorNavArea*,int> *)&local_44;
local_94 = (CUtlMemory<TerrorNavArea*,int> *)local_30;
*(undefined4 *)(this + 0x5f4) = 0;
*(undefined4 *)(this + 0x5f8) = 0;
if ((*(int *)(ZombieDebug._28_4_ + 0x30) != 0) && (*(int *)(z_spew_areas._28_4_ + 0x30) != 0)) {
ZombieDebugPrint(1,"Battle Stations = %d:\n",local_38);
if (0 < iVar4) {
iVar10 = 0;
do {
iVar6 = local_44[iVar10];
if (iVar6 != 0) {
ZombieDebugPrint(2,"Station: %d(%f %f %f)\n",*(undefined4 *)(iVar6 + 0x8c),
SUB84((double)*(float *)(iVar6 + 0x2c),0),
(int)((ulonglong)(double)*(float *)(iVar6 + 0x2c) >> 0x20),
SUB84((double)*(float *)(iVar6 + 0x30),0),
(int)((ulonglong)(double)*(float *)(iVar6 + 0x30) >> 0x20),
SUB84((double)*(float *)(iVar6 + 0x34),0),
(int)((ulonglong)(double)*(float *)(iVar6 + 0x34) >> 0x20));
}
iVar10 = iVar10 + 1;
} while (iVar10 != iVar4);
}
iVar4 = local_30[3];
ZombieDebugPrint(1,"Rescue Vehicles = %d:\n",local_30[3]);
if (0 < iVar4) {
iVar10 = 0;
do {
iVar6 = *(int *)(local_30[0] + iVar10 * 4);
if (iVar6 != 0) {
ZombieDebugPrint(2,"Vehicle: %d(%f %f %f)\n",*(undefined4 *)(iVar6 + 0x8c),
SUB84((double)*(float *)(iVar6 + 0x2c),0),
(int)((ulonglong)(double)*(float *)(iVar6 + 0x2c) >> 0x20),
SUB84((double)*(float *)(iVar6 + 0x30),0),
(int)((ulonglong)(double)*(float *)(iVar6 + 0x30) >> 0x20),
SUB84((double)*(float *)(iVar6 + 0x34),0),
(int)((ulonglong)(double)*(float *)(iVar6 + 0x34) >> 0x20));
}
iVar10 = iVar10 + 1;
} while (iVar10 != iVar4);
}
}
local_84 = 0;
cVar3 = GetPlayerSpawnPosition(8,&local_50,0,&local_84);
if (cVar3 == '\0') {
if (local_84 == 0) {
LAB_00984365:
ZombieDebugPrint(1,"Flow Error: Failed to spawn player at (%f %f %f), NO starting area!\n",
SUB84((double)local_50,0),(int)((ulonglong)(double)local_50 >> 0x20),
SUB84((double)local_4c,0),(int)((ulonglong)(double)local_4c >> 0x20),
SUB84((double)local_48,0),(int)((ulonglong)(double)local_48 >> 0x20));
}
else {
ZombieDebugPrint(1,"Flow Error: Failed to spawn player at (%f %f %f), in area %d(%f %f %f)!\n"
,SUB84((double)local_50,0),(int)((ulonglong)(double)local_50 >> 0x20),
SUB84((double)local_4c,0),(int)((ulonglong)(double)local_4c >> 0x20),
SUB84((double)local_48,0),(int)((ulonglong)(double)local_48 >> 0x20),
*(undefined4 *)(local_84 + 0x8c),(double)*(float *)(local_84 + 0x2c),
(double)*(float *)(local_84 + 0x30),(double)*(float *)(local_84 + 0x34));
}
}
else {
if (local_84 == 0) goto LAB_00984365;
dVar12 = (double)*(float *)(local_84 + 0x34);
dVar14 = (double)*(float *)(local_84 + 0x30);
dVar13 = (double)*(float *)(local_84 + 0x2c);
uVar15 = *(undefined4 *)(local_84 + 0x8c);
ZombieDebugPrint(1,"Player starting area = %d(%f %f %f)\n",uVar15,SUB84(dVar13,0),
(int)((ulonglong)dVar13 >> 0x20),SUB84(dVar14,0),
(int)((ulonglong)dVar14 >> 0x20),SUB84(dVar12,0),
(int)((ulonglong)dVar12 >> 0x20));
pCVar7 = (CNavArea *)FindGoalArea(this);
*(CNavArea **)(this + 0x608) = pCVar7;
if (pCVar7 == (CNavArea *)0x0) {
ZombieDebugPrint(1,"Flow Error: No goal area found!\n",uVar15,SUB84(dVar13,0),
(int)((ulonglong)dVar13 >> 0x20),SUB84(dVar14,0),
(int)((ulonglong)dVar14 >> 0x20),SUB84(dVar12,0),
(int)((ulonglong)dVar12 >> 0x20));
}
else {
uVar15 = 0;
cVar3 = CNavArea::IsBlocked(pCVar7,-1,false);
if (cVar3 == '\0') {
iVar4 = *(int *)(this + 0x608);
ZombieDebugPrint(1,"Goal area = %d(%f %f %f)\n",*(undefined4 *)(iVar4 + 0x8c),
SUB84((double)*(float *)(iVar4 + 0x2c),0),
(int)((ulonglong)(double)*(float *)(iVar4 + 0x2c) >> 0x20),
SUB84((double)*(float *)(iVar4 + 0x30),0),
(int)((ulonglong)(double)*(float *)(iVar4 + 0x30) >> 0x20),
SUB84((double)*(float *)(iVar4 + 0x34),0),
(int)((ulonglong)(double)*(float *)(iVar4 + 0x34) >> 0x20));
cVar3 = ComputeDirectedFlowDistances(this,0,local_84,*(undefined4 *)(this + 0x608));
if ((cVar3 != '\0') &&
(cVar3 = ComputeDirectedFlowDistances(this,1,local_84,*(undefined4 *)(this + 0x608)),
cVar3 != '\0')) {
if (*(int *)(z_spew_areas._28_4_ + 0x30) != 0) {
SpewUnconnectedAreas();
}
fVar11 = 3.4028235e+38;
*(undefined4 *)(this + 0x5fc) = 0x7f7fffff;
if (0 < local_38) {
piVar8 = local_44;
while( true ) {
if (*(float *)(*piVar8 + 0x154) < fVar11) {
*(float *)(this + 0x5fc) = *(float *)(*piVar8 + 0x154);
}
piVar8 = piVar8 + 1;
if (piVar8 == local_44 + local_38) break;
fVar11 = *(float *)(this + 0x5fc);
}
}
iVar10 = 0;
local_98 = (CNavArea *)&DAT_ffffffff;
*(undefined4 *)(this + 0x604) = 0;
iVar4 = local_84;
if (0 < local_30[3]) {
do {
local_80 = (TerrorNavArea *)0x0;
pCVar7 = *(CNavArea **)(local_30[0] + iVar10 * 4);
SearchSurroundingAreas<RescueVehicleAreaDepth>
(pCVar7,(Vector *)(pCVar7 + 0x2c),(RescueVehicleAreaDepth *)&local_80,-1.0,3
,-1);
if ((int)local_98 < (int)local_80) {
local_98 = (CNavArea *)local_80;
*(undefined4 *)(this + 0x604) = *(undefined4 *)(local_30[0] + iVar10 * 4);
}
iVar10 = iVar10 + 1;
iVar4 = local_84;
} while (iVar10 < local_30[3]);
}
goto LAB_009840b1;
}
if (*(int *)(z_spew_areas._28_4_ + 0x30) != 0) {
SpewUnconnectedAreas();
}
}
else {
ZombieDebugPrint(1,"Flow Error: Goal area is blocked!\n",uVar15,SUB84(dVar13,0),
(int)((ulonglong)dVar13 >> 0x20),SUB84(dVar14,0),
(int)((ulonglong)dVar14 >> 0x20),SUB84(dVar12,0),
(int)((ulonglong)dVar12 >> 0x20));
}
}
}
iVar4 = 0;
LAB_009840b1:
local_30[3] = 0;
CUtlMemory<TerrorNavArea*,int>::Purge(local_94);
local_30[4] = local_30[0];
CUtlMemory<TerrorNavArea*,int>::Purge(local_94);
local_38 = 0;
CUtlMemory<TerrorNavArea*,int>::Purge(local_90);
local_34 = local_44;
CUtlMemory<TerrorNavArea*,int>::Purge(local_90);
iVar10 = _DAT_0105db00;
if (((DAT_0105d158 == '\0') || (_DAT_0105d154 != 0)) &&
(iVar6 = ThreadGetCurrentId(), iVar10 == iVar6)) {
cVar3 = CVProfNode::ExitScope();
if (cVar3 != '\0') {
_DAT_0105d15c = (int *)_DAT_0105d15c[0x19];
}
DAT_0105d158 = _DAT_0105d15c == (int *)0x105d160;
}
if (local_6c != 0) {
(**(code **)(local_6c + 0x54))(local_6c,local_74,local_70,0,0,0);
}
return iVar4;
}
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.