CStudioHdr::CActivityToSequenceMapping::SelectWeightedSequence
0x003faba0 · 536 bytes · __thiscall
_ZN10CStudioHdr26CActivityToSequenceMapping22SelectWeightedSequenceEPS_ii
Decompiled
undefined (4 params)
/* CStudioHdr::CActivityToSequenceMapping::SelectWeightedSequence(CStudioHdr*, int, int) */
int __thiscall
CStudioHdr::CActivityToSequenceMapping::SelectWeightedSequence
(CActivityToSequenceMapping *this,CStudioHdr *param_1,int param_2,int param_3)
{
undefined4 *puVar1;
short *psVar2;
char cVar3;
int iVar4;
uint uVar5;
int iVar6;
int iVar7;
uint uVar8;
short *psVar9;
short *psVar10;
uint uVar11;
int *piVar12;
uint local_20;
if (((-1 < param_3) && (iVar4 = pSeqdesc(param_1,param_3), *(int *)(iVar4 + 0x10) == param_2)) &&
(*(int *)(iVar4 + 0x14) < 0)) {
return param_3;
}
cVar3 = SequencesAvailable(param_1);
if (cVar3 == '\0') {
return -1;
}
iVar4 = GetNumSeq(param_1);
if (iVar4 == 1) {
return -1;
}
cVar3 = ValidateAgainst(this,param_1);
if (cVar3 == '\0') {
if (SelectWeightedSequence(CStudioHdr*,int,int)::__executeCount < 1) {
SelectWeightedSequence(CStudioHdr*,int,int)::__executeCount =
SelectWeightedSequence(CStudioHdr*,int,int)::__executeCount + 1;
cVar3 = Plat_IsInDebugSession(0);
if (cVar3 != '\0') {
raise(5);
}
}
Reinitialize(this,param_1);
}
if (*(int *)this == 0) {
return -1;
}
uVar5 = HashInt(param_2);
if (this[0x1e] == (CActivityToSequenceMapping)0x0) {
local_20 = *(uint *)(this + 0x14);
uVar5 = uVar5 % local_20;
}
else {
uVar5 = uVar5 & *(uint *)(this + 0x20);
local_20 = *(uint *)(this + 0x14);
}
puVar1 = (undefined4 *)(*(int *)(this + 8) + uVar5 * 0x14);
uVar8 = puVar1[3];
if ((int)uVar8 < 1) {
if (uVar8 == 0) {
LAB_003fac8b:
uVar8 = 0xffff;
uVar5 = 0xffff;
goto LAB_003fac9a;
}
LAB_003fad56:
uVar11 = 0;
}
else {
piVar12 = (int *)*puVar1;
if (param_2 == *piVar12) goto LAB_003fad56;
uVar11 = 0;
do {
piVar12 = piVar12 + 4;
uVar11 = uVar11 + 1;
if (uVar11 == uVar8) goto LAB_003fac8b;
} while (param_2 != *piVar12);
}
uVar8 = uVar11 & 0xffff;
uVar5 = (uVar5 << 0x10 | uVar11) >> 0x10;
LAB_003fac9a:
if (((int)local_20 <= (int)uVar5) ||
(piVar12 = (int *)(*(int *)(this + 8) + uVar5 * 0x14), piVar12[3] <= (int)uVar8)) {
return -1;
}
iVar4 = uVar8 * 0x10 + *piVar12;
if (CBaseEntity::m_pPredictionPlayer == 0) {
iVar6 = RandomInt(0,*(int *)(iVar4 + 0xc) + -1);
}
else {
iVar6 = SharedRandomInt("SelectWeightedSequence",0,*(int *)(iVar4 + 0xc) + -1,0);
}
psVar2 = (short *)(*(int *)this + *(int *)(iVar4 + 4) * 4);
iVar7 = (int)psVar2[1];
psVar10 = psVar2;
if (iVar7 <= iVar6) {
do {
if (psVar2 + *(int *)(iVar4 + 8) * 2 <= psVar10) break;
psVar9 = psVar10 + 2;
iVar6 = iVar6 - iVar7;
iVar7 = (int)psVar10[3];
psVar10 = psVar9;
} while (iVar7 <= iVar6);
}
return (int)*psVar10;
}
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.