CCommentarySystem::LoadEntityFile
0x0064ebe0 · 1169 bytes · __thiscall
_ZN17CCommentarySystem14LoadEntityFileEPKc
Decompiled
undefined (2 params)
/* CCommentarySystem::LoadEntityFile(char const*) */
void __thiscall CCommentarySystem::LoadEntityFile(CCommentarySystem *this,char *param_1)
{
code *pcVar1;
char cVar2;
KeyValues *this_00;
KeyValues *pKVar3;
IBaseFileSystem *pIVar4;
char *pcVar5;
KeyValues *pKVar6;
int iVar7;
CBaseEntity *pCVar8;
undefined4 uVar9;
int *piVar10;
undefined1 *puVar11;
int in_GS_OFFSET;
char *pcVar12;
int local_62c;
char local_628 [260];
char local_524 [260];
char local_420 [1024];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (param_1 == (char *)0x0) {
puVar11 = &DAT_00d539c2;
if (*(undefined1 **)(gpGlobals + 0x3c) != (undefined1 *)0x0) {
puVar11 = *(undefined1 **)(gpGlobals + 0x3c);
}
V_snprintf(local_628,0x104,"maps%c%s_entities.txt",0x2f,puVar11);
}
else {
puVar11 = &DAT_00d539c2;
if (*(undefined1 **)(gpGlobals + 0x3c) != (undefined1 *)0x0) {
puVar11 = *(undefined1 **)(gpGlobals + 0x3c);
}
V_snprintf(local_628,0x104,"maps%c%s_entities_%s.txt",0x2f,puVar11,param_1);
}
pcVar12 = local_628;
cVar2 = (**(code **)(*(int *)(g_pFullFileSystem + 4) + 0x28))(g_pFullFileSystem + 4,local_628,0);
pcVar5 = local_628;
if (cVar2 == '\0') {
pcVar5 = local_524;
pcVar12 = "ems%c%s";
V_sprintf_safe<260u>(pcVar5,"ems%c%s",0x2f,local_628);
}
this_00 = KeyValues::operator_new((KeyValues *)0x2c,(uint)pcVar12);
pcVar12 = "EntityFile";
/* try { // try from 0064ecbd to 0064ecc1 has its CatchHandler @ 0064f07c */
KeyValues::KeyValues(this_00,"EntityFile",(IKeyValuesSystem *)0x0,false);
pKVar3 = KeyValues::operator_new((KeyValues *)0x2c,(uint)pcVar12);
/* try { // try from 0064eceb to 0064ecef has its CatchHandler @ 0064f094 */
KeyValues::KeyValues(pKVar3,"Entities",(IKeyValuesSystem *)0x0,false);
KeyValues::AddSubKey(this_00,pKVar3);
pIVar4 = (IBaseFileSystem *)0x0;
if (filesystem != 0) {
pIVar4 = (IBaseFileSystem *)(filesystem + 4);
}
cVar2 = KeyValues::LoadFromFile(pKVar3,pIVar4,pcVar5,"GAME");
if (cVar2 == '\0') {
Msg("Scripted Mode: Could not find entity data file \'%s\'. \n",pcVar5);
}
else {
Msg("Scripted Mode: Loading entity data from %s. \n",pcVar5);
for (pKVar3 = (KeyValues *)KeyValues::GetFirstSubKey(this_00); pKVar3 != (KeyValues *)0x0;
pKVar3 = (KeyValues *)KeyValues::GetNextKey(pKVar3)) {
pcVar5 = (char *)KeyValues::GetName(pKVar3);
pKVar6 = (KeyValues *)KeyValues::FindKey(pKVar3,"classname",false);
if (pKVar6 != (KeyValues *)0x0) {
pcVar5 = (char *)KeyValues::GetString(pKVar6,(char *)0x0,"");
}
iVar7 = _V_stricmp(pcVar5,"func_instance");
if (iVar7 == 0) {
pcVar5 = "info_item_position";
pcVar12 = (char *)KeyValues::GetString(pKVar3,"spawnpositionname","");
KeyValues::SetString(pKVar3,"targetname",pcVar12);
}
pCVar8 = (CBaseEntity *)CreateEntityByName(pcVar5,-1,true);
if (pCVar8 != (CBaseEntity *)0x0) {
pKVar6 = (KeyValues *)KeyValues::GetFirstSubKey(pKVar3);
joined_r0x0064edf0:
if (pKVar6 != (KeyValues *)0x0) {
do {
pcVar5 = (char *)KeyValues::GetName(pKVar6);
iVar7 = _V_strcmp(pcVar5,"connections");
if (iVar7 == 0) {
ParseEntKVBlock(this,pCVar8,pKVar6);
}
else {
pcVar5 = (char *)KeyValues::GetString(pKVar6,(char *)0x0,"");
iVar7 = V_strnchr(pcVar5,'^',0x400);
if (iVar7 != 0) goto code_r0x0064ee88;
pcVar1 = *(code **)(*(int *)pCVar8 + 0x84);
uVar9 = KeyValues::GetName(pKVar6);
(*pcVar1)(pCVar8,uVar9,pcVar5);
}
pKVar6 = (KeyValues *)KeyValues::GetNextKey(pKVar6);
if (pKVar6 == (KeyValues *)0x0) break;
} while( true );
}
local_62c = 0xffffffff;
piVar10 = (int *)(**(code **)(*(int *)pCVar8 + 0xc))(pCVar8);
local_62c = *piVar10;
if (local_62c == -1) {
UTIL_RemoveImmediate(pCVar8);
}
else {
CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>>::InsertBefore
((CUtlVector<CHandle<CBaseEntity>,CUtlMemory<CHandle<CBaseEntity>,int>> *)
(this + 0x44),*(int *)(this + 0x50),(CHandle *)&local_62c);
}
goto LAB_0064ef48;
}
Warning("Scripted Mode: Failed to spawn entity, type: \'%s\'\n",pcVar5);
LAB_0064ef48:
}
}
KeyValues::deleteThis();
if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail(this_00);
}
return;
code_r0x0064ee88:
V_strncpy(local_420,pcVar5,0x400);
iVar7 = _V_strlen(local_420);
if (0 < iVar7) {
pcVar12 = local_420 + iVar7;
pcVar5 = local_420;
do {
while (*pcVar5 != '^') {
pcVar5 = pcVar5 + 1;
if (pcVar5 == pcVar12) goto LAB_0064eec6;
}
*pcVar5 = '\"';
pcVar5 = pcVar5 + 1;
} while (pcVar5 != pcVar12);
}
LAB_0064eec6:
pcVar1 = *(code **)(*(int *)pCVar8 + 0x84);
uVar9 = KeyValues::GetName(pKVar6);
(*pcVar1)(pCVar8,uVar9,local_420);
pKVar6 = (KeyValues *)KeyValues::GetNextKey(pKVar6);
goto joined_r0x0064edf0;
}
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.