//
// GameLevelManager::getSavedLevels from 0x6f1a8c to 0x6f1c80 (500 bytes)
//
// 6 xrefs:
// > LevelBrowserLayer::loadPage @ 0x6e9d24
// > LevelBrowserLayer::loadPage @ 0x6ea1f4
// > LevelBrowserLayer::FLAlert_Clicked @ 0x6ed564
// > LevelBrowserLayer::FLAlert_Clicked @ 0x6ed664
// > GameLevelManager::limitSavedLevels @ 0x6f31c4
// > ??> @ 0x7aaf0
//
// 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
//
cocos2d::CCArray *GameLevelManager::getSavedLevels(GameLevelManager *a1, bool a2, int a3)
{
_BOOL4 v4; // w26
unsigned int v6; // w19
cocos2d::CCArray *v7; // x27
cocos2d::CCArray *v8; // x20
int v9; // w0
cocos2d::CCString *v10; // x0
char *CString; // x0
cocos2d::CCDictionary *m_onlineLevels; // x28
__int64 v13; // x2
char *v14; // x0
unsigned int *v16; // x1
int v17; // w3
__int64 v18; // [xsp+60h] [xbp+60h]
std::string v19; // [xsp+80h] [xbp+80h] BYREF
v4 = a2;
v6 = 0;
v7 = (cocos2d::CCArray *)cocos2d::CCArray::create(_stack_chk_guard);
v8 = cocos2d::CCDictionary::allKeys(a1->m_onlineLevels);
if ( (unsigned int)cocos2d::CCArray::count(v8) )
{
do
{
v9 = cocos2d::CCArray::count(v8);
v10 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v8, v9 + ~v6);
CString = (char *)cocos2d::CCString::getCString(v10);
m_onlineLevels = a1->m_onlineLevels;
sub_D153B8((int)&v19, CString);
v13 = cocos2d::CCDictionary::objectForKey(m_onlineLevels, &v19);
v14 = (char *)v19.m_data.m_data - 24;
if ( (__int64 *)v19.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v19.m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v19.m_data.m_data - 2);
*((_DWORD *)v19.m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
{
v18 = v13;
operator delete(v14);
v13 = v18;
}
}
if ( !*(_BYTE *)(v13 + 833) && (!v4 || *(_BYTE *)(v13 + 652)) && (a3 <= 0 || a3 == *(_DWORD *)(v13 + 656)) )
{
++v6;
cocos2d::CCArray::addObject(v7, (cocos2d::CCObject *)v13);
}
else
{
++v6;
}
}
while ( v6 < (unsigned int)cocos2d::CCArray::count(v8) );
}
if ( (unsigned int)cocos2d::CCArray::count(v7) )
qsort(v7->data->arr, v7->data->num, 8u, (int (*)(const void *, const void *))savedLevelCompare);
return v7;
}