//
// GameLevelManager::onGetLevelLeaderboardCompleted from 0x719f28 to 0x71a1fc (724 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x7322d4
// > ??> @ 0xa4c58
//
// 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::onGetLevelLeaderboardCompleted(
GameLevelManager *a1,
const char **a2,
const char **a3)
{
char *v4; // x23
char *v7; // x0
int v8; // w26
cocos2d::CCArray *Scores; // x22
char *v10; // x0
char *v11; // x0
LeaderboardManagerDelegate *v12; // x0
LeaderboardManagerDelegate *m_leaderboardManagerDelegate; // x0
__int64 v15; // x0
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x20
int v21; // w1
int v22; // [xsp+64h] [xbp+64h] BYREF
int v23; // [xsp+68h] [xbp+68h] BYREF
int v24; // [xsp+6Ch] [xbp+6Ch] BYREF
char *v25; // [xsp+70h] [xbp+70h] BYREF
v4 = (char *)*a3;
GameLevelManager::removeDLFromActive(a1, *a3);
v22 = 0;
v23 = 0;
v24 = 0;
sub_D18D28(&v25);
parseLevelLeaderboardKey(&v25, &v22, &v23, &v24);
v7 = v25 - 24;
if ( v25 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)(v25 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v7);
}
v8 = atoi(*a2);
if ( v23 == 4 )
{
v15 = cocos2d::CCDictionary::objectForKey(a1->m_localLeaderboardLevels, (const std::string *)a3);
if ( v15 && (v8 & 0x80000000) == 0 )
{
if ( v24 )
{
if ( v24 == 1 )
*(_BYTE *)(v15 + 1017) = 0;
}
else
{
*(_BYTE *)(v15 + 1016) = 0;
}
}
cocos2d::CCDictionary::removeObjectForKey(a1->m_localLeaderboardLevels, (const std::string *)a3);
}
else if ( v8 < 0 )
{
m_leaderboardManagerDelegate = a1->m_leaderboardManagerDelegate;
if ( m_leaderboardManagerDelegate )
m_leaderboardManagerDelegate->loadLeaderboardFailed(m_leaderboardManagerDelegate, (const unsigned __int8 *)v4);
}
else
{
sub_D18D28(&v25);
Scores = GameLevelManager::createAndGetScores(a1, &v25, 3);
v10 = v25 - 24;
if ( v25 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v25 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v10);
}
sub_D153B8((int)&v25, " ");
GameLevelManager::storeSearchResult(a1, Scores, &v25, v4);
v11 = v25 - 24;
if ( v25 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v25 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v25 - 2);
*((_DWORD *)v25 - 2) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v11);
}
v12 = a1->m_leaderboardManagerDelegate;
if ( v12 )
v12->loadLeaderboardFinished(v12, Scores, (const unsigned __int8 *)v4);
}
return _stack_chk_guard;
}