ReadCheatCommandsFromFile
0x001148b0 · 571 bytes · __cdecl
_Z25ReadCheatCommandsFromFilePc
Decompiled
undefined (1 param)
/* ReadCheatCommandsFromFile(char*) */
void ReadCheatCommandsFromFile(char *param_1)
{
code *pcVar1;
uint uVar2;
char cVar3;
KeyValues *pKVar4;
IBaseFileSystem *pIVar5;
char *pcVar6;
int iVar7;
KeyValues *this;
undefined4 uVar8;
char *pcVar9;
uint in_stack_ffffffc8;
pKVar4 = KeyValues::operator_new((KeyValues *)0x2c,in_stack_ffffffc8);
/* try { // try from 001148e8 to 001148ec has its CatchHandler @ 00114afa */
KeyValues::KeyValues(pKVar4,"cheat_codes",(IKeyValuesSystem *)0x0,false);
pIVar5 = (IBaseFileSystem *)0x0;
if (g_pFullFileSystem != 0) {
pIVar5 = (IBaseFileSystem *)(g_pFullFileSystem + 4);
}
cVar3 = KeyValues::LoadFromFile(pKVar4,pIVar5,param_1,(char *)0x0);
if (cVar3 != '\0') {
pKVar4 = (KeyValues *)KeyValues::GetFirstTrueSubKey(pKVar4);
uVar2 = DAT_00355d0c;
while (DAT_00355d0c = uVar2, pKVar4 != (KeyValues *)0x0) {
CUtlVector<CheatCodeData_t,CUtlMemory<CheatCodeData_t,int>>::GrowVector
((CUtlVector<CheatCodeData_t,CUtlMemory<CheatCodeData_t,int>> *)&s_CheatCodeCommands
,1);
if (0 < (int)(~uVar2 + DAT_00355d0c)) {
_V_memmove((void *)(s_CheatCodeCommands + 0xd0 + uVar2 * 0xd0),
(void *)(s_CheatCodeCommands + uVar2 * 0xd0),(~uVar2 + DAT_00355d0c) * 0xd0);
}
pcVar9 = (char *)(uVar2 * 0xd0 + s_CheatCodeCommands);
pcVar6 = (char *)KeyValues::GetName(pKVar4);
V_strncpy(pcVar9,pcVar6,0x20);
iVar7 = KeyValues::GetInt(pKVar4,"dev",0);
pcVar9[0x24] = '\0';
pcVar9[0x25] = '\0';
pcVar9[0x26] = '\0';
pcVar9[0x27] = '\0';
pcVar9[0x20] = iVar7 != 0;
pcVar6 = (char *)KeyValues::GetString(pKVar4,"command","echo \"Cheat code has no command!\"");
V_strncpy(pcVar9 + 0x50,pcVar6,0x80);
for (this = (KeyValues *)KeyValues::GetFirstSubKey(pKVar4); this != (KeyValues *)0x0;
this = (KeyValues *)KeyValues::GetNextKey(this)) {
while( true ) {
pcVar6 = (char *)KeyValues::GetName(this);
iVar7 = _V_strcmp(pcVar6,"code");
if (iVar7 != 0) break;
iVar7 = *(int *)(pcVar9 + 0x24);
pcVar1 = *(code **)(*g_pInputSystem + 0x74);
uVar8 = KeyValues::GetString(this,(char *)0x0,"");
uVar8 = (*pcVar1)(g_pInputSystem,uVar8);
*(undefined4 *)(pcVar9 + iVar7 * 4 + 0x28) = uVar8;
*(int *)(pcVar9 + 0x24) = *(int *)(pcVar9 + 0x24) + 1;
this = (KeyValues *)KeyValues::GetNextKey(this);
if (this == (KeyValues *)0x0) goto LAB_00114a7c;
}
}
LAB_00114a7c:
if (*(int *)(pcVar9 + 0x24) < 0x20) {
uVar8 = KeyValues::GetName(pKVar4);
DevWarning("Cheat code \"%s\" has less than %i code elements!",uVar8,0x20);
}
pKVar4 = (KeyValues *)KeyValues::GetNextTrueSubKey(pKVar4);
uVar2 = DAT_00355d0c;
}
}
KeyValues::deleteThis();
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.