CWatcherList::AddToList
0x00478140 · 721 bytes · __thiscall
_ZN12CWatcherList9AddToListEP11CBaseEntity
Decompiled
undefined (2 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CWatcherList::AddToList(CBaseEntity*) */
void __thiscall CWatcherList::AddToList(CWatcherList *this,CBaseEntity *param_1)
{
short *psVar1;
ushort uVar2;
ushort uVar3;
undefined4 uVar4;
int iVar5;
void *pvVar6;
short sVar7;
undefined4 *puVar8;
int iVar9;
uint uVar10;
ushort uVar11;
int iVar12;
uint uVar13;
uint local_28;
sVar7 = Find(this,param_1);
if (sVar7 != -1) {
return;
}
if (param_1 == (CBaseEntity *)0x0) {
return;
}
puVar8 = (undefined4 *)(**(code **)(*(int *)param_1 + 0xc))(param_1);
uVar4 = *puVar8;
iVar9 = __dynamic_cast(param_1,&CBaseEntity::typeinfo,&IWatcherCallback::typeinfo,0xfffffffe);
uVar10 = DAT_00f7e8b0;
uVar11 = _DAT_00f7e8ac;
if (iVar9 == 0) {
return;
}
uVar2 = *(ushort *)this;
local_28 = (uint)_DAT_00f7e8ac;
if (_DAT_00f7e8ac != 0xffff) {
iVar12 = local_28 * 0xc;
puVar8 = (undefined4 *)((int)g_WatcherList + iVar12);
uVar3 = *(ushort *)((int)puVar8 + 10);
*(ushort *)(puVar8 + 2) = _DAT_00f7e8ac;
_DAT_00f7e8ac = uVar3;
*(ushort *)((int)puVar8 + 10) = uVar11;
_DAT_00f7e8ae = _DAT_00f7e8ae + 1;
*puVar8 = 0xffffffff;
goto LAB_004781f4;
}
if ((DAT_00f7e8b0 != (DAT_00f7e8b0 & 0xffff)) || ((short)DAT_00f7e8b0 == -1)) {
if (9 < CUtlMultiList<watcher_t,unsigned_short>::Alloc()::__executeCount) {
return;
}
CUtlMultiList<watcher_t,unsigned_short>::Alloc()::__executeCount =
CUtlMultiList<watcher_t,unsigned_short>::Alloc()::__executeCount + 1;
goto LAB_004782ca;
}
local_28 = DAT_00f7e8b0;
if (DAT_00f7e8b0 != DAT_00f7e884) {
LAB_00478308:
DAT_00f7e8b0 = uVar10 + 1;
iVar12 = local_28 * 0xc;
puVar8 = (undefined4 *)((int)g_WatcherList + iVar12);
uVar11 = (ushort)uVar10;
*(ushort *)(puVar8 + 2) = uVar11;
*(ushort *)((int)puVar8 + 10) = uVar11;
_DAT_00f7e8ae = _DAT_00f7e8ae + 1;
*puVar8 = 0xffffffff;
if (uVar11 == 0xffff) {
return;
}
LAB_004781f4:
CUtlMultiList<watcher_t,unsigned_short>::Unlink
((CUtlMultiList<watcher_t,unsigned_short> *)&g_WatcherList,uVar2,uVar11);
pvVar6 = g_WatcherList;
*(undefined2 *)((int)g_WatcherList + iVar12 + 10) = 0xffff;
iVar5 = (uint)uVar2 * 10;
*(undefined2 *)((int)pvVar6 + iVar12 + 8) = *(undefined2 *)(DAT_00f7e88c + 2 + iVar5);
*(ushort *)(DAT_00f7e88c + 2 + iVar5) = uVar11;
uVar3 = *(ushort *)((int)pvVar6 + iVar12 + 8);
if (uVar3 == 0xffff) {
*(ushort *)(DAT_00f7e88c + iVar5) = uVar11;
}
else {
*(ushort *)((int)g_WatcherList + (uint)uVar3 * 0xc + 10) = uVar11;
}
psVar1 = (short *)(iVar5 + DAT_00f7e88c + 4);
*psVar1 = *psVar1 + 1;
if (DAT_00f7e8a8 != 0) {
*(ushort *)(DAT_00f7e8a8 + local_28 * 2) = uVar2;
}
puVar8 = (undefined4 *)(iVar12 + (int)g_WatcherList);
if (puVar8 == (undefined4 *)0x0) {
return;
}
puVar8[1] = iVar9;
*puVar8 = uVar4;
return;
}
if (DAT_00f7e888 < 0) {
_DAT_00f7e8b4 = g_WatcherList;
}
else {
iVar12 = DAT_00f7e8b0 + 1;
if (DAT_00f7e888 == 0) {
uVar13 = 3;
if (DAT_00f7e8b0 != 0) {
uVar13 = DAT_00f7e8b0;
}
for (; (int)uVar13 < iVar12; uVar13 = uVar13 * 2) {
}
}
else {
for (uVar13 = DAT_00f7e888 * ((int)DAT_00f7e8b0 / DAT_00f7e888 + 1); (int)uVar13 < iVar12;
uVar13 = (int)(uVar13 + iVar12) / 2) {
}
}
DAT_00f7e884 = uVar13;
if (g_WatcherList == (void *)0x0) {
g_WatcherList = malloc(uVar13 * 0xc);
}
else {
g_WatcherList = realloc(g_WatcherList,uVar13 * 0xc);
uVar10 = DAT_00f7e8b0;
uVar13 = DAT_00f7e884;
}
local_28 = uVar10 & 0xffff;
_DAT_00f7e8b4 = g_WatcherList;
if ((int)uVar10 < (int)uVar13) goto LAB_00478308;
}
if (9 < CUtlMultiList<watcher_t,unsigned_short>::Alloc()::__executeCount) {
g_WatcherList = _DAT_00f7e8b4;
return;
}
CUtlMultiList<watcher_t,unsigned_short>::Alloc()::__executeCount =
CUtlMultiList<watcher_t,unsigned_short>::Alloc()::__executeCount + 1;
g_WatcherList = _DAT_00f7e8b4;
LAB_004782ca:
Warning();
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.