CDirectorScavengeMode::SpawnAllScavengeItemsNonVirtual
0x008b44d0 · 1106 bytes · __thiscall
_ZN21CDirectorScavengeMode31SpawnAllScavengeItemsNonVirtualEv
Decompiled
undefined (1 param)
/* CDirectorScavengeMode::SpawnAllScavengeItemsNonVirtual() */
int __thiscall CDirectorScavengeMode::SpawnAllScavengeItemsNonVirtual(CDirectorScavengeMode *this)
{
CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>> *this_00;
int iVar1;
float fVar2;
CBaseEntity CVar3;
uint uVar4;
undefined4 uVar5;
char cVar6;
CBaseEntity *pCVar7;
undefined4 *puVar8;
int iVar9;
undefined *puVar10;
CUtlMemory<CHandle<CBaseEntity>,int> *this_01;
int iVar11;
CBaseEntity *this_02;
undefined4 *puVar12;
int iVar13;
float fVar14;
int local_4c;
int local_48;
int local_44;
float local_40;
undefined4 local_34;
void *local_30;
undefined4 local_2c;
undefined4 local_28;
size_t local_24;
void *local_20;
cVar6 = CTerrorGameRules::IsScavengeMode();
if ((cVar6 == '\0') ||
(cVar6 = CDirectorChallengeMode::SingleScavengeCluster
(*(CDirectorChallengeMode **)(TheDirector + 0x648)), cVar6 == '\0')) {
return 0;
}
pCVar7 = (CBaseEntity *)
CGlobalEntityList::FindEntityByClassname
((CGlobalEntityList *)gEntList,(CBaseEntity *)0x0,"point_prop_use_target");
if (pCVar7 != (CBaseEntity *)0x0) {
if (((byte)pCVar7[0x14d] & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar7);
}
*(undefined4 *)(this + 0x54) = *(undefined4 *)(pCVar7 + 0x2e0);
*(undefined4 *)(this + 0x58) = *(undefined4 *)(pCVar7 + 0x2e4);
*(undefined4 *)(this + 0x5c) = *(undefined4 *)(pCVar7 + 0x2e8);
}
local_30 = (void *)0x0;
pCVar7 = (CBaseEntity *)0x0;
local_2c = 0;
local_28 = 0;
local_24 = 0;
local_20 = (void *)0x0;
local_4c = 0;
while (pCVar7 = (CBaseEntity *)
CGlobalEntityList::FindEntityByClassname
((CGlobalEntityList *)gEntList,pCVar7,"weapon_scavenge_item_spawn"),
pCVar7 != (CBaseEntity *)0x0) {
local_4c = local_4c + 1;
local_34 = 0xffffffff;
/* try { // try from 008b45b0 to 008b4905 has its CatchHandler @ 008b4933 */
puVar8 = (undefined4 *)(**(code **)(*(int *)pCVar7 + 0xc))(pCVar7);
local_34 = *puVar8;
CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>::InsertBefore
((CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>> *)&local_30,
local_24,(CHandle *)&local_34);
}
if (1 < (int)local_24) {
if (local_30 == (void *)0x0) {
local_40 = (float)(local_24 - 1);
do {
if (0 < (int)local_40) {
iVar13 = 0;
iVar11 = 1;
do {
while( true ) {
iVar1 = iVar11 * 4;
iVar9 = ScavengeClusterDistanceSort
((CHandle *)((int)local_30 + iVar13),
(CHandle *)((int)local_30 + iVar1));
if (-1 < iVar9) break;
iVar11 = iVar11 + 1;
puVar12 = (undefined4 *)(iVar1 + (int)local_30);
puVar8 = (undefined4 *)((int)local_30 + iVar13);
iVar13 = iVar13 + 4;
uVar5 = *puVar8;
*puVar8 = *puVar12;
*puVar12 = uVar5;
if ((int)local_40 < iVar11) goto LAB_008b4924;
}
iVar11 = iVar11 + 1;
iVar13 = iVar13 + 4;
} while (iVar11 <= (int)local_40);
}
LAB_008b4924:
local_40 = (float)((int)local_40 + -1);
} while (local_40 != -NAN);
}
else {
qsort(local_30,local_24,4,ScavengeClusterDistanceSort);
}
}
fVar2 = *(float *)(scavenge_cluster_range_squared._28_4_ + 0x2c);
iVar11 = *(int *)(this + 0x38) + -1;
if (-1 < iVar11) {
iVar13 = iVar11 * 0x14;
do {
iVar11 = iVar11 + -1;
this_01 = (CUtlMemory<CHandle<CBaseEntity>,int> *)(*(int *)(this + 0x2c) + iVar13);
iVar13 = iVar13 + -0x14;
*(undefined4 *)(this_01 + 0xc) = 0;
CUtlMemory<CHandle<CBaseEntity>,int>::Purge(this_01);
*(undefined4 *)(this_01 + 0x10) = *(undefined4 *)this_01;
CUtlMemory<CHandle<CBaseEntity>,int>::Purge(this_01);
} while (iVar11 != -1);
}
*(undefined4 *)(this + 0x38) = 0;
if ((int)local_24 < 1) {
LAB_008b4866:
*(undefined4 *)(this + 0x60) = 0xffffffff;
if (*(char *)(TheDirector + 0x4e5) == '\0') {
*(undefined4 *)(this + 0x4c) = 0;
*(undefined4 *)(this + 100) = 0;
}
SpawnNextScavengeCluster(this);
local_24 = 0;
CUtlMemory<CHandle<CBaseEntity>,int>::Purge((CUtlMemory<CHandle<CBaseEntity>,int> *)&local_30);
local_20 = local_30;
CUtlMemory<CHandle<CBaseEntity>,int>::Purge((CUtlMemory<CHandle<CBaseEntity>,int> *)&local_30);
return local_4c;
}
local_48 = 0;
iVar11 = 0;
do {
pCVar7 = (CBaseEntity *)0x0;
uVar4 = *(uint *)((int)local_30 + local_48 * 4);
if (((uVar4 != 0xffffffff) &&
(puVar10 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar10 + 8) == uVar4 >> 0xc)) {
pCVar7 = *(CBaseEntity **)(puVar10 + 4);
}
if (iVar11 < 1) {
LAB_008b4838:
local_44 = CUtlVector<CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>,CUtlMemory<CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>,int>>
::InsertBefore((CUtlVector<CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>,CUtlMemory<CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>,int>>
*)(this + 0x2c),iVar11);
local_34 = 0xffffffff;
if (pCVar7 != (CBaseEntity *)0x0) {
puVar8 = (undefined4 *)(**(code **)(*(int *)pCVar7 + 0xc))(pCVar7);
local_34 = *puVar8;
}
}
else {
iVar13 = 0;
local_44 = -1;
local_40 = fVar2;
do {
this_02 = (CBaseEntity *)0x0;
uVar4 = **(uint **)(iVar13 * 0x14 + *(int *)(this + 0x2c));
if (((uVar4 != 0xffffffff) &&
(puVar10 = g_pEntityList + (uVar4 & 0xfff) * 0x10, puVar10 != (undefined *)0xfffffffc))
&& (*(uint *)(puVar10 + 8) == uVar4 >> 0xc)) {
this_02 = *(CBaseEntity **)(puVar10 + 4);
}
if (((byte)this_02[0x14d] & 8) == 0) {
CVar3 = pCVar7[0x14d];
}
else {
CBaseEntity::CalcAbsolutePosition(this_02);
CVar3 = pCVar7[0x14d];
}
if (((byte)CVar3 & 8) != 0) {
CBaseEntity::CalcAbsolutePosition(pCVar7);
}
fVar14 = (*(float *)(pCVar7 + 0x2e8) - *(float *)(this_02 + 0x2e8)) *
(*(float *)(pCVar7 + 0x2e8) - *(float *)(this_02 + 0x2e8)) +
(*(float *)(pCVar7 + 0x2e0) - *(float *)(this_02 + 0x2e0)) *
(*(float *)(pCVar7 + 0x2e0) - *(float *)(this_02 + 0x2e0)) +
(*(float *)(pCVar7 + 0x2e4) - *(float *)(this_02 + 0x2e4)) *
(*(float *)(pCVar7 + 0x2e4) - *(float *)(this_02 + 0x2e4));
if (fVar14 < local_40) {
local_44 = iVar13;
local_40 = fVar14;
}
iVar13 = iVar13 + 1;
iVar11 = *(int *)(this + 0x38);
} while (iVar13 < iVar11);
if (local_44 == -1) goto LAB_008b4838;
local_34 = 0xffffffff;
puVar8 = (undefined4 *)(**(code **)(*(int *)pCVar7 + 0xc))(pCVar7);
local_34 = *puVar8;
}
this_00 = (CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>> *)
(*(int *)(this + 0x2c) + local_44 * 0x14);
CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>::InsertBefore
(this_00,*(int *)(this_00 + 0xc),(CHandle *)&local_34);
local_48 = local_48 + 1;
if ((int)local_24 <= local_48) goto LAB_008b4866;
iVar11 = *(int *)(this + 0x38);
} while( true );
}
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.