//
// GameLevelManager::onGetLeaderboardScoresCompleted from 0x10008b85c to 0x10008baec (656 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x100089570
//
// 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
//
__int64 __fastcall GameLevelManager::onGetLeaderboardScoresCompleted(GameLevelManager *a1, void **a2, __int64 a3)
{
const char *v6; // x19
cocos2d::CCArray *v7; // x23
cocos2d::CCString *v8; // x0
int v9; // w22
cocos2d::CCString *v10; // x0
int v11; // w23
int v12; // w25
_BOOL4 v13; // w0
_BOOL4 v14; // w24
__int64 result; // x0
__int64 Scores; // x21
unsigned int *v17; // x8
__int64 v18; // x9
unsigned __int64 v19; // x8
unsigned __int64 v20; // x9
int (__cdecl *v21)(const void *, const void *); // x3
unsigned int *v22; // x8
__int64 v23; // x9
unsigned __int64 v24; // x8
unsigned __int64 v25; // x9
int v26; // w10
void *v27[2]; // [xsp+8h] [xbp-88h] BYREF
char v28; // [xsp+1Fh] [xbp-71h]
void *__dst[2]; // [xsp+20h] [xbp-70h] BYREF
void *v30; // [xsp+30h] [xbp-60h]
void *__p[2]; // [xsp+38h] [xbp-58h] BYREF
char v32; // [xsp+4Fh] [xbp-41h]
v6 = (const char *)a3;
if ( *(char *)(a3 + 23) < 0 )
v6 = *(const char **)a3;
GameLevelManager::removeDLFromActive(a1, v6);
v7 = (cocos2d::CCArray *)sub_100093338(a3, "_");
if ( (unsigned int)sub_10024A36C(v7) == 3 )
{
v8 = cocos2d::CCArray::stringAtIndex(v7, 1u);
v9 = cocos2d::CCString::intValue(v8);
}
else
{
v9 = 0;
}
if ( (unsigned int)sub_10024A36C(v7) == 3 )
{
v10 = cocos2d::CCArray::stringAtIndex(v7, 2u);
v11 = cocos2d::CCString::intValue(v10);
}
else
{
v11 = 0;
}
if ( v9 == 3 )
v12 = 0;
else
v12 = v11;
sub_100009900(__p, "-1");
v13 = sub_1000045BC(a2, __p);
v14 = v13;
if ( v32 < 0 )
{
operator delete(__p[0]);
if ( v14 )
{
LABEL_14:
result = (__int64)a1->m_leaderboardManagerDelegate;
if ( result )
return (*(__int64 (__fastcall **)(__int64, const char *))(*(_QWORD *)result + 24LL))(result, v6);
return result;
}
}
else if ( v13 )
{
goto LABEL_14;
}
if ( *((char *)a2 + 23) < 0 )
{
sub_1000097D0(__dst, *a2, (unsigned __int64)a2[1]);
}
else
{
*(_OWORD *)__dst = *(_OWORD *)a2;
v30 = a2[2];
}
Scores = GameLevelManager::createAndGetScores(a1, __dst, v9 == 3);
if ( SHIBYTE(v30) < 0 )
operator delete(__dst[0]);
if ( (unsigned int)sub_10024A36C(Scores) )
{
if ( v12 )
{
if ( Scores )
{
v17 = *(unsigned int **)(Scores + 56);
v18 = *v17;
if ( (_DWORD)v18 )
{
v19 = *((_QWORD *)v17 + 2);
v20 = v19 + 8 * v18 - 8;
do
{
if ( !*(_QWORD *)v19 )
break;
*(_DWORD *)(*(_QWORD *)v19 + 808LL) = v12;
v19 += 8LL;
}
while ( v19 <= v20 );
}
}
}
}
if ( (unsigned int)sub_10024A36C(Scores) && v9 == 4 )
{
v21 = (unsigned int)(v11 - 1) > 2
? (int (__cdecl *)(const void *, const void *))sub_10008794C
: (int (__cdecl *)(const void *, const void *))off_1007815C8[v11 - 1];
qsort(*(void **)(*(_QWORD *)(Scores + 56) + 16LL), **(unsigned int **)(Scores + 56), 8u, v21);
v22 = *(unsigned int **)(Scores + 56);
v23 = *v22;
if ( (_DWORD)v23 )
{
v24 = *((_QWORD *)v22 + 2);
v25 = v24 + 8 * v23 - 8;
v26 = 1;
do
{
if ( !*(_QWORD *)v24 )
break;
*(_DWORD *)(*(_QWORD *)v24 + 396LL) = v26++;
v24 += 8LL;
}
while ( v24 <= v25 );
}
}
sub_100009900(v27, " ");
GameLevelManager::storeSearchResult(a1, Scores, v27, v6);
if ( v28 < 0 )
operator delete(v27[0]);
result = (__int64)a1->m_leaderboardManagerDelegate;
if ( result )
return (*(__int64 (__fastcall **)(__int64, __int64, const char *))(*(_QWORD *)result + 16LL))(result, Scores, v6);
return result;
}