//
// SetupRandAdvTriggerPopup::updateGroupIDButtons from 0x65bac0 to 0x65c17a (1722 bytes)
//
// 6 xrefs:
// > SetupRandAdvTriggerPopup::init @ 0x65c95c
// > SetupRandAdvTriggerPopup::addChance @ 0x65cc40
// > SetupRandAdvTriggerPopup::removeGroupID @ 0x65cc8a
// > SetupRandAdvTriggerPopup::onGroupIDScrollUp @ 0x65ccd2
// > SetupRandAdvTriggerPopup::onGroupIDScrollDown @ 0x65cce2
// > SetupRandAdvTriggerPopup::onAddChance @ 0x65cd62
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:55:33 +0000
//
void __fastcall SetupRandAdvTriggerPopup::updateGroupIDButtons(cocos2d::CCArray **this)
{
unsigned int i; // r7
bool v3; // cf
cocos2d::CCArray *v4; // r0
unsigned int v5; // r1
int v6; // r0
_DWORD *v7; // r6
int (__fastcall *v8)(int, cocos2d::CCObject *); // r5
int (__fastcall *j)(int, cocos2d::CCObject *); // r4
RandTriggerGameObject *v10; // r4
int k; // r9
unsigned int v12; // r4
unsigned int v13; // r8
unsigned int v14; // r11
int v15; // r3
_DWORD *v16; // r2
_DWORD *m; // r7
unsigned int v18; // r0
int v19; // r1
_DWORD *ii; // r4
unsigned int v21; // r8
unsigned int v22; // r0
int v23; // r3
int v24; // r6
int v25; // r0
int v26; // r3
int v27; // r0
int v28; // r4
cocos2d::CCDirector *v29; // r0
int v30; // r5
const cocos2d::CCPoint *v31; // r6
int jj; // r6
_DWORD *v33; // r4
unsigned int v34; // r7
char *v35; // r9
int v36; // r7
bool v37; // cc
int v38; // r0
cocos2d::CCString *v39; // r0
char *CString; // r0
ButtonSprite *v41; // r0
char *v42; // r0
ButtonSprite *v43; // r0
int v44; // r9
int v45; // r0
void (__fastcall *v46)(int, _DWORD *); // r3
cocos2d::CCObject *v47; // r7
void (__fastcall *v48)(cocos2d::CCObject *, _DWORD *); // r9
unsigned int v49; // r11
int v50; // r7
_DWORD **v51; // r2
_DWORD *n; // r5
unsigned int v53; // r0
int v54; // r1
_DWORD *v55; // r0
int v56; // r3
float v57; // s15
bool v58; // r7
unsigned int prime; // r4
unsigned int v60; // r0
unsigned int v61; // r7
unsigned int v62; // r1
unsigned int v63; // r0
_DWORD *v64; // r3
unsigned int v65; // r0
int v66; // r1
int v67; // r2
float v68; // r0
float v69; // [sp+10h] [bp-84h]
int v70; // [sp+14h] [bp-80h]
int v71; // [sp+1Ch] [bp-78h]
int v72; // [sp+1Ch] [bp-78h]
int v73; // [sp+20h] [bp-74h]
int (__fastcall *v74)(_DWORD); // [sp+3Ch] [bp-58h] BYREF
float v75[2]; // [sp+40h] [bp-54h] BYREF
_BYTE v76[8]; // [sp+48h] [bp-4Ch] BYREF
_BYTE v77[8]; // [sp+50h] [bp-44h] BYREF
_DWORD v78[2]; // [sp+58h] [bp-3Ch] BYREF
void *v79; // [sp+60h] [bp-34h] BYREF
char *v80; // [sp+64h] [bp-30h]
unsigned int v81; // [sp+68h] [bp-2Ch]
int v82[2]; // [sp+6Ch] [bp-28h] BYREF
ButtonSprite *v83; // [sp+74h] [bp-20h]
int (__fastcall *v84)(int, cocos2d::CCObject *); // [sp+78h] [bp-1Ch] BYREF
unsigned int v85; // [sp+7Ch] [bp-18h]
_DWORD *v86; // [sp+80h] [bp-14h] BYREF
unsigned int v87; // [sp+84h] [bp-10h]
float v88; // [sp+88h] [bp-Ch]
for ( i = 0; ; ++i )
{
v3 = i >= cocos2d::CCArray::count(*(this + 179));
v4 = *(this + 179);
if ( v3 )
break;
v5 = i;
v6 = cocos2d::CCArray::objectAtIndex(v4, v5);
(*(void (__fastcall **)(int))(*(_DWORD *)v6 + 260))(v6);
}
cocos2d::CCArray::removeAllObjects(v4);
v7 = *(this + 132);
v79 = nullptr;
v80 = nullptr;
v81 = 0;
if ( v7 )
{
v8 = (int (__fastcall *)(int, cocos2d::CCObject *))v7[413];
for ( j = (int (__fastcall *)(int, cocos2d::CCObject *))v7[412];
j != v8;
j = (int (__fastcall *)(int, cocos2d::CCObject *))((char *)j + 16) )
{
v84 = j;
if ( (unsigned int)v80 >= v81 )
{
std::vector::__push_back_slow_path((int)&v79, &v84);
}
else
{
if ( v80 )
*(_DWORD *)v80 = j;
v80 += 4;
}
}
RandTriggerGameObject::getTotalChance((RandTriggerGameObject *)v7);
v70 = 1;
goto LABEL_42;
}
v84 = nullptr;
v88 = 1.0;
v85 = 0;
v86 = nullptr;
v87 = 0;
v70 = 1;
LABEL_15:
if ( (unsigned int)v7 < cocos2d::CCArray::count(*(this + 133)) )
{
v10 = (RandTriggerGameObject *)cocos2d::CCArray::objectAtIndex(*(this + 133), (unsigned int)v7);
RandTriggerGameObject::getTotalChance(v10);
v71 = *((_DWORD *)v10 + 413);
for ( k = *((_DWORD *)v10 + 412) + 16; ; k += 16 )
{
if ( v71 == k - 16 )
{
v7 = (_DWORD *)((char *)v7 + 1);
goto LABEL_15;
}
v12 = v85;
v13 = *(_DWORD *)(k - 16);
if ( v85 )
{
v14 = v85 - 1;
v15 = ((v85 - 1) & v85) != 0 ? v13 % v85 : v13 & v14;
v16 = *((_DWORD **)v84 + v15);
if ( v16 )
{
for ( m = (_DWORD *)*v16; m; m = (_DWORD *)*m )
{
v18 = m[1];
v19 = ((v85 - 1) & v85) != 0 ? v18 % v85 : v14 & v18;
if ( v19 != v15 )
break;
if ( m[2] == v13 )
__und(0xFFu);
}
}
}
v73 = *(_DWORD *)(k - 8);
if ( v85 )
{
v49 = v85 - 1;
if ( ((v85 - 1) & v85) != 0 )
v50 = v13 % v85;
else
v50 = v13 & v49;
v51 = *((_DWORD ***)v84 + v50);
if ( v51 )
{
for ( n = *v51; n; n = (_DWORD *)*n )
{
v53 = n[1];
v54 = ((v85 - 1) & v85) != 0 ? v53 % v85 : v49 & v53;
if ( v54 != v50 )
break;
if ( n[2] == v13 )
goto LABEL_123;
}
}
}
else
{
v50 = 0;
}
v55 = (_DWORD *)operator new(0x1Cu);
v56 = *(_DWORD *)(k - 16);
v55[3] = v13;
n = v55;
v55[4] = v13;
v55[2] = v56;
v55[5] = v73;
v55[6] = 0;
*v55 = 0;
v55[1] = v13;
v57 = (float)(v87 + 1);
if ( v57 > (float)((float)v12 * v88) )
break;
if ( !v12 )
{
v58 = 0;
goto LABEL_95;
}
LABEL_115:
v64 = *((_DWORD **)v84 + v50);
if ( v64 )
{
*n = *v64;
*v64 = n;
}
else
{
*n = v86;
v86 = n;
*((_DWORD *)v84 + v50) = &v86;
if ( *n )
{
v65 = *(_DWORD *)(*n + 4);
if ( ((v12 - 1) & v12) != 0 )
v66 = v65 % v12;
else
v66 = (v12 - 1) & v65;
*((_DWORD *)v84 + v66) = n;
}
}
++v87;
LABEL_123:
v67 = n[5];
n[6] = 0;
if ( v67 != *(_DWORD *)(k - 8) )
{
n[5] = -1;
v70 = 0;
}
n[6] = 1;
}
v58 = v12 > 2 && ((v12 - 1) & v12) == 0;
LABEL_95:
prime = 2 * v12 + !v58;
v60 = (unsigned int)ceilf(v57 / v88);
if ( prime < v60 )
prime = v60;
if ( prime == 1 )
{
prime = 2;
}
else if ( ((prime - 1) & prime) != 0 )
{
prime = std::__next_prime(prime);
}
v61 = v85;
if ( prime <= v85 )
{
if ( prime >= v85 )
goto LABEL_104;
if ( v85 <= 2 || ((v85 - 1) & v85) != 0 )
{
v68 = ceilf((float)v87 / v88);
v63 = std::__next_prime((unsigned int)v68);
}
else
{
v63 = 1 << (32 - __clz((unsigned int)ceilf((float)v87 / v88) - 1));
}
v62 = v63;
if ( v63 < prime )
v62 = prime;
if ( v62 >= v61 )
goto LABEL_104;
}
else
{
v62 = prime;
}
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::__rehash(
(int)&v84,
v62);
LABEL_104:
v12 = v85;
if ( ((v85 - 1) & v85) != 0 )
v50 = v13 % v85;
else
v50 = v13 & (v85 - 1);
goto LABEL_115;
}
for ( ii = v86; ii; ii = (_DWORD *)*ii )
{
v21 = ii[6];
v22 = cocos2d::CCArray::count(*(this + 133));
v23 = v70;
if ( v21 < v22 )
v23 = 0;
v70 = v23;
v78[0] = ii + 3;
if ( (unsigned int)v80 >= v81 )
{
std::vector::__push_back_slow_path((int)&v79, v78);
}
else
{
if ( v80 )
*(_DWORD *)v80 = ii + 3;
v80 += 4;
}
}
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::~__hash_table((int)&v84);
LABEL_42:
v24 = (v80 - (_BYTE *)v79) >> 2;
v25 = (int)ceilf((float)v24 / 5.0);
v26 = (v25 - 2) & ~((v25 - 2) >> 31);
if ( (int)*(this + 186) > v26 )
*(this + 186) = (cocos2d::CCArray *)v26;
v37 = v25 <= 2;
v27 = (int)*(this + 184);
v28 = !v37;
if ( v27 )
(*(void (__fastcall **)(int, int))(*(_DWORD *)v27 + 172))(v27, v28);
v29 = *(this + 185);
if ( v29 )
v29 = (cocos2d::CCDirector *)(*(int (__fastcall **)(cocos2d::CCDirector *, int))(*(_DWORD *)v29 + 172))(v29, v28);
v30 = 5 * (_DWORD)*(this + 186);
if ( v24 >= v30 + 10 )
v24 = v30 + 10;
v72 = v24;
cocos2d::CCDirector::sharedDirector(v29);
cocos2d::CCDirector::getWinSize((cocos2d::CCDirector *)v75);
v31 = *(this + 111);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v84, (float)(v75[0] * 0.5) - 132.0, (float)(v75[1] * 0.5) + 10.0);
cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)v76, v31);
v74 = (int (__fastcall *)(_DWORD))chanceObjCompare;
std::__sort((int)v79, v80, &v74);
for ( jj = 0; jj + v30 < v72; ++jj )
{
v33 = *((_DWORD **)v79 + jj + v30);
if ( *(this + 132) || (v34 = v33[3], v34 >= cocos2d::CCArray::count(*(this + 133))) )
v35 = "GJ_button_04.png";
else
v35 = "GJ_button_05.png";
v36 = v33[2];
v83 = nullptr;
v37 = v36 <= 0;
v82[0] = 0;
if ( v36 > 0 )
v36 = 0;
v82[1] = 0;
if ( v37 )
v36 = 1;
v38 = lroundf();
if ( v70 )
{
if ( !v36 )
{
v39 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i - %i\n%i%%",
(const char *)*v33,
v33[2],
v38);
goto LABEL_65;
}
v42 = "%i - ?\n?%%";
}
else
{
if ( !v36 )
{
v39 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i - %i",
(const char *)*v33,
v33[2],
v38);
goto LABEL_65;
}
v42 = "%i - ?";
}
v39 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)v42, (const char *)*v33);
LABEL_65:
CString = (char *)cocos2d::CCString::getCString(v39);
std::string::assign(v82, CString);
if ( (v82[0] & 1) != 0 )
v41 = v83;
else
v41 = (ButtonSprite *)((char *)v82 + 1);
v43 = ButtonSprite::create(
v41,
(const char *)&word_28,
0,
0.35,
1,
"bigFont.fnt",
v35,
(const char *)0x41F00000,
v69);
v44 = (int)v43;
if ( v36 )
{
v45 = *((_DWORD *)v43 + 134);
v46 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v45 + 536);
LOWORD(v78[0]) = -26881;
BYTE2(v78[0]) = 0;
v46(v45, v78);
}
v84 = SetupRandAdvTriggerPopup::onRemoveFromGroup;
v85 = 0;
v47 = (cocos2d::CCObject *)CCMenuItemSpriteExtra::create(
v44,
0,
(int)this,
(int)SetupRandAdvTriggerPopup::onRemoveFromGroup,
0);
(*(void (__fastcall **)(cocos2d::CCObject *, _DWORD))(*(_DWORD *)v47 + 36))(v47, *v33);
(*(void (__fastcall **)(_DWORD, cocos2d::CCObject *))(*(_DWORD *)*(this + 111) + 228))(*(this + 111), v47);
v48 = *(void (__fastcall **)(cocos2d::CCObject *, _DWORD *))(*(_DWORD *)v47 + 92);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v77, (float)(jj % 5) * 66.0, (float)(-38 * (jj / 5)));
cocos2d::CCPoint::operator+(v78, v76, v77);
v48(v47, v78);
cocos2d::CCArray::addObject(*(this + 179), v47);
std::string::~string((int)v82);
}
if ( v79 )
{
v80 -= 4 * ((unsigned int)(v80 - (_BYTE *)v79) >> 2);
operator delete(v79);
}
}