FileWeaponInfo_t::Parse
0x00584b30 · 1355 bytes · __thiscall
_ZN16FileWeaponInfo_t5ParseEP9KeyValuesPKc
Decompiled
undefined (3 params)
/* FileWeaponInfo_t::Parse(KeyValues*, char const*) */
void __thiscall FileWeaponInfo_t::Parse(FileWeaponInfo_t *this,KeyValues *param_1,char *param_2)
{
char *pcVar1;
undefined4 uVar2;
int iVar3;
byte *pbVar4;
CAmmoDef *pCVar5;
KeyValues *this_00;
int iVar6;
byte *pbVar7;
byte *pbVar8;
FileWeaponInfo_t *pFVar9;
undefined1 uVar10;
undefined1 uVar11;
undefined1 uVar12;
byte bVar13;
bVar13 = 0;
iVar6 = 0;
this[4] = (FileWeaponInfo_t)0x1;
V_strncpy((char *)(this + 6),param_2,0x50);
pcVar1 = (char *)KeyValues::GetString(param_1,"printname","!!! Missing printname on weapon");
V_strncpy((char *)(this + 0x56),pcVar1,0x50);
pcVar1 = (char *)KeyValues::GetString(param_1,"viewmodel","");
V_strncpy((char *)(this + 0xa6),pcVar1,0x50);
pcVar1 = (char *)KeyValues::GetString(param_1,"playermodel","");
V_strncpy((char *)(this + 0xf6),pcVar1,0x50);
pcVar1 = (char *)KeyValues::GetString(param_1,"anim_prefix","");
V_strncpy((char *)(this + 0x146),pcVar1,0x10);
uVar2 = KeyValues::GetInt(param_1,"bucket",0);
*(undefined4 *)(this + 0x158) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"bucket_position",0);
*(undefined4 *)(this + 0x15c) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"clip_size",-1);
*(undefined4 *)(this + 0x160) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"clip2_size",-1);
*(undefined4 *)(this + 0x164) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"default_clip",*(int *)(this + 0x160));
*(undefined4 *)(this + 0x168) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"default_clip2",*(int *)(this + 0x164));
*(undefined4 *)(this + 0x16c) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"weight",0);
*(undefined4 *)(this + 0x170) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"rumble",-1);
*(undefined4 *)(this + 0x174) = uVar2;
uVar2 = KeyValues::GetInt(param_1,"item_flags",8);
*(undefined4 *)(this + 0x17c) = uVar2;
LAB_00584d77:
do {
iVar3 = KeyValues::GetInt(param_1,(&g_ItemFlags)[iVar6 * 2],-1);
if (iVar3 == 0) {
*(uint *)(this + 0x17c) = *(uint *)(this + 0x17c) & ~(&DAT_00f1efa4)[iVar6 * 2];
}
else if (iVar3 == 1) {
iVar3 = iVar6 * 2;
iVar6 = iVar6 + 1;
*(uint *)(this + 0x17c) = *(uint *)(this + 0x17c) | (&DAT_00f1efa4)[iVar3];
if (iVar6 == 8) break;
goto LAB_00584d77;
}
iVar6 = iVar6 + 1;
} while (iVar6 != 8);
iVar6 = KeyValues::GetInt(param_1,"showusagehint",0);
this[0x88c] = (FileWeaponInfo_t)(iVar6 != 0);
iVar6 = KeyValues::GetInt(param_1,"autoswitchto",1);
this[0x178] = (FileWeaponInfo_t)(iVar6 != 0);
iVar6 = KeyValues::GetInt(param_1,"autoswitchfrom",1);
this[0x179] = (FileWeaponInfo_t)(iVar6 != 0);
iVar6 = KeyValues::GetInt(param_1,"BuiltRightHanded",1);
this[0x859] = (FileWeaponInfo_t)(iVar6 != 0);
iVar6 = KeyValues::GetInt(param_1,"AllowFlipping",1);
this[0x85a] = (FileWeaponInfo_t)(iVar6 != 0);
iVar6 = KeyValues::GetInt(param_1,"MeleeWeapon",0);
uVar10 = 0;
uVar12 = iVar6 == 0;
this[0x858] = (FileWeaponInfo_t)!(bool)uVar12;
pbVar4 = (byte *)KeyValues::GetString(param_1,"primary_ammo","None");
iVar6 = 5;
pbVar7 = (byte *)0xcb1fea;
pbVar8 = pbVar4;
do {
if (iVar6 == 0) break;
iVar6 = iVar6 + -1;
uVar10 = *pbVar7 < *pbVar8;
uVar12 = *pbVar7 == *pbVar8;
pbVar7 = pbVar7 + (uint)bVar13 * -2 + 1;
pbVar8 = pbVar8 + (uint)bVar13 * -2 + 1;
} while ((bool)uVar12);
pFVar9 = this + 0x180;
uVar11 = (!(bool)uVar10 && !(bool)uVar12) < (byte)uVar10;
uVar10 = (!(bool)uVar10 && !(bool)uVar12) == (bool)uVar10;
if ((bool)uVar10) {
V_strncpy((char *)pFVar9,"",0x20);
}
else {
V_strncpy((char *)pFVar9,(char *)pbVar4,0x20);
}
pCVar5 = (CAmmoDef *)GetAmmoDef();
uVar2 = CAmmoDef::Index(pCVar5,(char *)pFVar9);
*(undefined4 *)(this + 0x850) = uVar2;
pbVar4 = (byte *)KeyValues::GetString(param_1,"secondary_ammo","None");
iVar6 = 5;
pbVar7 = (byte *)0xcb1fea;
pbVar8 = pbVar4;
do {
if (iVar6 == 0) break;
iVar6 = iVar6 + -1;
uVar11 = *pbVar7 < *pbVar8;
uVar10 = *pbVar7 == *pbVar8;
pbVar7 = pbVar7 + (uint)bVar13 * -2 + 1;
pbVar8 = pbVar8 + (uint)bVar13 * -2 + 1;
} while ((bool)uVar10);
pFVar9 = this + 0x1a0;
uVar12 = (!(bool)uVar11 && !(bool)uVar10) < (byte)uVar11;
uVar10 = (!(bool)uVar11 && !(bool)uVar10) == (bool)uVar11;
if ((bool)uVar10) {
V_strncpy((char *)pFVar9,"",0x20);
}
else {
V_strncpy((char *)pFVar9,(char *)pbVar4,0x20);
}
pCVar5 = (CAmmoDef *)GetAmmoDef();
uVar2 = CAmmoDef::Index(pCVar5,(char *)pFVar9);
*(undefined4 *)(this + 0x854) = uVar2;
pbVar4 = (byte *)KeyValues::GetString(param_1,"ai_addon","ai_addon_basecombatweapon");
iVar6 = 5;
pbVar7 = (byte *)0xcb1fea;
pbVar8 = pbVar4;
do {
if (iVar6 == 0) break;
iVar6 = iVar6 + -1;
uVar12 = *pbVar7 < *pbVar8;
uVar10 = *pbVar7 == *pbVar8;
pbVar7 = pbVar7 + (uint)bVar13 * -2 + 1;
pbVar8 = pbVar8 + (uint)bVar13 * -2 + 1;
} while ((bool)uVar10);
if ((!(bool)uVar12 && !(bool)uVar10) == (bool)uVar12) {
V_strncpy((char *)(this + 0x1c0),"",0x50);
}
else {
V_strncpy((char *)(this + 0x1c0),(char *)pbVar4,0x50);
}
pFVar9 = this + 0x210;
for (iVar6 = 400; iVar6 != 0; iVar6 = iVar6 + -1) {
*(undefined4 *)pFVar9 = 0;
pFVar9 = pFVar9 + (uint)bVar13 * -8 + 4;
}
iVar6 = 0;
this_00 = (KeyValues *)KeyValues::FindKey(param_1,"SoundData",false);
pFVar9 = this + 0x210;
if (this_00 != (KeyValues *)0x0) {
do {
while ((pcVar1 = (char *)KeyValues::GetString(this_00,(&pWeaponSoundCategories)[iVar6],""),
pcVar1 != (char *)0x0 && (*pcVar1 != '\0'))) {
iVar6 = iVar6 + 1;
V_strncpy((char *)pFVar9,pcVar1,0x50);
pFVar9 = pFVar9 + 0x50;
if (iVar6 == 0x14) {
return;
}
}
iVar6 = iVar6 + 1;
pFVar9 = pFVar9 + 0x50;
} while (iVar6 != 0x14);
}
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.