//
// GauntletLayer::init from 0x91f38c to 0x91fa9c (1808 bytes)
//
// 2 xrefs:
// > GauntletLayer::create @ 0x91fb2c
// > ??> @ 0x5b6e0
//
// 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
//
bool GauntletLayer::init(GauntletLayer *a1, GauntletType a2)
{
bool v4; // w25
GauntletLayer_vtbl *v6; // x2
cocos2d::CCDirector *v7; // x0
GameManager *v8; // x0
cocos2d::CCSprite *BGTexture; // x0
const char *v10; // x1
cocos2d::CCSprite *v11; // x0
cocos2d::CCSprite_vtbl *v12; // x3
__int64 (*getTexture)(void); // x2
cocos2d::CCTexture2D *v14; // x0
cocos2d::CCSprite *m_backgroundSprite; // x26
void (__fastcall *setAnchorPoint)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCSprite *v17; // x26
void (__fastcall *setScale)(cocos2d::CCSprite *__hidden, float); // x27
AppDelegate *v19; // x0
float v20; // s0
cocos2d::CCSprite *v21; // x0
void (__fastcall *setColor)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x3
cocos2d::CCSprite *v23; // x26
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCLabelBMFont *v25; // x24
void (__fastcall *v26)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
void (__fastcall *v27)(cocos2d::CCLabelBMFont *__hidden, const cocos2d::ccColor3B *); // x3
cocos2d::CCLabelBMFont *v28; // x23
void (__fastcall *v29)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x26
__int64 v30; // x27
cocos2d::CCSprite *v31; // x0
CCMenuItemSpriteExtra *v32; // x26
cocos2d::CCNode *v33; // x23
void (__fastcall *v34)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x27
cocos2d::CCDirector *v35; // x0
float v36; // s0
float v37; // s8
cocos2d::CCDirector *v38; // x0
float v39; // s0
LoadingCircle *v40; // x0
LoadingCircle *m_loadingCircle; // x0
cocos2d::CCSprite *m_sprite; // x0
void (__fastcall *v43)(cocos2d::CCSprite *__hidden, const cocos2d::ccColor3B *); // x3
TextArea *v44; // x0
TextArea *m_tryAgainText; // x23
void *v46; // x0
void (__fastcall *v47)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x26
GameLevelManager *v48; // x0
GameLevelManager *v49; // x0
cocos2d::CCArray *StoredOnlineLevels; // x1
char *v51; // x0
cocos2d::CCArray **p_m_pTargetArray; // x0
unsigned int *p_m_nExtraKerning; // x1
int m_nExtraKerning; // w2
GameLevelManager *v55; // x0
unsigned int *v56; // x1
int v57; // w2
unsigned int *v58; // x1
int v59; // w2
int v60; // [xsp+68h] [xbp+68h]
float v61; // [xsp+78h] [xbp+78h]
float v62; // [xsp+7Ch] [xbp+7Ch]
cocos2d::CCLabelBMFont *v63; // [xsp+80h] [xbp+80h] BYREF
cocos2d::CCPoint v64; // [xsp+88h] [xbp+88h] BYREF
char *v65; // [xsp+90h] [xbp+90h] BYREF
cocos2d::ccTexParams v66; // [xsp+98h] [xbp+98h] BYREF
cocos2d::SEL_MenuHandler v67; // 0:x2.16
v4 = cocos2d::CCLayer::init(a1);
if ( v4 )
{
v6 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_gauntletType = a2;
v6->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
v7 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v7);
v60 = bgForGauntlet(a1->m_gauntletType);
v8 = GameManager::sharedState();
BGTexture = (cocos2d::CCSprite *)GameManager::getBGTexture(v8, v60);
v11 = (cocos2d::CCSprite *)cocos2d::CCSprite::create(BGTexture, v10);
v12 = v11->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_backgroundSprite = v11;
v66.minFilter = 9729;
v66.magFilter = 9729;
getTexture = (__int64 (*)(void))v12->getTexture;
v66.wrapS = 10497;
v66.wrapT = 10497;
v14 = (cocos2d::CCTexture2D *)getTexture();
cocos2d::CCTexture2D::setTexParameters(v14, &v66);
a1->addChild_0(a1, a1->m_backgroundSprite, -1);
m_backgroundSprite = a1->m_backgroundSprite;
setAnchorPoint = m_backgroundSprite->setAnchorPoint;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v65, 0.0, 0.0);
setAnchorPoint(m_backgroundSprite, (const cocos2d::CCPoint *)&v65);
v17 = a1->m_backgroundSprite;
setScale = v17->setScale;
v19 = AppDelegate::get();
v20 = AppDelegate::bgScale(v19);
setScale(v17, v20);
v21 = a1->m_backgroundSprite;
setColor = v21->setColor;
memset(&v65, 76, 3);
setColor(v21, (const cocos2d::ccColor3B *)&v65);
v23 = a1->m_backgroundSprite;
setPosition = v23->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v65, 0.0, -20.0);
setPosition(v23, (const cocos2d::CCPoint *)&v65);
GauntletNode::nameForType(a2, (__int64)&v63);
sub_D15FD4(&v63, " Gauntlet", 9);
v25 = cocos2d::CCLabelBMFont::create();
a1->addChild_0(a1, v25, 2);
v26 = v25->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v65, v61 * 0.5, v62 - 22.0);
v26(v25, (const cocos2d::CCPoint *)&v65);
v25->setScale(v25, 1.0);
v27 = v25->setColor;
LOWORD(v65) = -1;
BYTE2(v65) = 0;
v27(v25, (const cocos2d::ccColor3B *)&v65);
v28 = cocos2d::CCLabelBMFont::create();
a1->addChild_0(a1, v28, 0);
v29 = v28->setPosition;
v30 = (__int64)v25->getPosition(v25);
cocos2d::CCPoint::CCPoint(&v64, 2.0, -4.0);
cocos2d::CCPoint::operator+(&v65, v30, &v64);
v29(v28, (const cocos2d::CCPoint *)&v65);
v28->setScale(v28, 1.0);
v28->setColor(v28, (const cocos2d::ccColor3B *)&unk_EF4C40);
v28->setOpacity(v28, 100);
v31 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v67.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v67.adj = (size_t)GauntletLayer::onBack;
v32 = CCMenuItemSpriteExtra::create(v31, nullptr, v67);
CCMenuItemSpriteExtra::setSizeMult(v32, 1.6);
v33 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v32, nullptr);
a1->addChild_0(a1, v33, 2);
v34 = v33->setPosition;
v35 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v35);
v37 = v36 + 25.0;
v38 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v38);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v65, v37, v39 - 22.0);
v34(v33, (const cocos2d::CCPoint *)&v65);
if ( PlatformToolbox::isControllerConnected() )
GameToolbox::addBackButton(a1, v32);
v40 = LoadingCircle::create();
a1->m_loadingCircle = v40;
v40->m_parentLayer = a1;
m_loadingCircle = a1->m_loadingCircle;
m_loadingCircle->m_fade = 0;
cocos2d::CCObject::retain(m_loadingCircle);
LoadingCircle::show(a1->m_loadingCircle);
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 0);
m_sprite = a1->m_loadingCircle->m_sprite;
v43 = m_sprite->setColor;
memset(&v65, 100, 3);
v43(m_sprite, (const cocos2d::ccColor3B *)&v65);
sub_D153B8((int)&v64, "Something went wrong\nplease try again later");
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v65, 0.5, 1.0);
v44 = (TextArea *)TextArea::create(
(__int64)&v64,
"bigFont.fnt",
(const cocos2d::CCPoint *)&v65,
0,
1.0,
600.0,
20.0);
a1->m_tryAgainText = v44;
m_tryAgainText = v44;
v46 = (void *)(*(_QWORD *)&v64 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v64 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v56 = (unsigned int *)(*(_QWORD *)&v64 - 8LL);
do
v57 = __ldaxr(v56);
while ( __stlxr(v57 - 1, v56) );
}
else
{
v57 = *(_DWORD *)(*(_QWORD *)&v64 - 8LL);
*(_DWORD *)(*(_QWORD *)&v64 - 8LL) = v57 - 1;
}
if ( v57 <= 0 )
operator delete(v46);
m_tryAgainText = a1->m_tryAgainText;
}
v47 = m_tryAgainText->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v65, v61 * 0.5, (float)(v62 * 0.5) + 10.0);
v47(m_tryAgainText, (const cocos2d::CCPoint *)&v65);
a1->m_tryAgainText->setScale(a1->m_tryAgainText, 0.6);
a1->addChild_0(a1, a1->m_tryAgainText, 10);
a1->m_tryAgainText->setVisible(a1->m_tryAgainText, 0);
v48 = GameLevelManager::sharedState();
GameLevelManager::getGauntletSearchKey(v48, (const char *)(unsigned int)a1->m_gauntletType, (__int64)&v65);
v49 = GameLevelManager::sharedState();
StoredOnlineLevels = GameLevelManager::getStoredOnlineLevels(v49, v65);
if ( StoredOnlineLevels )
{
GauntletLayer::setupGauntlet(a1, StoredOnlineLevels);
}
else
{
a1->m_loadingCircle->setVisible(a1->m_loadingCircle, 1);
GameLevelManager::sharedState()->m_levelManagerDelegate = &a1->LevelManagerDelegate;
v55 = GameLevelManager::sharedState();
GameLevelManager::getGauntletLevels(v55, a1->m_gauntletType);
}
v51 = v65 - 24;
if ( v65 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v58 = (unsigned int *)(v65 - 8);
do
v59 = __ldaxr(v58);
while ( __stlxr(v59 - 1, v58) );
}
else
{
v59 = *((_DWORD *)v65 - 2);
*((_DWORD *)v65 - 2) = v59 - 1;
}
if ( v59 <= 0 )
operator delete(v51);
}
p_m_pTargetArray = &v63[-1].m_pTargetArray;
if ( &v63[-1].m_pTargetArray != (cocos2d::CCArray **)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_nExtraKerning = (unsigned int *)&v63[-1].m_nExtraKerning;
do
m_nExtraKerning = __ldaxr(p_m_nExtraKerning);
while ( __stlxr(m_nExtraKerning - 1, p_m_nExtraKerning) );
}
else
{
m_nExtraKerning = v63[-1].m_nExtraKerning;
v63[-1].m_nExtraKerning = m_nExtraKerning - 1;
}
if ( m_nExtraKerning <= 0 )
operator delete(p_m_pTargetArray);
}
}
return v4;
}