CMeleeWeaponInfoStore::GetRandomMeleeWeapon
0x00544bb0 · 545 bytes · __thiscall
_ZN21CMeleeWeaponInfoStore20GetRandomMeleeWeaponEv
Decompiled
undefined (1 param)
/* CMeleeWeaponInfoStore::GetRandomMeleeWeapon() */
undefined4 __thiscall CMeleeWeaponInfoStore::GetRandomMeleeWeapon(CMeleeWeaponInfoStore *this)
{
int iVar1;
int iVar2;
int iVar3;
undefined4 uVar4;
int iVar5;
int local_40;
void *local_30;
int local_2c;
int local_28;
int local_24;
void *local_20;
local_30 = (void *)0x0;
local_2c = 0;
local_28 = 0;
local_24 = 0;
local_20 = (void *)0x0;
if (0 < *(int *)(this + 0x14)) {
local_40 = 0;
iVar3 = 0;
LAB_00544c04:
do {
if (iVar3 <= *(int *)(this + 0x28)) {
if ((CUtlRBTree<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int,CUtlMap<int,CMeleeWeaponInfo*,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int>,int>>
::Links(int)::s_Sentinel == '\0') &&
(iVar1 = __cxa_guard_acquire(&CUtlRBTree<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int,CUtlMap<int,CMeleeWeaponInfo*,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int>,int>>
::Links(int)::s_Sentinel), iVar1 != 0)) {
CUtlRBTree<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int,CUtlMap<int,CMeleeWeaponInfo*,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int>,int>>
::Links(int)::s_Sentinel = 0xffffffff;
DAT_00f1dde0 = 0xffffffff;
DAT_00f1dde4 = 0xffffffff;
__cxa_guard_release(&CUtlRBTree<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int,CUtlMap<int,CMeleeWeaponInfo*,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<int,CMeleeWeaponInfo*,int>::Node_t,int>,int>>
::Links(int)::s_Sentinel);
}
iVar1 = local_24;
if (iVar3 != *(int *)(*(int *)(this + 0x10) + local_40)) {
iVar5 = local_24 + 1;
if ((local_2c < iVar5) && (-1 < local_28)) {
if (local_28 == 0) {
iVar2 = local_2c;
if (local_2c == 0) {
if (iVar5 < 9) {
local_2c = 8;
goto LAB_00544cf7;
}
iVar2 = 8;
}
do {
local_2c = iVar2 * 2;
if (iVar5 <= local_2c) break;
local_2c = iVar2 * 4;
iVar2 = local_2c;
} while (local_2c < iVar5);
}
else {
for (local_2c = (local_24 / local_28 + 1) * local_28; local_2c < iVar5;
local_2c = (local_2c + iVar5) / 2) {
}
}
LAB_00544cf7:
if (local_30 == (void *)0x0) {
local_30 = malloc(local_2c << 2);
}
else {
local_30 = realloc(local_30,local_2c << 2);
iVar5 = local_24 + 1;
}
}
iVar2 = (iVar5 - iVar1) + -1;
iVar1 = iVar1 * 4;
local_24 = iVar5;
local_20 = local_30;
if (0 < iVar2) {
_V_memmove((void *)((int)local_30 + iVar1 + 4),(void *)((int)local_30 + iVar1),iVar2 * 4
);
}
if ((int *)(iVar1 + (int)local_30) != (int *)0x0) {
local_40 = local_40 + 0x18;
*(int *)(iVar1 + (int)local_30) = iVar3;
iVar3 = iVar3 + 1;
if (*(int *)(this + 0x14) <= iVar3) break;
goto LAB_00544c04;
}
}
}
local_40 = local_40 + 0x18;
iVar3 = iVar3 + 1;
} while (iVar3 < *(int *)(this + 0x14));
if (local_24 != 0) {
/* try { // try from 00544c7a to 00544d49 has its CatchHandler @ 00544def */
iVar3 = RandomInt(0,local_24 + -1);
uVar4 = *(undefined4 *)
(*(int *)(this + 0x10) + *(int *)((int)local_30 + iVar3 * 4) * 0x18 + 0x10);
goto LAB_00544c91;
}
}
uVar4 = 0xffffffff;
LAB_00544c91:
local_24 = 0;
CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
local_20 = local_30;
CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
return uVar4;
}
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.