Templates_Add
0x0083dd80 · 253 bytes · __cdecl
_Z13Templates_AddP11CBaseEntityPKcii
Decompiled
undefined (4 params)
/* Templates_Add(CBaseEntity*, char const*, int, int) */
undefined4 Templates_Add(CBaseEntity *param_1,char *param_2,int param_3,int param_4)
{
char *pcVar1;
TemplateEntityData_t *pTVar2;
int iVar3;
size_t sVar4;
void *__dest;
undefined4 uVar5;
undefined1 *puVar6;
TemplateEntityData_t *local_20 [4];
pcVar1 = *(char **)(param_1 + 0x154);
if (pcVar1 == (char *)0x0) {
pcVar1 = "";
}
if (*pcVar1 == '\0') {
puVar6 = &DAT_00d539c2;
if (*(undefined1 **)(param_1 + 0x7c) != (undefined1 *)0x0) {
puVar6 = *(undefined1 **)(param_1 + 0x7c);
}
DevWarning(1,"RegisterTemplateEntity: template entity with no name, class %s\n",puVar6);
uVar5 = 0xffffffff;
}
else {
pTVar2 = malloc(0x1c);
*(int *)(pTVar2 + 0x18) = param_4;
local_20[0] = pTVar2;
pcVar1 = strdup(pcVar1);
*(char **)pTVar2 = pcVar1;
iVar3 = MapEntity_GetNumKeysInEntity(param_2);
sVar4 = strlen(ENTITYIO_FIXUP_STRING);
pTVar2 = local_20[0];
sVar4 = param_3 + 1 + iVar3 * (sVar4 + 1);
*(size_t *)(local_20[0] + 0xc) = sVar4;
__dest = malloc(sVar4);
*(void **)(pTVar2 + 4) = __dest;
memcpy(__dest,param_2,param_3 + 1);
*(undefined1 *)(*(int *)(pTVar2 + 4) + param_3) = 0;
*(undefined4 *)(local_20[0] + 8) = 0;
local_20[0][0x10] = (TemplateEntityData_t)0x0;
*(undefined4 *)(local_20[0] + 0x14) = 0;
uVar5 = CUtlVector<TemplateEntityData_t*,CUtlMemory<TemplateEntityData_t*,int>>::InsertBefore
((CUtlVector<TemplateEntityData_t*,CUtlMemory<TemplateEntityData_t*,int>> *)
&g_Templates,DAT_00ffa750,local_20);
}
return uVar5;
}
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.