//
// GauntletSelectLayer::setupGauntlets from 0x1401f9d30 to 0x1401fa4a5 (1909 bytes)
//
// 3 xrefs:
// > GauntletSelectLayer::init @ 0x1401f96c1
// > GauntletSelectLayer::loadLevelsFinished @ 0x1401f9b46
// > ??> @ 0x1406cc9b4
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=4
void GauntletSelectLayer::setupGauntlets(GauntletSelectLayer *a1)
{
float v1; // xmm0_4
cocos2d::CCDirector *v2; // rax
__int64 v3; // rcx
cocos2d::CCArray *v4; // r12
__int64 v5; // rcx
cocos2d::CCArray *v6; // rsi
__int64 v7; // rcx
__int64 v8; // r14
cocos2d::CCDictionary *v9; // r14
GameManager *v10; // rcx
float width; // ebx
int v12; // r13d
int v13; // edi
cocos2d::CCDictElement *m_pElements; // r14
cocos2d::CCDictElement *next; // r15
cocos2d::CCObject *m_pObject; // r14
unsigned int v17; // edi
struct cocos2d::CCObject *v18; // r12
struct cocos2d::CCObject *v19; // rbx
__int64 v20; // rcx
__int64 v21; // rcx
GauntletNode *v22; // rsi
cocos2d::CCNode *v23; // rdi
cocos2d::CCNode_vtbl *v24; // rbx
double v25; // xmm0_8
const cocos2d::CCSize *v26; // rax
GauntletNode_vtbl *v27; // rbx
float *v28; // rax
struct cocos2d::CCPoint v29; // rax
CCMenuItemSpriteExtra *v30; // rbx
unsigned int v31; // r14d
int v32; // edx
cocos2d::CCArray *v33; // r13
cocos2d::CCNode *v34; // rdi
struct cocos2d::CCObject *v35; // r15
cocos2d::CCNode *v36; // rbx
struct cocos2d::CCPoint v37; // r12
float v38; // xmm6_4
cocos2d::CCObject_vtbl *v39; // rbx
__int64 copyWithZone_low; // rcx
bool (__fastcall *isEqual)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *); // rbx
bool (__fastcall *i)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *); // rsi
__int64 v43; // rdi
float v44; // xmm0_4
float v45; // xmm6_4
cocos2d::CCObject_vtbl *v46; // rsi
__int64 v47; // rax
bool (__fastcall *v48)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *); // rsi
bool (__fastcall *j)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *); // r15
__int64 *v50; // rdi
__int64 v51; // rbx
double v52; // xmm0_8
__int64 v53; // rax
float v54; // xmm0_4
unsigned int v55; // eax
BoomScrollLayer *v56; // rax
__int64 v57; // rcx
cocos2d::CCDirector *v58; // rax
float ScreenBottom; // xmm0_4
BoomScrollLayer *m_scrollLayer; // rbx
__int64 v61; // rax
BoomScrollLayer *v62; // rcx
cocos2d::CCArray *m_dynamicObjects; // rcx
cocos2d::CCArray *v64; // [rsp+38h] [rbp-99h]
cocos2d::CCArray *v65; // [rsp+40h] [rbp-91h] BYREF
cocos2d::CCArray *v66; // [rsp+48h] [rbp-89h]
float v67; // [rsp+50h] [rbp-81h]
cocos2d::CCSize v68; // [rsp+60h] [rbp-71h] BYREF
struct cocos2d::CCPoint v69; // [rsp+68h] [rbp-69h] BYREF
struct cocos2d::CCPoint v70; // [rsp+70h] [rbp-61h] BYREF
void *v71; // [rsp+78h] [rbp-59h]
GauntletNode *v72; // [rsp+80h] [rbp-51h]
cocos2d::CCSize v74; // [rsp+140h] [rbp+6Fh] BYREF
cocos2d::CCSize v75; // [rsp+148h] [rbp+77h] BYREF
cocos2d::CCArray *v76; // [rsp+150h] [rbp+7Fh]
v2 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(a1);
cocos2d::CCDirector::getWinSize(v2);
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(v3);
v66 = v4;
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
v64 = v6;
v65 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
cocos2d::CCPoint::CCPoint(v1, v67 * 0.5);
v8 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v74 = (cocos2d::CCSize)operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280(*(_QWORD *)&v74);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v8 = qword_1406C2EC0;
}
v9 = *(cocos2d::CCDictionary **)(v8 + 576);
if ( cocos2d::CCDictionary::count(v9) )
{
v10 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v74 = (cocos2d::CCSize)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(*(_QWORD *)&v74);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = (GameManager *)qword_1406C2ED8;
}
width = *(float *)&v10->m_currentGauntlet;
v75.width = width;
v12 = 0;
LODWORD(v76) = 0;
v13 = 1;
LODWORD(v74.width) = 1;
if ( v9 )
{
m_pElements = v9->m_pElements;
if ( m_pElements )
{
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
while ( 1 )
{
m_pObject = m_pElements->m_pObject;
if ( m_pObject[5].m_uOrderOfArrival != 7 )
goto LABEL_13;
if ( !v10 )
{
v71 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v71);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = (GameManager *)qword_1406C2ED8;
}
if ( GameManager::getUGV(v10, (const char *)&word_14054445C) )
{
LABEL_13:
v17 = (int)(float)(ceilf((float)v13 / 3.0) - 1.0);
if ( cocos2d::CCArray::count(v4) <= v17 )
{
v19 = (struct cocos2d::CCObject *)cocos2d::CCLayer::create();
cocos2d::CCArray::addObject(v4, v19);
v18 = (struct cocos2d::CCObject *)cocos2d::CCMenu::create(v20);
v19->__vftable[6].isEqual(v19, v18);
cocos2d::CCArray::addObject(v65, v18);
v76 = (cocos2d::CCArray *)cocos2d::CCArray::create(v21);
cocos2d::CCArray::addObject(v6, v76);
width = v75.width;
}
else
{
cocos2d::CCArray::objectAtIndex(v4, v17);
v76 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(v6, v17);
v18 = cocos2d::CCArray::objectAtIndex(v65, v17);
}
if ( m_pObject[5].m_uOrderOfArrival == LODWORD(width) && SLODWORD(width) > 1 )
v12 = v17;
v22 = (GauntletNode *)operator new(0x168u);
v72 = v22;
cocos2d::CCNode::CCNode(v22);
v22->__vftable = (GauntletNode_vtbl *)&GauntletNode::`vftable';
v22->m_gauntletInfoNode = nullptr;
v22->m_rewardNode = nullptr;
v22->m_gauntlet = nullptr;
v22->m_locked = 0;
if ( cocos2d::CCNode::init(v22) )
{
v22->m_gauntlet = (GJMapPack *)m_pObject;
cocos2d::CCObject::retain(m_pObject);
v22->m_locked = 0;
GauntletNode::generateNode(v22);
cocos2d::CCObject::autorelease(v22);
}
else
{
((void (__fastcall *)(GauntletNode *, __int64))v22->~GauntletNode)(v22, 1);
v22 = nullptr;
}
cocos2d::CCDictionary::setObject(a1->m_gauntlets, v22, m_pObject[5].m_uOrderOfArrival);
v23 = (cocos2d::CCNode *)cocos2d::CCNode::create();
v24 = v23->__vftable;
v25 = cocos2d::CCSize::CCSize(&v68, 110.0, 234.0);
v24->setContentSize(v23, v26);
v23->addChild_1(v23, v22);
v27 = v22->__vftable;
v23->getContentSize(v23);
v28 = (float *)v23->getContentSize(v23);
cocos2d::CCPoint::CCPoint(*(float *)&v25, *v28 * 0.5);
v29 = cocos2d::CCNode::convertToNodeSpace(v23, &v70);
((void (__fastcall *)(GauntletNode *, struct cocos2d::CCPoint))v27->setPosition_0)(v22, v29);
v30 = CCMenuItemSpriteExtra::create(
v23,
nullptr,
a1,
(cocos2d::SEL_MenuHandler *)GauntletSelectLayer::onPlay);
LODWORD(v30->m_pDisabledImage) = 1065772646;
v30->setTag(v30, m_pObject[5].m_uOrderOfArrival);
v18->__vftable[6].isEqual(v18, v30);
cocos2d::CCArray::addObject(v76, v30);
v13 = ++LODWORD(v74.width);
v6 = v64;
v4 = v66;
width = v75.width;
}
m_pElements = next;
if ( !next )
break;
next = (cocos2d::CCDictElement *)next->hh.next;
v10 = (GameManager *)qword_1406C2ED8;
}
LODWORD(v76) = v12;
}
}
v31 = 0;
if ( cocos2d::CCArray::count(v6) )
{
v33 = v65;
do
{
v34 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(v4, v31);
v35 = cocos2d::CCArray::objectAtIndex(v6, v31);
v36 = (cocos2d::CCNode *)cocos2d::CCArray::objectAtIndex(v33, v31);
cocos2d::CCNode::convertToWorldSpace(v34, &v70);
v37 = cocos2d::CCNode::convertToNodeSpace(v36, &v69);
v38 = -112.0;
if ( v35 )
{
v39 = v35[1].__vftable;
copyWithZone_low = LODWORD(v39->copyWithZone);
if ( (_DWORD)copyWithZone_low )
{
isEqual = v39->isEqual;
for ( i = (bool (__fastcall *)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *))((char *)isEqual
+ 8 * copyWithZone_low
- 8);
(unsigned __int64)isEqual <= (unsigned __int64)i;
isEqual = (bool (__fastcall *)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *))((char *)isEqual + 8) )
{
v43 = *(_QWORD *)isEqual;
if ( !*(_QWORD *)isEqual )
break;
cocos2d::CCSize::CCSize(&v75, &stru_1406C14A0);
v44 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v43 + 128LL))(v43);
v38 = v38 + (float)((float)(v44 * v75.width) + 112.0);
}
v6 = v64;
}
}
v45 = (float)-v38 * 0.5;
if ( v35 )
{
v46 = v35[1].__vftable;
v47 = LODWORD(v46->copyWithZone);
if ( (_DWORD)v47 )
{
v48 = v46->isEqual;
for ( j = (bool (__fastcall *)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *))((char *)v48
+ 8 * v47
- 8);
(unsigned __int64)v48 <= (unsigned __int64)j;
v48 = (bool (__fastcall *)(cocos2d::CCObject *__hidden, const cocos2d::CCObject *))((char *)v48 + 8) )
{
v50 = *(__int64 **)v48;
if ( !*(_QWORD *)v48 )
break;
cocos2d::CCSize::CCSize(&v74, &stru_1406C14A0);
v51 = *v50;
v52 = (*(double (__fastcall **)(__int64 *))(*v50 + 128))(v50);
cocos2d::CCPoint::CCPoint(
(float)((float)(*(float *)&v52 * v74.width) * 0.5) + v45,
(float)((float)(*(float *)&v52 * v74.width) * 0.5) + v45);
(*(void (__fastcall **)(__int64 *, __int64))(v51 + 184))(v50, v53);
(*(void (__fastcall **)(__int64 *))(*v50 + 200))(v50);
((void (__fastcall *)(_QWORD, _QWORD))cocos2d::CCPoint::operator+)(v37, &v65);
(*(void (__fastcall **)(__int64 *, cocos2d::CCArray **))(*v50 + 184))(v50, &v65);
v54 = (*(float (__fastcall **)(__int64 *))(*v50 + 128))(v50);
v45 = v45 + (float)((float)(v54 * v74.width) + 112.0);
}
}
v6 = v64;
}
++v31;
v55 = cocos2d::CCArray::count(v6);
v4 = v66;
}
while ( v31 < v55 );
v12 = (int)v76;
}
v56 = BoomScrollLayer::create(v66, v32, 1, nullptr, nullptr);
a1->m_scrollLayer = v56;
v56->m_delegate = &a1->BoomScrollLayerDelegate;
a1->addChild_1(a1, a1->m_scrollLayer);
v58 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v57);
ScreenBottom = cocos2d::CCDirector::getScreenBottom(v58);
cocos2d::CCPoint::CCPoint(ScreenBottom + 15.0, v67 * 0.5);
m_scrollLayer = a1->m_scrollLayer;
cocos2d::CCPoint::operator=(&m_scrollLayer->m_dotPosition, v61);
BoomScrollLayer::updateDots(m_scrollLayer, 0.0);
if ( v12 > 0 )
{
v62 = a1->m_scrollLayer;
if ( v62->m_dynamic )
m_dynamicObjects = v62->m_dynamicObjects;
else
m_dynamicObjects = v62->m_pages;
if ( v12 == cocos2d::CCArray::count(m_dynamicObjects) - 1 )
GauntletSelectLayer::goToPage(a1, v12 - 1, 1);
GauntletSelectLayer::goToPage(a1, v12, 1);
}
}
}