CDirectorItemManager::PopulateItems<CHandle<CBaseEntity>>
0x008ad250 · 701 bytes · __thiscall
_ZN20CDirectorItemManager13PopulateItemsI7CHandleI11CBaseEntityEEEiP10CUtlVectorIP18EntityLocationInfoIT_E10CUtlMemoryIS8_iEEiNS_19population_method_tE
Decompiled
int (4 params)
/* int CDirectorItemManager::PopulateItems<CHandle<CBaseEntity>
>(CUtlVector<EntityLocationInfo<CHandle<CBaseEntity> >*,
CUtlMemory<EntityLocationInfo<CHandle<CBaseEntity> >*, int> >*, int,
CDirectorItemManager::population_method_t) */
int __thiscall
CDirectorItemManager::PopulateItems<CHandle<CBaseEntity>>
(CDirectorItemManager *this,CUtlVector *param_1,int param_2,uint param_4)
{
undefined4 *puVar1;
int *piVar2;
uint uVar3;
undefined4 uVar4;
char *pcVar5;
char cVar6;
char *pcVar7;
int iVar8;
int iVar9;
int iVar10;
undefined *puVar11;
int *piVar12;
int iVar13;
int local_20;
if (*(int *)(director_debug_scavenge_items._28_4_ + 0x30) != 0) {
if (*(int *)(param_1 + 0xc) == 0) {
return 0;
}
uVar3 = *(uint *)(**(int **)param_1 + 0x1c);
pcVar7 = "UNKNOWN";
if ((((uVar3 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar3 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc)) &&
(*(uint *)(puVar11 + 8) == uVar3 >> 0xc)) && (*(int *)(puVar11 + 4) != 0)) {
pcVar5 = *(char **)(*(int *)(puVar11 + 4) + 0x7c);
pcVar7 = "";
if (pcVar5 != (char *)0x0) {
pcVar7 = pcVar5;
}
}
Msg("Attempting to populate %s %d items out of a possible %d \n",pcVar7,param_2,
*(int *)(param_1 + 0xc));
}
iVar8 = *(int *)(param_1 + 0xc);
if (iVar8 != 0) {
if (*(int *)(DirectorMustCreateAllScavengeItems._28_4_ + 0x30) != 0) {
return iVar8;
}
cVar6 = CTerrorGameRules::IsSurvivalMode();
if (((cVar6 == '\0') && (cVar6 = CTerrorGameRules::IsScavengeMode(), cVar6 == '\0')) &&
(0 < param_2)) {
if (param_4 < 2) {
iVar13 = 0;
iVar9 = iVar8 + -1;
if (0 < iVar9) {
do {
iVar10 = RandomInt(iVar13,iVar9);
puVar1 = (undefined4 *)(*(int *)param_1 + iVar13 * 4);
iVar13 = iVar13 + 1;
uVar4 = *puVar1;
*puVar1 = *(undefined4 *)(*(int *)param_1 + iVar10 * 4);
*(undefined4 *)(*(int *)param_1 + iVar10 * 4) = uVar4;
} while (iVar13 != iVar9);
}
}
if (param_4 == 1) {
PopulateItemsAlongFlow<CHandle<CBaseEntity>>(this,param_1,param_2);
}
else {
local_20 = iVar8;
if (param_2 < iVar8) {
local_20 = param_2;
}
iVar9 = local_20 * 4;
if (local_20 < iVar8) {
do {
iVar13 = *(int *)(*(int *)param_1 + iVar9);
iVar10 = iVar13;
do {
uVar3 = *(uint *)(iVar10 + 0x1c);
if ((((uVar3 == 0xffffffff) ||
(puVar11 = g_pEntityList + (uVar3 & 0xfff) * 0x10,
puVar11 == (undefined *)0xfffffffc)) || (*(uint *)(puVar11 + 8) != uVar3 >> 0xc))
|| (*(CBaseEntity **)(puVar11 + 4) == (CBaseEntity *)0x0)) {
iVar10 = *(int *)(iVar10 + 0x18);
}
else {
UTIL_Remove(*(CBaseEntity **)(puVar11 + 4));
*(undefined4 *)(iVar10 + 0x1c) = 0xffffffff;
iVar10 = *(int *)(iVar10 + 0x18);
}
} while ((iVar10 != iVar13) && (iVar10 != 0));
local_20 = local_20 + 1;
iVar9 = iVar9 + 4;
} while (local_20 != iVar8);
}
}
if (0 < *(int *)(param_1 + 0xc)) {
piVar12 = *(int **)param_1;
piVar2 = piVar12 + *(int *)(param_1 + 0xc);
iVar8 = 0;
do {
if (((*piVar12 != 0) && (uVar3 = *(uint *)(*piVar12 + 0x1c), uVar3 != 0xffffffff)) &&
((puVar11 = g_pEntityList + (uVar3 & 0xfff) * 0x10, puVar11 != (undefined *)0xfffffffc
&& ((*(uint *)(puVar11 + 8) == uVar3 >> 0xc && (*(int *)(puVar11 + 4) != 0)))))) {
iVar8 = iVar8 + (uint)((*(uint *)(*(int *)(puVar11 + 4) + 0x14c) & 1) == 0);
}
piVar12 = piVar12 + 1;
} while (piVar12 != piVar2);
return iVar8;
}
}
else {
local_20 = iVar8 + -1;
if (-1 < local_20) {
iVar8 = local_20 * 4;
do {
iVar9 = *(int *)(*(int *)param_1 + iVar8);
iVar13 = iVar9;
do {
uVar3 = *(uint *)(iVar13 + 0x1c);
if (((uVar3 != 0xffffffff) &&
(puVar11 = g_pEntityList + (uVar3 & 0xfff) * 0x10,
puVar11 != (undefined *)0xfffffffc)) &&
((*(uint *)(puVar11 + 8) == uVar3 >> 0xc &&
(*(CBaseEntity **)(puVar11 + 4) != (CBaseEntity *)0x0)))) {
UTIL_Remove(*(CBaseEntity **)(puVar11 + 4));
*(undefined4 *)(iVar13 + 0x1c) = 0xffffffff;
}
iVar13 = *(int *)(iVar13 + 0x18);
} while ((iVar13 != iVar9) && (iVar13 != 0));
local_20 = local_20 + -1;
iVar8 = iVar8 + -4;
} while (local_20 != -1);
}
}
}
return 0;
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
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.
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.