CVEngineServer::BuildEntityClusterList
0x0022a200 · 1234 bytes · __thiscall
_ZN14CVEngineServer22BuildEntityClusterListEP7edict_tP9PVSInfo_t
Decompiled
undefined (3 params)
/* CVEngineServer::BuildEntityClusterList(edict_t*, PVSInfo_t*) */
void __thiscall
CVEngineServer::BuildEntityClusterList(CVEngineServer *this,edict_t *param_1,PVSInfo_t *param_2)
{
short sVar1;
undefined4 *puVar2;
bool bVar3;
int *piVar4;
int iVar5;
int iVar6;
int iVar7;
int iVar8;
undefined4 *local_454;
int local_444;
float local_440;
float local_43c;
float local_438;
float local_434;
float local_430;
float local_42c;
float local_428;
float local_424;
float local_420;
int local_41c [128];
int local_21c [131];
(**(code **)(*(int *)this + 0x19c))(this,param_2);
*(undefined4 *)(param_2 + 4) = 0;
*(undefined2 *)(param_2 + 2) = 0;
*(undefined2 *)(param_2 + 8) = 0;
*(undefined2 *)(param_2 + 10) = 0;
if ((((param_1 != (edict_t *)0x0) && (((byte)*param_1 & 4) != 0)) &&
(piVar4 = *(int **)(param_1 + 0xc), piVar4 != (int *)0x0)) &&
(piVar4 = (int *)(**(code **)(*piVar4 + 0x10))(piVar4), piVar4 != (int *)0x0)) {
local_444 = -1;
(**(code **)(*piVar4 + 0x3c))(piVar4,(Vector *)&local_440);
iVar5 = CM_BoxLeafnums((Vector *)&local_440,(Vector *)&local_434,local_41c,0x80,&local_444);
bVar3 = false;
if (0 < iVar5) {
iVar8 = 0;
do {
while( true ) {
iVar6 = CM_LeafCluster(local_41c[iVar8]);
local_21c[iVar8] = iVar6;
iVar6 = CM_LeafArea(local_41c[iVar8]);
if (iVar6 != 0) break;
LAB_0022a324:
iVar8 = iVar8 + 1;
if (iVar8 == iVar5) goto LAB_0022a36a;
}
if ((*(short *)(param_2 + 8) != 0) && (iVar6 != *(short *)(param_2 + 8))) {
if (((!bVar3) && ((*(short *)(param_2 + 10) != 0 && (iVar6 != *(short *)(param_2 + 10)))))
&& (bVar3 = true, DAT_003b7f64 == 1)) {
ConDMsg("Object touching 3 areas at %f %f %f\n",(double)local_440,(double)local_43c,
(double)local_438);
}
*(short *)(param_2 + 10) = (short)iVar6;
goto LAB_0022a324;
}
iVar8 = iVar8 + 1;
*(short *)(param_2 + 8) = (short)iVar6;
} while (iVar8 != iVar5);
}
LAB_0022a36a:
local_428 = (local_434 + local_440) * 0.5;
local_424 = (local_430 + local_43c) * 0.5;
local_420 = (local_42c + local_438) * 0.5;
if (bVar3) {
iVar8 = CM_PointLeafnum((Vector *)&local_428);
iVar8 = CM_LeafArea(iVar8);
if ((iVar8 != *(short *)(param_2 + 8)) && (iVar8 != *(short *)(param_2 + 10))) {
*(short *)(param_2 + 8) = (short)iVar8;
}
}
*(float *)(param_2 + 0xc) = local_428;
*(short *)param_2 = (short)local_444;
*(float *)(param_2 + 0x10) = local_424;
*(float *)(param_2 + 0x14) = local_420;
if (0x7f < iVar5) goto LAB_0022a4c7;
*(PVSInfo_t **)(param_2 + 4) = param_2 + 0x18;
if (iVar5 < 0x10) {
iVar8 = 0;
if (0 < iVar5) {
do {
iVar6 = local_21c[iVar8];
if (iVar6 != -1) {
if (iVar8 == 0) {
sVar1 = *(short *)(param_2 + 2);
iVar7 = 0;
joined_r0x0022a582:
if (sVar1 == 4) {
local_454 = (undefined4 *)
CUtlMemoryPool::Alloc((CUtlMemoryPool *)s_PVSInfoAllocator);
puVar2 = *(undefined4 **)(param_2 + 4);
*local_454 = *puVar2;
local_454[1] = puVar2[1];
sVar1 = *(short *)(param_2 + 2);
*(undefined4 **)(param_2 + 4) = local_454;
}
else {
if (sVar1 == 0x40) goto LAB_0022a4a7;
local_454 = *(undefined4 **)(param_2 + 4);
}
*(short *)(param_2 + 2) = sVar1 + 1;
*(short *)((int)local_454 + sVar1 * 2) = (short)local_21c[iVar7];
}
else if (iVar6 != local_21c[0]) {
iVar7 = 0;
do {
iVar7 = iVar7 + 1;
if (iVar7 == iVar8) {
sVar1 = *(short *)(param_2 + 2);
goto joined_r0x0022a582;
}
} while (iVar6 != local_21c[iVar7]);
}
}
iVar8 = iVar8 + 1;
} while (iVar8 != iVar5);
}
}
else {
piVar4 = local_21c + iVar5;
iVar8 = (int)piVar4 - (int)local_21c;
if (7 < iVar8) {
iVar8 = iVar8 >> 2;
for (iVar6 = iVar8 + -2 >> 1;
std::__adjust_heap<int*,int,int,bool(*)(int_const&,int_const&)>
(local_21c,iVar6,iVar8,local_21c[iVar6],SortClusterLessFunc), iVar6 != 0;
iVar6 = iVar6 + -1) {
}
do {
piVar4 = piVar4 + -1;
iVar8 = *piVar4;
iVar6 = (int)piVar4 - (int)local_21c;
*piVar4 = local_21c[0];
std::__adjust_heap<int*,int,int,bool(*)(int_const&,int_const&)>
(local_21c,0,iVar6 >> 2,iVar8,SortClusterLessFunc);
} while (7 < iVar6);
}
iVar8 = 0;
do {
iVar6 = local_21c[iVar8];
if ((iVar6 != -1) && ((iVar8 == 0 || (iVar6 != local_21c[iVar8 + -1])))) {
sVar1 = *(short *)(param_2 + 2);
if (sVar1 == 4) {
local_454 = (undefined4 *)CUtlMemoryPool::Alloc((CUtlMemoryPool *)s_PVSInfoAllocator);
puVar2 = *(undefined4 **)(param_2 + 4);
*local_454 = *puVar2;
local_454[1] = puVar2[1];
sVar1 = *(short *)(param_2 + 2);
*(undefined4 **)(param_2 + 4) = local_454;
iVar6 = local_21c[iVar8];
}
else {
if (sVar1 == 0x40) goto LAB_0022a4a7;
local_454 = *(undefined4 **)(param_2 + 4);
}
*(short *)(param_2 + 2) = sVar1 + 1;
*(short *)((int)local_454 + sVar1 * 2) = (short)iVar6;
}
iVar8 = iVar8 + 1;
} while (iVar8 != iVar5);
}
}
return;
LAB_0022a4a7:
CUtlMemoryPool::Free((CUtlMemoryPool *)s_PVSInfoAllocator,*(void **)(param_2 + 4));
*(undefined4 *)(param_2 + 4) = 0;
LAB_0022a4c7:
*(undefined2 *)(param_2 + 2) = 0xffff;
return;
}
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.