//
// GameLevelManager::updateLevelOrders from 0x6f1dcc to 0x6f1fd0 (516 bytes)
//
// 3 xrefs:
// > GameLevelManager::encodeDataTo @ 0x708ab4
// > GameLevelManager::encodeDataTo @ 0x708abc
// > ??> @ 0x2b4a0
//
// 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
//
void GameLevelManager::updateLevelOrders(GameLevelManager *a1)
{
unsigned int v2; // w19
cocos2d::CCArray *v3; // x25
cocos2d::CCArray *v4; // x20
int v5; // w0
cocos2d::CCString *v6; // x0
char *CString; // x0
cocos2d::CCDictionary *m_onlineLevels; // x28
__int64 v9; // x2
char *v10; // x0
unsigned int v11; // w19
int v12; // w20
__int64 v13; // x0
unsigned int v14; // w1
unsigned int *v15; // x1
int v16; // w3
__int64 v17; // [xsp+60h] [xbp+60h]
std::string v18; // [xsp+80h] [xbp+80h] BYREF
v2 = 0;
v3 = (cocos2d::CCArray *)cocos2d::CCArray::create(_stack_chk_guard);
v4 = cocos2d::CCDictionary::allKeys(a1->m_onlineLevels);
if ( (unsigned int)cocos2d::CCArray::count(v4) )
{
do
{
v5 = cocos2d::CCArray::count(v4);
v6 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v4, v5 + ~v2);
CString = (char *)cocos2d::CCString::getCString(v6);
m_onlineLevels = a1->m_onlineLevels;
sub_D153B8((int)&v18, CString);
v9 = cocos2d::CCDictionary::objectForKey(m_onlineLevels, &v18);
v10 = (char *)v18.m_data.m_data - 24;
if ( (__int64 *)v18.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)((char *)v18.m_data.m_data - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v18.m_data.m_data - 2);
*((_DWORD *)v18.m_data.m_data - 2) = v16 - 1;
}
if ( v16 <= 0 )
{
v17 = v9;
operator delete(v10);
v9 = v17;
}
}
if ( *(_BYTE *)(v9 + 833) )
{
*(_DWORD *)(v9 + 480) = 0;
++v2;
}
else
{
++v2;
cocos2d::CCArray::addObject(v3, (cocos2d::CCObject *)v9);
}
}
while ( v2 < (unsigned int)cocos2d::CCArray::count(v4) );
}
if ( (unsigned int)cocos2d::CCArray::count(v3) )
qsort(v3->data->arr, v3->data->num, 8u, (int (*)(const void *, const void *))savedLevelCompare);
v11 = 0;
v12 = cocos2d::CCArray::count(v3);
if ( v12 > 0 )
{
do
{
v13 = cocos2d::CCArray::objectAtIndex(v3, v11);
v14 = v12 - v11++;
*(_DWORD *)(v13 + 480) = v14;
}
while ( v12 != v11 );
}
}