UTIL_LoadAndSpawnEntitiesFromScript
0x00b2f9d0 · 481 bytes · __cdecl
_Z35UTIL_LoadAndSpawnEntitiesFromScriptR10CUtlVectorIP11CBaseEntity10CUtlMemoryIS1_iEEPKcS7_b
Decompiled
undefined (4 params)
/* UTIL_LoadAndSpawnEntitiesFromScript(CUtlVector<CBaseEntity*, CUtlMemory<CBaseEntity*, int> >&,
char const*, char const*, bool) */
char UTIL_LoadAndSpawnEntitiesFromScript
(CUtlVector *param_1,char *param_2,char *param_3,bool param_4)
{
int *piVar1;
char cVar2;
undefined1 uVar3;
KeyValues *pKVar4;
IBaseFileSystem *pIVar5;
char *pcVar6;
KeyValues *this;
int iVar7;
uint in_stack_ffffffb8;
CBaseEntity *local_20 [4];
pKVar4 = KeyValues::operator_new((KeyValues *)0x2c,in_stack_ffffffb8);
/* try { // try from 00b2fa0a to 00b2fa0e has its CatchHandler @ 00b2fbb5 */
KeyValues::KeyValues(pKVar4,param_3,(IKeyValuesSystem *)0x0,false);
pIVar5 = (IBaseFileSystem *)0x0;
if (filesystem != 0) {
pIVar5 = (IBaseFileSystem *)(filesystem + 4);
}
cVar2 = KeyValues::LoadFromFile(pKVar4,pIVar5,param_2,"GAME");
if (cVar2 != '\0') {
for (pKVar4 = (KeyValues *)KeyValues::GetFirstSubKey(pKVar4); pKVar4 != (KeyValues *)0x0;
pKVar4 = (KeyValues *)KeyValues::GetNextKey(pKVar4)) {
pcVar6 = (char *)KeyValues::GetName(pKVar4);
iVar7 = _V_stricmp(pcVar6,"entity");
if (iVar7 == 0) {
this = (KeyValues *)KeyValues::FindKey(pKVar4,"classname",false);
if (this != (KeyValues *)0x0) {
pcVar6 = (char *)KeyValues::GetString(this,(char *)0x0,"");
}
local_20[0] = (CBaseEntity *)CreateEntityByName(pcVar6,-1,true);
if (local_20[0] == (CBaseEntity *)0x0) {
Warning("UTIL_LoadAndSpawnEntitiesFromScript: Failed to spawn entity, type: \'%s\'\n",
pcVar6);
}
else {
LoadAndSpawnEntities_ParseEntKVBlockHelper(local_20[0],pKVar4);
DispatchSpawn(local_20[0],true);
CUtlVector<CBaseEntity*,CUtlMemory<CBaseEntity*,int>>::InsertBefore
((CUtlVector<CBaseEntity*,CUtlMemory<CBaseEntity*,int>> *)param_1,
*(int *)(param_1 + 0xc),local_20);
}
}
}
if (param_4) {
uVar3 = (**(code **)(*mdlcache + 0x84))(mdlcache,4,0);
if (0 < *(int *)(param_1 + 0xc)) {
iVar7 = 0;
do {
piVar1 = *(int **)(*(int *)param_1 + iVar7 * 4);
iVar7 = iVar7 + 1;
(**(code **)(*piVar1 + 0x94))(piVar1);
} while (iVar7 < *(int *)(param_1 + 0xc));
}
(**(code **)(*mdlcache + 0x84))(mdlcache,4,uVar3);
return cVar2;
}
}
return cVar2;
}
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.