CEntitySaveRestoreBlockHandler::Restore
0x004ab2c0 · 790 bytes · __thiscall
_ZN30CEntitySaveRestoreBlockHandler7RestoreEP8IRestoreb
Decompiled
undefined (3 params)
/* CEntitySaveRestoreBlockHandler::Restore(IRestore*, bool) */
void __thiscall
CEntitySaveRestoreBlockHandler::Restore
(CEntitySaveRestoreBlockHandler *this,IRestore *param_1,bool param_2)
{
char cVar1;
int iVar2;
CBaseEntity *pCVar3;
undefined4 *puVar4;
char *pcVar5;
int iVar6;
undefined *puVar7;
uint uVar8;
edict_t *peVar9;
int iVar10;
int iVar11;
iVar11 = 0;
iVar2 = (**(code **)(*(int *)param_1 + 0x9c))(param_1);
if (0 < *(int *)(iVar2 + 0x55c)) {
do {
while( true ) {
iVar10 = iVar11 * 0x38 + *(int *)(iVar2 + 0x560);
pcVar5 = *(char **)(iVar10 + 0x20);
if (((pcVar5 != (char *)0x0) && (*(int *)(iVar10 + 0x18) != 0)) &&
((*(uint *)(iVar10 + 0x1c) & 0x40000000) == 0)) break;
LAB_004ab3e5:
*(undefined4 *)(iVar10 + 0x10) = 0xffffffff;
iVar11 = iVar11 + 1;
*(undefined4 *)(iVar10 + 0xc) = 0xffffffff;
iVar10 = *(int *)(iVar2 + 0x55c);
if (iVar10 <= iVar11) goto LAB_004ab403;
}
uVar8 = *(uint *)(iVar10 + 4);
if (uVar8 == 0) {
pCVar3 = (CBaseEntity *)CreateEntityByName(pcVar5,-1,true);
(**(code **)(*(int *)param_1 + 4))(param_1,*(undefined4 *)(iVar10 + 0x14));
iVar6 = RestoreEntity((CBaseEntity *)this,(IRestore *)pCVar3,(entitytable_t *)param_1);
if (iVar6 < 0) {
*(undefined4 *)(iVar10 + 0x10) = 0xffffffff;
*(undefined4 *)(iVar10 + 0xc) = 0xffffffff;
UTIL_RemoveImmediate(pCVar3);
}
else {
AddRestoredEntity(pCVar3);
}
}
else if (((int)uVar8 < 1) || (*(int *)(gpGlobals + 0x14) < (int)uVar8)) {
pCVar3 = (CBaseEntity *)CreateEntityByName(pcVar5,-1,true);
}
else {
if (-1 < (int)*(uint *)(iVar10 + 0x1c)) {
Warning("ENTITY IS NOT A PLAYER: %d\n",iVar11);
uVar8 = *(uint *)(iVar10 + 4);
}
if (((0x7ff < uVar8) || (*(int *)(gpGlobals + 0x58) == 0)) ||
((peVar9 = (edict_t *)(uVar8 * 0x10 + *(int *)(gpGlobals + 0x58)),
((byte)*peVar9 & 2) != 0 || (!param_2)))) goto LAB_004ab3e5;
pcVar5 = *(char **)(iVar10 + 0x20);
if (pcVar5 == (char *)0x0) {
pcVar5 = "";
}
pCVar3 = (CBaseEntity *)CBasePlayer::CreatePlayer(pcVar5,peVar9);
}
if (pCVar3 == (CBaseEntity *)0x0) goto LAB_004ab3e5;
puVar4 = (undefined4 *)(**(code **)(*(int *)pCVar3 + 0xc))(pCVar3);
*(undefined4 *)(iVar10 + 0x10) = *puVar4;
if (*(int *)(pCVar3 + 0x30) == 0) {
*(undefined4 *)(iVar10 + 0xc) = 0;
LAB_004ab517:
if ((*(char **)(pCVar3 + 0x7c) != "worldspawn") &&
(cVar1 = CBaseEntity::ClassMatchesComplex(pCVar3,"worldspawn"), cVar1 == '\0')) {
*(undefined4 *)(iVar10 + 0xc) = 0xffffffff;
}
}
else {
iVar6 = *(int *)(pCVar3 + 0x30) - *(int *)(gpGlobals + 0x58) >> 4;
*(int *)(iVar10 + 0xc) = iVar6;
if (iVar6 == 0) goto LAB_004ab517;
}
iVar11 = iVar11 + 1;
iVar10 = *(int *)(iVar2 + 0x55c);
} while (iVar11 < iVar10);
LAB_004ab403:
if (0 < iVar10) {
iVar11 = 0;
do {
iVar10 = iVar11 * 0x38 + *(int *)(iVar2 + 0x560);
if (*(int *)(iVar10 + 4) != 0) {
uVar8 = *(uint *)(iVar10 + 0x10);
if (((uVar8 == 0xffffffff) ||
(puVar7 = g_pEntityList + (uVar8 & 0xfff) * 0x10, puVar7 == (undefined *)0xfffffffc))
|| (*(uint *)(puVar7 + 8) != uVar8 >> 0xc)) {
(**(code **)(*(int *)param_1 + 4))(param_1,*(undefined4 *)(iVar10 + 0x14));
}
else {
pCVar3 = *(CBaseEntity **)(puVar7 + 4);
(**(code **)(*(int *)param_1 + 4))(param_1,*(undefined4 *)(iVar10 + 0x14));
if (pCVar3 != (CBaseEntity *)0x0) {
iVar6 = RestoreEntity((CBaseEntity *)this,(IRestore *)pCVar3,(entitytable_t *)param_1)
;
if (iVar6 < 0) {
*(undefined4 *)(iVar10 + 0x10) = 0xffffffff;
*(undefined4 *)(iVar10 + 0xc) = 0xffffffff;
UTIL_RemoveImmediate(pCVar3);
}
else {
AddRestoredEntity(pCVar3);
}
}
}
}
iVar11 = iVar11 + 1;
} while (iVar11 < *(int *)(iVar2 + 0x55c));
}
}
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.