//
// LeaderboardsLayer::init from 0x81eabc to 0x81f738 (3196 bytes)
//
// 2 xrefs:
// > LeaderboardsLayer::create @ 0x81f7ec
// > ??> @ 0x3aff8
//
// 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 LeaderboardsLayer::init(LeaderboardsLayer *a1, LeaderboardType a2, LeaderboardStat a3)
{
bool v6; // w25
GameManager *v7; // x0
LeaderboardsLayer_vtbl *v8; // x2
GameLevelManager *v9; // x21
char *v10; // x0
GameLevelManager *v11; // x21
char *v12; // x0
GameLevelManager *v13; // x21
char *v14; // x0
GameLevelManager *v15; // x21
char *v16; // x0
GameLevelManager *v17; // x21
char *v18; // x0
GameLevelManager *v19; // x21
char *v20; // x0
GameLevelManager *v21; // x21
char *v22; // x0
GameLevelManager *v23; // x21
char *v24; // x0
GameLevelManager *v25; // x21
char *v26; // x0
GameLevelManager *v27; // x21
char *v28; // x0
GameLevelManager *v29; // x21
char *v30; // x0
GameLevelManager *v31; // x21
char *v32; // x0
cocos2d::CCDirector *v33; // x0
const char *v34; // x1
cocos2d::CCNode *v35; // x21
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x28
int (__fastcall *getTag)(const cocos2d::CCObject *__hidden); // x2
cocos2d::CCSprite *v38; // x21
cocos2d::CCDirector *v39; // x0
float v40; // s0
float v41; // s9
cocos2d::CCDirector *v42; // x0
float v43; // s0
cocos2d::CCSprite *v44; // x21
void (__fastcall *v45)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x28
void (__fastcall *v46)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x28
cocos2d::CCDirector *v47; // x0
float v48; // s0
float v49; // s9
cocos2d::CCDirector *v50; // x0
float v51; // s0
LoadingCircle *v52; // x0
LoadingCircle *m_circle; // x0
TextArea *v54; // x0
TextArea *m_noInternet; // x21
char *v56; // x0
void (__fastcall *v57)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCMenu *v58; // x21
cocos2d::CCSprite *v59; // x0
void (__fastcall *v60)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x22
cocos2d::CCDirector *v61; // x0
float v62; // s0
float v63; // s9
cocos2d::CCDirector *v64; // x0
float v65; // s0
cocos2d::CCSprite *v66; // x0
CCMenuItemSpriteExtra *v67; // x22
cocos2d::CCNode *v68; // x21
void (__fastcall *v69)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // x24
cocos2d::CCDirector *v70; // x0
float v71; // s0
float v72; // s8
cocos2d::CCDirector *v73; // x0
float v74; // s0
bool isControllerConnected; // w0
unsigned int *v77; // x1
int v78; // w2
unsigned int *v79; // x1
int v80; // w2
unsigned int *v81; // x1
int v82; // w2
unsigned int *v83; // x1
int v84; // w2
unsigned int *v85; // x1
int v86; // w2
unsigned int *v87; // x1
int v88; // w2
unsigned int *v89; // x1
int v90; // w2
unsigned int *v91; // x1
int v92; // w2
unsigned int *v93; // x1
int v94; // w2
unsigned int *v95; // x1
int v96; // w2
unsigned int *v97; // x1
int v98; // w2
unsigned int *v99; // x1
int v100; // w2
unsigned int *v101; // x1
int v102; // w2
void (__fastcall *setAnchorPoint)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [xsp+78h] [xbp+78h]
void (__fastcall *v104)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+78h] [xbp+78h]
void (__fastcall *v105)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // [xsp+78h] [xbp+78h]
CCMenuItemSpriteExtra *v106; // [xsp+78h] [xbp+78h]
float v107; // [xsp+90h] [xbp+90h]
float v108; // [xsp+94h] [xbp+94h]
cocos2d::CCPoint v109; // [xsp+98h] [xbp+98h] BYREF
char *v110; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::SEL_MenuHandler v111; // 0:x2.16
cocos2d::SEL_MenuHandler v112; // 0:x2.16
v6 = cocos2d::CCLayer::init(a1);
if ( v6 )
{
if ( a2 == Default )
a2 = Top100;
GameManager::sharedState()->m_searchObjectBool = 0;
v7 = GameManager::sharedState();
v8 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v7->m_sceneEnum = 6;
v8->setKeypadEnabled(a1, 1);
a1->setKeyboardEnabled(a1, 1);
if ( !GameManager::sharedState()->m_scoreValid )
{
v9 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 1, (__int64)&v110);
GameLevelManager::resetTimerForKey(v9, v110);
v10 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v85 = (unsigned int *)(v110 - 8);
do
v86 = __ldaxr(v85);
while ( __stlxr(v86 - 1, v85) );
}
else
{
v86 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v86 - 1;
}
if ( v86 <= 0 )
operator delete(v10);
}
v11 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 1, (__int64)&v110);
GameLevelManager::resetTimerForKey(v11, v110);
v12 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v89 = (unsigned int *)(v110 - 8);
do
v90 = __ldaxr(v89);
while ( __stlxr(v90 - 1, v89) );
}
else
{
v90 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v90 - 1;
}
if ( v90 <= 0 )
operator delete(v12);
}
v13 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 1, (__int64)&v110);
GameLevelManager::resetTimerForKey(v13, v110);
v14 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v97 = (unsigned int *)(v110 - 8);
do
v98 = __ldaxr(v97);
while ( __stlxr(v98 - 1, v97) );
}
else
{
v98 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v98 - 1;
}
if ( v98 <= 0 )
operator delete(v14);
}
v15 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 1, (__int64)&v110);
GameLevelManager::resetTimerForKey(v15, v110);
v16 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v93 = (unsigned int *)(v110 - 8);
do
v94 = __ldaxr(v93);
while ( __stlxr(v94 - 1, v93) );
}
else
{
v94 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v94 - 1;
}
if ( v94 <= 0 )
operator delete(v16);
}
v17 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey(&byte_4, (__int64)&v110);
GameLevelManager::resetTimerForKey(v17, v110);
v18 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v101 = (unsigned int *)(v110 - 8);
do
v102 = __ldaxr(v101);
while ( __stlxr(v102 - 1, v101) );
}
else
{
v102 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v102 - 1;
}
if ( v102 <= 0 )
operator delete(v18);
}
v19 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey(&byte_4, (__int64)&v110);
GameLevelManager::resetTimerForKey(v19, v110);
v20 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v87 = (unsigned int *)(v110 - 8);
do
v88 = __ldaxr(v87);
while ( __stlxr(v88 - 1, v87) );
}
else
{
v88 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v88 - 1;
}
if ( v88 <= 0 )
operator delete(v20);
}
v21 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey(&byte_4, (__int64)&v110);
GameLevelManager::resetTimerForKey(v21, v110);
v22 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v95 = (unsigned int *)(v110 - 8);
do
v96 = __ldaxr(v95);
while ( __stlxr(v96 - 1, v95) );
}
else
{
v96 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v96 - 1;
}
if ( v96 <= 0 )
operator delete(v22);
}
v23 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey(&byte_4, (__int64)&v110);
GameLevelManager::resetTimerForKey(v23, v110);
v24 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v91 = (unsigned int *)(v110 - 8);
do
v92 = __ldaxr(v91);
while ( __stlxr(v92 - 1, v91) );
}
else
{
v92 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v92 - 1;
}
if ( v92 <= 0 )
operator delete(v24);
}
v25 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 2, (__int64)&v110);
GameLevelManager::resetTimerForKey(v25, v110);
v26 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v99 = (unsigned int *)(v110 - 8);
do
v100 = __ldaxr(v99);
while ( __stlxr(v100 - 1, v99) );
}
else
{
v100 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v100 - 1;
}
if ( v100 <= 0 )
operator delete(v26);
}
v27 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 2, (__int64)&v110);
GameLevelManager::resetTimerForKey(v27, v110);
v28 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v79 = (unsigned int *)(v110 - 8);
do
v80 = __ldaxr(v79);
while ( __stlxr(v80 - 1, v79) );
}
else
{
v80 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v80 - 1;
}
if ( v80 <= 0 )
operator delete(v28);
}
v29 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 2, (__int64)&v110);
GameLevelManager::resetTimerForKey(v29, v110);
v30 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v81 = (unsigned int *)(v110 - 8);
do
v82 = __ldaxr(v81);
while ( __stlxr(v82 - 1, v81) );
}
else
{
v82 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v82 - 1;
}
if ( v82 <= 0 )
operator delete(v30);
}
v31 = GameLevelManager::sharedState();
GameLevelManager::sharedState();
GameLevelManager::getLeaderboardKey((_BYTE *)&dword_0 + 2, (__int64)&v110);
GameLevelManager::resetTimerForKey(v31, v110);
v32 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v83 = (unsigned int *)(v110 - 8);
do
v84 = __ldaxr(v83);
while ( __stlxr(v84 - 1, v83) );
}
else
{
v84 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v84 - 1;
}
if ( v84 <= 0 )
operator delete(v32);
}
}
v33 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v33);
v35 = (cocos2d::CCNode *)cocos2d::CCSprite::create((cocos2d::CCSprite *)"GJ_gradientBG.png", v34);
setAnchorPoint = v35->setAnchorPoint;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, 0.0, 0.0);
setAnchorPoint(v35, (const cocos2d::CCPoint *)&v110);
a1->addChild_0(a1, v35, -2);
v35->setScaleX(v35, (float)(v107 + 10.0) / v35[1].m_obContentSize.height);
v35->setScaleY(v35, (float)(v108 + 10.0) / v35[1].m_sAdditionalTransform.a);
setPosition = v35->setPosition;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, -5.0, -5.0);
setPosition(v35, (const cocos2d::CCPoint *)&v110);
getTag = v35->__vftable[1].getTag;
LOWORD(v110) = 26112;
BYTE2(v110) = -1;
((void (__fastcall *)(cocos2d::CCNode *, char **))getTag)(v35, &v110);
v38 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
v104 = v38->setAnchorPoint;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, 0.0, 0.0);
v104(v38, (const cocos2d::CCPoint *)&v110);
v105 = v38->setPosition;
v39 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v39);
v41 = v40;
v42 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenBottom(v42);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, v41 - 1.0, v43 - 1.0);
v105(v38, (const cocos2d::CCPoint *)&v110);
a1->addChild_0(a1, v38, 1);
v44 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_sideArt_001.png");
v45 = v44->setAnchorPoint;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, 1.0, 0.0);
v45(v44, (const cocos2d::CCPoint *)&v110);
v46 = v44->setPosition;
v47 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenRight(v47);
v49 = v48;
v50 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenBottom(v50);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, v49 + 1.0, v51 - 1.0);
v46(v44, (const cocos2d::CCPoint *)&v110);
cocos2d::CCSprite::setFlipX(v44, 1);
a1->addChild_0(a1, v44, 1);
v52 = LoadingCircle::create();
a1->m_circle = v52;
v52->m_parentLayer = a1;
m_circle = a1->m_circle;
m_circle->m_fade = 0;
cocos2d::CCObject::retain(m_circle);
LoadingCircle::show(a1->m_circle);
a1->m_circle->setVisible(a1->m_circle, 0);
sub_D153B8((int)&v110, "No Internet connection!");
cocos2d::CCPoint::CCPoint(&v109, 0.5, 1.0);
v54 = (TextArea *)TextArea::create((__int64)&v110, "bigFont.fnt", &v109, 0, 1.0, 600.0, 20.0);
a1->m_noInternet = v54;
m_noInternet = v54;
v56 = v110 - 24;
if ( v110 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v77 = (unsigned int *)(v110 - 8);
do
v78 = __ldaxr(v77);
while ( __stlxr(v78 - 1, v77) );
}
else
{
v78 = *((_DWORD *)v110 - 2);
*((_DWORD *)v110 - 2) = v78 - 1;
}
if ( v78 <= 0 )
operator delete(v56);
m_noInternet = a1->m_noInternet;
}
v57 = m_noInternet->setPosition;
m_noInternet->m_height = 30.0;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, v107 * 0.5, (float)(v108 * 0.5) + 10.0);
v57(m_noInternet, (const cocos2d::CCPoint *)&v110);
a1->m_noInternet->setScale(a1->m_noInternet, 0.6);
a1->addChild_0(a1, a1->m_noInternet, 2);
a1->m_noInternet->setVisible(a1->m_noInternet, 0);
v58 = cocos2d::CCMenu::create();
a1->addChild_0(a1, v58, 10);
v59 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_infoIcon_001.png");
v111.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v111.adj = (size_t)LeaderboardsLayer::onInfo;
v106 = CCMenuItemSpriteExtra::create(v59, nullptr, v111);
CCMenuItemSpriteExtra::setSizeMult(v106, 2.0);
v58->addChild(v58, v106);
v60 = v58->setPosition;
v61 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v61);
v63 = v62;
v64 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenBottom(v64);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, v63 + 30.0, v65 + 30.0);
v60(v58, (const cocos2d::CCPoint *)&v110);
LeaderboardsLayer::setupTabs(a1);
LeaderboardsLayer::selectLeaderboard(a1, a2, a3);
v66 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_arrow_01_001.png");
v112.ptr = (void (__cdecl *)(cocos2d::CCObject *))a1;
v112.adj = (size_t)LeaderboardsLayer::onBack;
v67 = CCMenuItemSpriteExtra::create(v66, nullptr, v112);
CCMenuItemSpriteExtra::setSizeMult(v67, 1.6);
v68 = (cocos2d::CCNode *)cocos2d::CCMenu::create((cocos2d::CCMenu *)v67, nullptr);
a1->addChild_0(a1, v68, 1);
v69 = v68->setPosition;
v70 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenLeft(v70);
v72 = v71;
v73 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getScreenTop(v73);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v110, v72 + 24.0, v74 - 23.0);
v69(v68, (const cocos2d::CCPoint *)&v110);
isControllerConnected = PlatformToolbox::isControllerConnected();
if ( isControllerConnected )
{
v6 = isControllerConnected;
GameToolbox::addBackButton(a1, v67);
}
}
return v6;
}