//
// GameLevelManager::getLeaderboardScores from 0x720238 to 0x72079c (1380 bytes)
//
// 2 xrefs:
// > LeaderboardsLayer::selectLeaderboard @ 0x81ea74
// > ??> @ 0x4a418
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void GameLevelManager::getLeaderboardScores(GameLevelManager *a1, LeaderboardType a2, LeaderboardStat a3)
{
char *v6; // x0
GJAccountManager *v7; // x0
LeaderboardManagerDelegate *m_leaderboardManagerDelegate; // x0
unsigned int *v9; // x2
int v10; // w1
unsigned int v11; // w26
const char *v12; // x24
cocos2d::CCString *v13; // x0
const char *CString; // x0
cocos2d::CCString *v15; // x0
size_t v16; // x0
int *p_m_unknown2; // x0
char *v18; // x0
char *v19; // x0
char *v20; // x0
void *v21; // x0
unsigned int *v22; // x1
int v23; // w2
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x1
int v27; // w2
unsigned int *v28; // x1
int v29; // w2
unsigned int *p_timeoutForConnect; // x1
int timeoutForConnect; // w2
unsigned int *v32; // x1
int v33; // w2
const char *v34; // [xsp+58h] [xbp+58h]
char *v35; // [xsp+78h] [xbp+78h] BYREF
__int64 v36; // [xsp+80h] [xbp+80h] BYREF
char *v37; // [xsp+88h] [xbp+88h] BYREF
const char *v38; // [xsp+90h] [xbp+90h] BYREF
const char *v39; // [xsp+98h] [xbp+98h] BYREF
cocos2d::extension::CCHttpClient *v40; // [xsp+A0h] [xbp+A0h] BYREF
GameLevelManager::getLeaderboardKey(*(const char **)&a2, (__int64)&v35);
if ( a2 == Friends && (v7 = GJAccountManager::sharedState(), v7->m_accountID - v7->m_unkInt1 <= 0) )
{
m_leaderboardManagerDelegate = a1->m_leaderboardManagerDelegate;
if ( m_leaderboardManagerDelegate )
m_leaderboardManagerDelegate->loadLeaderboardFailed(m_leaderboardManagerDelegate, (const unsigned __int8 *)v35);
}
else if ( !GameLevelManager::isDLActive(a1, v35) )
{
GameLevelManager::addDLToActive(a1, v35);
if ( a2 == Global )
{
v11 = 50;
v12 = "relative";
}
else
{
v11 = 100;
if ( a2 == Friends )
{
v12 = "friends";
}
else if ( a2 == Creator )
{
v12 = "creators";
}
else
{
v12 = "top";
}
}
GameManager::sharedState();
sub_D18D28(&v36);
GameLevelManager::getBasePostString(a1, (__int64)&v37);
if ( a2 == Creator )
a3 = Stars;
v13 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
CString = cocos2d::CCString::getCString(v13);
v15 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&type=%s&count=%i&stat=%i&secret=%s",
v12,
v11,
(unsigned int)a3,
CString);
v34 = cocos2d::CCString::getCString(v15);
v16 = strlen(v34);
sub_D15FD4(&v37, v34, v16);
sub_D153B8((int)&v38, "https://www.boomlings.com/database/getGJScores20.php");
sub_D153B8((int)&v39, v37);
sub_D18D28(&v40);
GameLevelManager::ProcessHttpRequest(a1, &v38, &v39, &v40, 11);
p_m_unknown2 = &v40[-1].m_unknown2;
if ( &v40[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v40[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v40[-1]._timeoutForConnect;
v40[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
}
v18 = (char *)(v39 - 24);
if ( v39 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v39 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v18);
}
v19 = (char *)(v38 - 24);
if ( v38 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v28 = (unsigned int *)(v38 - 8);
do
v29 = __ldaxr(v28);
while ( __stlxr(v29 - 1, v28) );
}
else
{
v29 = *((_DWORD *)v38 - 2);
*((_DWORD *)v38 - 2) = v29 - 1;
}
if ( v29 <= 0 )
operator delete(v19);
}
v20 = v37 - 24;
if ( v37 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v37 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *((_DWORD *)v37 - 2);
*((_DWORD *)v37 - 2) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v20);
}
v21 = (void *)(v36 - 24);
if ( (__int64 *)(v36 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v36 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *(_DWORD *)(v36 - 8);
*(_DWORD *)(v36 - 8) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v21);
}
v6 = v35 - 24;
if ( v35 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v35 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *((_DWORD *)v35 - 2);
*((_DWORD *)v35 - 2) = v23 - 1;
}
if ( v23 <= 0 )
goto LABEL_12;
}
return;
}
v6 = v35 - 24;
if ( v35 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)(v35 - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *((_DWORD *)v35 - 2);
*((_DWORD *)v35 - 2) = v10 - 1;
}
if ( v10 <= 0 )
LABEL_12:
operator delete(v6);
}
}