//
// SetupRandAdvTriggerPopup::onAddChance from 0x1405d4630 to 0x1405d48c8 (664 bytes)
//
// 2 xrefs:
// > SetupRandAdvTriggerPopup::init @ 0x1405d3302
// > ??> @ 0x14092e928
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:34:56 +0000
//
void __fastcall SetupRandAdvTriggerPopup::onAddChance(__int64 a1)
{
unsigned int v2; // edi
__int64 v3; // rcx
_BYTE *v4; // rax
size_t v5; // rsi
size_t v6; // r8
const char *v7; // rcx
int v8; // ebx
char *v9; // rcx
__int64 v10; // rcx
_BYTE *v11; // rax
const char *v12; // rcx
int v13; // esi
char *v14; // rcx
__int64 v15; // r9
_DWORD *v16; // rax
_DWORD *v17; // rcx
char *v18; // r9
_DWORD *v19; // rax
_DWORD *v20; // rcx
int v21; // [rsp+30h] [rbp-40h] BYREF
int v22; // [rsp+38h] [rbp-38h] BYREF
char *String[2]; // [rsp+40h] [rbp-30h] BYREF
__int128 v24; // [rsp+50h] [rbp-20h]
v2 = 0;
v3 = *(_QWORD *)(*(_QWORD *)(a1 + 1016) + 592LL) + 600LL;
v4 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v3 + 8LL))(v3);
v5 = -1;
*(_OWORD *)String = 0;
v6 = -1;
v24 = 0;
do
++v6;
while ( v4[v6] );
sub_14003D230(String, v4, v6);
v7 = (const char *)String;
if ( *((_QWORD *)&v24 + 1) > 0xFu )
v7 = String[0];
v8 = atoi(v7);
if ( *((_QWORD *)&v24 + 1) > 0xFu )
{
v9 = String[0];
if ( (unsigned __int64)(*((_QWORD *)&v24 + 1) + 1LL) >= 0x1000 )
{
v9 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v9 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v9);
}
if ( v8 > 9999 )
v8 = 9999;
if ( v8 < 0 )
v8 = 0;
v10 = *(_QWORD *)(*(_QWORD *)(a1 + 1024) + 592LL) + 600LL;
v11 = (_BYTE *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v10 + 8LL))(v10);
*(_OWORD *)String = 0;
v24 = 0;
do
++v5;
while ( v11[v5] );
sub_14003D230(String, v11, v5);
v12 = (const char *)String;
if ( *((_QWORD *)&v24 + 1) > 0xFu )
v12 = String[0];
v13 = atoi(v12);
if ( *((_QWORD *)&v24 + 1) > 0xFu )
{
v14 = String[0];
if ( (unsigned __int64)(*((_QWORD *)&v24 + 1) + 1LL) >= 0x1000 )
{
v14 = *((char **)String[0] - 1);
if ( (unsigned __int64)(String[0] - v14 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v14);
}
if ( v8 && v13 > 0 )
{
v15 = *(_QWORD *)(a1 + 680);
*(_BYTE *)(a1 + 1000) = 1;
if ( v15 )
{
v16 = *(_DWORD **)(v15 + 1856);
v17 = *(_DWORD **)(v15 + 1864);
v22 = v13;
v21 = v8;
if ( v16 == v17 )
{
LABEL_29:
sub_1405D4B60(v15 + 1856, &v21, &v22);
}
else
{
while ( *v16 != v8 )
{
v16 += 4;
if ( v16 == v17 )
goto LABEL_29;
}
v16[2] += v13;
}
}
else if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 688)) )
{
v21 = v13;
v22 = v8;
do
{
v18 = (char *)cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 688), v2) + 1856;
v19 = *(_DWORD **)v18;
v20 = *((_DWORD **)v18 + 1);
if ( *(_DWORD **)v18 == v20 )
{
LABEL_36:
sub_1405D4B60(v18, &v22, &v21);
}
else
{
while ( *v19 != v8 )
{
v19 += 4;
if ( v19 == v20 )
goto LABEL_36;
}
v19[2] += v13;
}
++v2;
}
while ( v2 < cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 688)) );
}
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
}
}