ReadWeaponDataFromFileForSlot
0x00585600 · 394 bytes · __cdecl
_Z29ReadWeaponDataFromFileForSlotP11IFileSystemPKcPtPKh
Decompiled
undefined (4 params)
/* ReadWeaponDataFromFileForSlot(IFileSystem*, char const*, unsigned short*, unsigned char const*)
*/
char ReadWeaponDataFromFileForSlot
(IFileSystem *param_1,char *param_2,ushort *param_3,uchar *param_4)
{
char cVar1;
ushort uVar2;
int iVar3;
undefined4 uVar4;
undefined1 *puVar5;
int in_GS_OFFSET;
char *local_a8;
undefined4 local_a4;
char local_a0 [128];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (param_3 != (ushort *)0x0) {
if (param_2 == (char *)0x0) {
LAB_0058572e:
uVar4 = CreateWeaponInfo();
local_a8 = strdup(param_2);
local_a4 = uVar4;
uVar2 = CUtlRBTree<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short,CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
::Insert((CUtlRBTree<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short,CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
*)m_WeaponInfoDatabase,(Node_t *)&local_a8);
*param_3 = uVar2;
if (uVar2 < (ushort)m_WeaponInfoDatabase._18_2_) {
if (uVar2 != 0xffff) goto LAB_00585680;
puVar5 = gNullWeaponInfo;
}
else {
LAB_00585772:
puVar5 = gNullWeaponInfo;
}
}
else {
local_a8 = param_2;
uVar2 = CUtlRBTree<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short,CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
::Find((CUtlRBTree<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short,CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,FileWeaponInfo_t*,unsigned_short>::Node_t,unsigned_short>,unsigned_short>>
*)m_WeaponInfoDatabase,(Node_t *)&local_a8);
if (uVar2 == 0xffff) goto LAB_0058572e;
*param_3 = uVar2;
if ((ushort)m_WeaponInfoDatabase._18_2_ <= uVar2) goto LAB_00585772;
LAB_00585680:
puVar5 = *(undefined1 **)((uint)uVar2 * 0x10 + m_WeaponInfoDatabase._4_4_ + 0xc);
}
cVar1 = *(char *)((int)puVar5 + 4);
if (cVar1 != '\0') goto LAB_0058570a;
V_snprintf(local_a0,0x80,"scripts/%s",param_2);
iVar3 = ReadEncryptedKVFile(param_1,local_a0,param_4);
if (iVar3 != 0) {
(*(code *)**(undefined4 **)puVar5)(puVar5,iVar3,param_2);
KeyValues::deleteThis();
cVar1 = '\x01';
goto LAB_0058570a;
}
}
cVar1 = '\0';
LAB_0058570a:
if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
return cVar1;
}
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.