//
// LocalLevelManager::dataLoaded from 0x7e96e8 to 0x7ea25c (2932 bytes)
//
// 2 xrefs:
// > ??> @ 0xb3988
// > ??> @ 0x1183c50
//
// 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 LocalLevelManager::dataLoaded(LocalLevelManager *a1, DS_Dictionary *a2)
{
cocos2d::CCArray *ArrayForKey; // x0
int updated; // w19
GJGameLevel *v5; // x24
double v6; // d0
cocos2d::CCArray *v7; // x20
unsigned int v8; // w22
int v9; // w21
int v10; // w0
unsigned int i; // w22
__int64 v12; // x23
unsigned int j; // w21
_QWORD *v14; // x22
stl::StringData::Internal *v15; // x27
__int64 *v16; // x23
__int64 *v17; // x28
size_t v18; // x2
int v19; // w2
unsigned int *v20; // x4
int v21; // w0
stl::StringData::Internal *m_data; // x1
char *v23; // x0
unsigned int v24; // w19
cocos2d::CCArray *v25; // x21
cocos2d::CCString *v26; // x0
char *CString; // x0
cocos2d::CCArray *v28; // x26
char *v29; // x0
unsigned int *v30; // x1
int v31; // w2
unsigned int *v32; // x1
int v33; // w2
unsigned int *v34; // x5
int v35; // w0
int v36; // w0
cocos2d::CCArray *v37; // x20
cocos2d::CCArray *v38; // x0
cocos2d::CCArray *v39; // x26
unsigned int v40; // w20
int v41; // w19
int v42; // w28
cocos2d::CCDictionary *v43; // x25
cocos2d::CCObject *v44; // x23
cocos2d::CCArray *v45; // x22
cocos2d::CCArray *v46; // x0
unsigned int v47; // w27
GJLevelList *v48; // x23
double v49; // d0
cocos2d::CCArray *v50; // x19
unsigned int v51; // w21
int v52; // w20
int v53; // w0
unsigned int k; // w21
__int64 v55; // x22
unsigned int m; // w20
char *v57; // x0
unsigned int v58; // w19
cocos2d::CCArray *v59; // x21
cocos2d::CCString *v60; // x0
char *v61; // x0
cocos2d::CCArray *v62; // x27
char *v63; // x0
unsigned int *v64; // x1
int v65; // w2
unsigned int *v66; // x1
int v67; // w2
char *v68; // x0
unsigned int *v69; // x1
int v70; // w2
unsigned int *v71; // x2
int v72; // w1
cocos2d::CCArray *v73; // x19
cocos2d::CCArray *m_localLists; // x0
cocos2d::CCArray *m_localLevels; // x0
cocos2d::CCDictionary *LevelsInNameGroups; // [xsp+80h] [xbp+80h]
cocos2d::CCArray *v78; // [xsp+88h] [xbp+88h]
int v80; // [xsp+A8h] [xbp+A8h]
unsigned int v81; // [xsp+ACh] [xbp+ACh]
unsigned __int64 v82; // [xsp+B0h] [xbp+B0h]
unsigned __int64 v83; // [xsp+B8h] [xbp+B8h]
int v84; // [xsp+B8h] [xbp+B8h]
int v85; // [xsp+B8h] [xbp+B8h]
std::string v86; // [xsp+D0h] [xbp+D0h] BYREF
_QWORD *v87; // [xsp+D8h] [xbp+D8h] BYREF
std::string v88; // [xsp+E0h] [xbp+E0h] BYREF
ArrayForKey = DS_Dictionary::getArrayForKey(a2, "LLM_01", 0);
v78 = ArrayForKey;
if ( a1->m_localLevels )
{
v81 = 0;
updated = LocalLevelManager::updateLevelOrder(a1);
v80 = cocos2d::CCArray::count(v78) + 1 + updated;
LevelsInNameGroups = LocalLevelManager::getLevelsInNameGroups(a1);
if ( !(unsigned int)cocos2d::CCArray::count(v78) )
goto LABEL_35;
while ( 1 )
{
v5 = (GJGameLevel *)cocos2d::CCArray::objectAtIndex(v78, v81);
v5->m_hasBeenModified = 0;
*(_QWORD *)&v6 = sub_D18D28(&v86).n128_u64[0];
if ( !*((_QWORD *)v86.m_data.m_data - 3) )
sub_D1798C(&v86, "Unknown", 7, v6);
v7 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(LevelsInNameGroups, &v86);
v8 = 0;
v9 = 0;
if ( !v7 )
{
v37 = (cocos2d::CCArray *)cocos2d::CCArray::create(nullptr);
cocos2d::CCArray::addObject(v37, v5);
v5->m_levelIndex = v80;
cocos2d::CCDictionary::setObject((int)LevelsInNameGroups, v37);
--v80;
goto LABEL_33;
}
while ( v8 < (unsigned int)cocos2d::CCArray::count(v7) )
{
v10 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v7, v8++) + 460);
if ( v9 < v10 )
v9 = v10;
}
for ( i = 0; ; ++i )
{
if ( i >= (unsigned int)cocos2d::CCArray::count(v7) )
{
for ( j = 0; ; ++j )
{
if ( j >= (unsigned int)cocos2d::CCArray::count(v7) )
{
cocos2d::CCArray::addObject(v7, v5);
v5->m_levelIndex = v80--;
LABEL_33:
m_data = v86.m_data.m_data;
v23 = (char *)v86.m_data.m_data - 24;
if ( (__int64 *)v86.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_34;
LABEL_46:
if ( &pthread_create )
{
v32 = (unsigned int *)((char *)m_data - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)m_data - 2);
*((_DWORD *)m_data - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v23);
goto LABEL_34;
}
cocos2d::CCArray::objectAtIndex(v7, j);
sub_D18D28(&v87);
sub_D18D28(&v88);
v14 = v87;
v15 = v88.m_data.m_data;
v16 = v87 - 3;
v17 = (__int64 *)((char *)v88.m_data.m_data - 24);
v82 = *(v87 - 3);
v83 = *((_QWORD *)v88.m_data.m_data - 3);
if ( v83 > v82 )
v18 = *(v87 - 3);
else
v18 = *((_QWORD *)v88.m_data.m_data - 3);
v19 = memcmp(v87, v88.m_data.m_data, v18);
if ( !v19 )
{
v19 = 0x7FFFFFFF;
if ( (__int64)(v82 - v83) <= 0x7FFFFFFF )
{
if ( (__int64)(v82 - v83) >= (__int64)0xFFFFFFFF80000000LL )
v19 = v82 - v83;
else
v19 = 0x80000000;
}
}
if ( v17 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v34 = (unsigned int *)((char *)v15 - 8);
do
v35 = __ldaxr(v34);
while ( __stlxr(v35 - 1, v34) );
if ( v35 <= 0 )
{
LABEL_59:
v85 = v19;
operator delete(v17);
v14 = v87;
v19 = v85;
v16 = v87 - 3;
goto LABEL_25;
}
}
else
{
v36 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v36 - 1;
if ( v36 <= 0 )
goto LABEL_59;
}
v14 = v87;
v16 = v87 - 3;
}
LABEL_25:
if ( v16 == &qword_124B6B0 )
goto LABEL_26;
if ( &pthread_create )
{
v20 = (unsigned int *)(v14 - 1);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v14 - 2);
*((_DWORD *)v14 - 2) = v21 - 1;
}
if ( v21 > 0 )
{
LABEL_26:
if ( !v19 )
goto LABEL_33;
}
else
{
v84 = v19;
operator delete(v16);
if ( !v84 )
goto LABEL_33;
}
}
}
v12 = cocos2d::CCArray::objectAtIndex(v7, i);
if ( *(_DWORD *)(v12 + 460) == v5->m_levelRev )
break;
}
if ( *(_BYTE *)(v12 + 526) )
{
cocos2d::CCArray::addObject(v7, v5);
*(_DWORD *)(v12 + 460) = v9 + 1;
v5->m_levelIndex = v80--;
goto LABEL_33;
}
GJGameLevel::handleStatsConflict(v5);
cocos2d::CCArray::removeObject(v7, (cocos2d::CCObject *)v12, 1);
cocos2d::CCArray::addObject(v7, v5);
m_data = v86.m_data.m_data;
v23 = (char *)v86.m_data.m_data - 24;
if ( (__int64 *)v86.m_data.m_data - 3 != &qword_124B6B0 )
goto LABEL_46;
LABEL_34:
if ( ++v81 >= (unsigned int)cocos2d::CCArray::count(v78) )
{
LABEL_35:
v24 = 0;
cocos2d::CCArray::removeAllObjects(a1->m_localLevels);
v25 = cocos2d::CCDictionary::allKeys(LevelsInNameGroups);
while ( v24 < (unsigned int)cocos2d::CCArray::count(v25) )
{
v26 = cocos2d::CCArray::stringAtIndex(v25, v24);
CString = (char *)cocos2d::CCString::getCString(v26);
sub_D153B8((int)&v88, CString);
v28 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(LevelsInNameGroups, &v88);
v29 = (char *)v88.m_data.m_data - 24;
if ( (__int64 *)v88.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v30 = (unsigned int *)((char *)v88.m_data.m_data - 8);
do
v31 = __ldaxr(v30);
while ( __stlxr(v31 - 1, v30) );
}
else
{
v31 = *((_DWORD *)v88.m_data.m_data - 2);
*((_DWORD *)v88.m_data.m_data - 2) = v31 - 1;
}
if ( v31 <= 0 )
operator delete(v29);
}
++v24;
cocos2d::CCArray::addObjectsFromArray(a1->m_localLevels, v28);
}
LocalLevelManager::reorderLevels(a1);
goto LABEL_63;
}
}
}
if ( ArrayForKey )
{
cocos2d::CCObject::retain(ArrayForKey);
m_localLevels = a1->m_localLevels;
if ( m_localLevels )
cocos2d::CCObject::release(m_localLevels);
a1->m_localLevels = v78;
}
LABEL_63:
v38 = DS_Dictionary::getArrayForKey(a2, "LLM_03", 0);
v39 = v38;
if ( a1->m_localLists )
{
v40 = 0;
v41 = LocalLevelManager::updateListOrder(a1);
v42 = cocos2d::CCArray::count(v39) + 1 + v41;
v43 = cocos2d::CCDictionary::create();
while ( v40 < (unsigned int)cocos2d::CCArray::count(a1->m_localLists) )
{
v44 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a1->m_localLists, v40);
sub_D18D28(&v88);
v45 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v43, &v88);
v46 = (cocos2d::CCArray *)((char *)v88.m_data.m_data - 24);
if ( (__int64 *)v88.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_66;
if ( &pthread_create )
{
v66 = (unsigned int *)((char *)v88.m_data.m_data - 8);
do
v67 = __ldaxr(v66);
while ( __stlxr(v67 - 1, v66) );
}
else
{
v67 = *((_DWORD *)v88.m_data.m_data - 2);
*((_DWORD *)v88.m_data.m_data - 2) = v67 - 1;
}
if ( v67 > 0 )
{
LABEL_66:
if ( !v45 )
goto LABEL_102;
}
else
{
operator delete(v46);
if ( !v45 )
{
LABEL_102:
v45 = (cocos2d::CCArray *)cocos2d::CCArray::create(v46);
sub_D18D28(&v88);
cocos2d::CCDictionary::setObject((int)v43, v45);
v68 = (char *)v88.m_data.m_data - 24;
if ( (__int64 *)v88.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = (unsigned int *)((char *)v88.m_data.m_data - 8);
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *((_DWORD *)v88.m_data.m_data - 2);
*((_DWORD *)v88.m_data.m_data - 2) = v70 - 1;
}
if ( v70 <= 0 )
operator delete(v68);
}
}
}
++v40;
cocos2d::CCArray::addObject(v45, v44);
}
v47 = 0;
while ( v47 < (unsigned int)cocos2d::CCArray::count(v39) )
{
v48 = (GJLevelList *)cocos2d::CCArray::objectAtIndex(v39, v47);
v48->m_modified = 0;
*(_QWORD *)&v49 = sub_D18D28(&v88).n128_u64[0];
if ( !*((_QWORD *)v88.m_data.m_data - 3) )
sub_D1798C(&v88, "Unknown", 7, v49);
v50 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v43, &v88);
v51 = 0;
v52 = 0;
if ( v50 )
{
while ( v51 < (unsigned int)cocos2d::CCArray::count(v50) )
{
v53 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v50, v51++) + 372);
if ( v52 < v53 )
v52 = v53;
}
for ( k = 0; k < (unsigned int)cocos2d::CCArray::count(v50); ++k )
{
v55 = cocos2d::CCArray::objectAtIndex(v50, k);
if ( *(_DWORD *)(v55 + 372) == v48->m_listRevision )
{
if ( *(_BYTE *)(v55 + 399) )
{
if ( !GJLevelList::hasMatchingLevels(v48) )
{
cocos2d::CCArray::addObject(v50, v48);
*(_DWORD *)(v55 + 372) = v52 + 1;
v48->m_listOrder = v42--;
}
}
else
{
GJLevelList::handleStatsConflict(v48);
cocos2d::CCArray::removeObject(v50, (cocos2d::CCObject *)v55, 1);
cocos2d::CCArray::addObject(v50, v48);
}
goto LABEL_85;
}
}
for ( m = 0; m < (unsigned int)cocos2d::CCArray::count(v50); ++m )
{
cocos2d::CCArray::objectAtIndex(v50, m);
if ( GJLevelList::hasMatchingLevels(v48) )
goto LABEL_85;
}
cocos2d::CCArray::addObject(v50, v48);
v48->m_listOrder = v42--;
}
else
{
v73 = (cocos2d::CCArray *)cocos2d::CCArray::create(nullptr);
cocos2d::CCArray::addObject(v73, v48);
v48->m_listOrder = v42--;
cocos2d::CCDictionary::setObject((int)v43, v73);
}
LABEL_85:
v57 = (char *)v88.m_data.m_data - 24;
if ( (__int64 *)v88.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_86;
if ( &pthread_create )
{
v71 = (unsigned int *)((char *)v88.m_data.m_data - 8);
do
v72 = __ldaxr(v71);
while ( __stlxr(v72 - 1, v71) );
}
else
{
v72 = *((_DWORD *)v88.m_data.m_data - 2);
*((_DWORD *)v88.m_data.m_data - 2) = v72 - 1;
}
if ( v72 > 0 )
{
LABEL_86:
++v47;
}
else
{
++v47;
operator delete(v57);
}
}
v58 = 0;
cocos2d::CCArray::removeAllObjects(a1->m_localLists);
v59 = cocos2d::CCDictionary::allKeys(v43);
while ( v58 < (unsigned int)cocos2d::CCArray::count(v59) )
{
v60 = cocos2d::CCArray::stringAtIndex(v59, v58);
v61 = (char *)cocos2d::CCString::getCString(v60);
sub_D153B8((int)&v88, v61);
v62 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v43, &v88);
v63 = (char *)v88.m_data.m_data - 24;
if ( (__int64 *)v88.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v64 = (unsigned int *)((char *)v88.m_data.m_data - 8);
do
v65 = __ldaxr(v64);
while ( __stlxr(v65 - 1, v64) );
}
else
{
v65 = *((_DWORD *)v88.m_data.m_data - 2);
*((_DWORD *)v88.m_data.m_data - 2) = v65 - 1;
}
if ( v65 <= 0 )
operator delete(v63);
}
++v58;
cocos2d::CCArray::addObjectsFromArray(a1->m_localLists, v62);
}
LocalLevelManager::reorderLists(a1);
}
else if ( v38 )
{
cocos2d::CCObject::retain(v38);
m_localLists = a1->m_localLists;
if ( m_localLists )
cocos2d::CCObject::release(m_localLists);
a1->m_localLists = v39;
}
if ( DS_Dictionary::getIntegerForKey(a2, "LLM_02") <= 18 )
LocalLevelManager::updateLevelRevision(a1);
}