Studio_FindRandomAttachment
0x00b96450 · 476 bytes · __cdecl
_Z27Studio_FindRandomAttachmentPK10CStudioHdrPKc
Decompiled
undefined (2 params)
/* Studio_FindRandomAttachment(CStudioHdr const*, char const*) */
undefined4 Studio_FindRandomAttachment(CStudioHdr *param_1,char *param_2)
{
int iVar1;
int *piVar2;
char *pcVar3;
size_t __size;
int iVar4;
int iVar5;
undefined4 uVar6;
int iVar7;
void *local_30;
int local_2c;
int local_28;
int local_24;
void *local_20;
if (param_1 == (CStudioHdr *)0x0) {
uVar6 = 0xffffffff;
}
else {
local_30 = (void *)0x0;
local_2c = 0;
local_28 = 0;
local_24 = 0;
local_20 = (void *)0x0;
/* try { // try from 00b964b9 to 00b965d9 has its CatchHandler @ 00b96642 */
for (iVar7 = 0; iVar1 = CStudioHdr::GetNumAttachments(param_1), iVar7 < iVar1; iVar7 = iVar7 + 1
) {
piVar2 = (int *)CStudioHdr::pAttachment(param_1,iVar7);
pcVar3 = strstr((char *)((int)piVar2 + *piVar2),param_2);
iVar1 = local_24;
if (pcVar3 != (char *)0x0) {
iVar5 = local_24 + 1;
if ((local_2c < iVar5) && (-1 < local_28)) {
if (local_28 == 0) {
if (local_2c == 0) {
if (iVar5 < 9) {
local_2c = 8;
goto LAB_00b96527;
}
local_2c = 8;
}
do {
iVar4 = local_2c;
local_2c = iVar4 * 2;
} while (local_2c < iVar5);
__size = iVar4 << 3;
}
else {
for (local_2c = (local_24 / local_28 + 1) * local_28; local_2c < iVar5;
local_2c = (local_2c + iVar5) / 2) {
}
LAB_00b96527:
__size = local_2c << 2;
}
if (local_30 == (void *)0x0) {
local_30 = malloc(__size);
}
else {
local_30 = realloc(local_30,__size);
iVar5 = local_24 + 1;
}
}
iVar4 = (iVar5 - iVar1) + -1;
iVar1 = iVar1 * 4;
local_24 = iVar5;
local_20 = local_30;
if (0 < iVar4) {
_V_memmove((void *)((int)local_30 + iVar1 + 4),(void *)((int)local_30 + iVar1),iVar4 * 4);
}
if ((int *)(iVar1 + (int)local_30) != (int *)0x0) {
*(int *)(iVar1 + (int)local_30) = iVar7;
}
}
}
if (local_24 < 1) {
local_24 = 0;
CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
uVar6 = 0xffffffff;
local_20 = local_30;
CUtlMemory<int,int>::Purge((CUtlMemory<int,int> *)&local_30);
}
else {
iVar7 = RandomInt(0,local_24 + -1);
uVar6 = *(undefined4 *)((int)local_30 + iVar7 * 4);
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 uVar6;
}
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.