//
// LocalLevelManager::dataLoaded from 0x140330a00 to 0x140331386 (2438 bytes)
//
// 2 xrefs:
// > ??> @ 0x1405aa680
// > ??> @ 0x1406d5048
//
// 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
//
// Hidden C++ exception states: #wind=4
void LocalLevelManager::dataLoaded(LocalLevelManager *a1, DS_Dictionary *a2)
{
LocalLevelManager *v2; // r13
struct cocos2d::CCArray *ArrayForKey; // rax
cocos2d::CCArray *v4; // r14
cocos2d::CCObject *m_localLevels; // rcx
int updated; // ebx
unsigned int v7; // r12d
__int64 v8; // rcx
cocos2d::CCDictionary *v9; // r15
unsigned int v10; // edi
struct cocos2d::CCObject *v11; // rsi
cocos2d::CCArray *v12; // rbx
__int64 v13; // rcx
unsigned int v14; // r13d
GJGameLevel *v15; // r14
cocos2d::CCArray *v16; // rax
__int64 v17; // rcx
cocos2d::CCArray *v18; // rdi
cocos2d::CCArray *v19; // rbx
int v20; // r15d
unsigned int v21; // ebx
int v22; // ecx
int v23; // r15d
unsigned int v24; // ebx
struct cocos2d::CCObject *v25; // rax
struct cocos2d::CCObject *v26; // rsi
unsigned int v27; // esi
struct cocos2d::CCObject *v28; // rbx
cocos2d::CCArray *v29; // rsi
unsigned int i; // ebx
cocos2d::CCString *v31; // rax
const char *CString; // rax
size_t v33; // r8
struct cocos2d::CCArray *v34; // rdi
void *v35; // rcx
struct cocos2d::CCArray *v36; // rax
cocos2d::CCArray *v37; // rsi
cocos2d::CCArray *m_localLists; // rcx
cocos2d::CCObject *v39; // rcx
int v40; // edi
unsigned int v41; // ebx
unsigned int v42; // eax
unsigned int v43; // r12d
__int64 v44; // rcx
cocos2d::CCDictionary *v45; // r15
unsigned int v46; // edi
struct cocos2d::CCObject *v47; // rsi
cocos2d::CCArray *v48; // rbx
__int64 v49; // rcx
unsigned int v50; // r13d
GJLevelList *v51; // rsi
cocos2d::CCArray *v52; // rax
__int64 v53; // rcx
cocos2d::CCArray *v54; // rbx
cocos2d::CCArray *v55; // rbx
int v56; // r15d
unsigned int v57; // edi
int m_uUnknown; // ecx
int v59; // r15d
unsigned int v60; // edi
struct cocos2d::CCObject *v61; // rax
struct cocos2d::CCObject *v62; // r14
unsigned int v63; // edi
cocos2d::CCArray *v64; // rsi
unsigned int j; // edi
cocos2d::CCString *v66; // rax
const char *v67; // rax
size_t v68; // r8
struct cocos2d::CCArray *v69; // rbx
int v70; // eax
struct cocos2d::CCObject *v71; // rdx
int m_listOrder; // ecx
int m_unknown2; // eax
cocos2d::CCDictionary *v74; // [rsp+20h] [rbp-69h]
cocos2d::CCDictionary *v75; // [rsp+20h] [rbp-69h]
cocos2d::CCArray *v76; // [rsp+28h] [rbp-61h]
cocos2d::CCArray *v77; // [rsp+28h] [rbp-61h]
__int128 v80; // [rsp+40h] [rbp-49h] BYREF
__int64 v81; // [rsp+50h] [rbp-39h]
unsigned __int64 v82; // [rsp+58h] [rbp-31h]
_QWORD Buf1[4]; // [rsp+60h] [rbp-29h] BYREF
_QWORD Buf2[4]; // [rsp+80h] [rbp-9h] BYREF
v2 = a1;
ArrayForKey = DS_Dictionary::getArrayForKey(a2, "LLM_01", 0);
v4 = ArrayForKey;
v76 = ArrayForKey;
if ( !v2->m_localLevels )
{
if ( ArrayForKey )
{
cocos2d::CCObject::retain(ArrayForKey);
m_localLevels = v2->m_localLevels;
if ( m_localLevels )
cocos2d::CCObject::release(m_localLevels);
v2->m_localLevels = v4;
}
goto LABEL_40;
}
updated = LocalLevelManager::updateLevelOrder(v2);
v7 = updated + cocos2d::CCArray::count(v4) + 1;
v9 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v8);
v74 = v9;
v10 = 0;
if ( cocos2d::CCArray::count(v2->m_localLevels) )
{
do
{
v11 = cocos2d::CCArray::objectAtIndex(v2->m_localLevels, v10);
sub_14003BDB0((__int64)&v80, (__int64)&v11[6].m_uID);
v12 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v9, &v80);
sub_14003A830((__int64)&v80);
if ( !v12 )
{
v12 = (cocos2d::CCArray *)cocos2d::CCArray::create(v13);
sub_14003BDB0((__int64)Buf1, (__int64)&v11[6].m_uID);
cocos2d::CCDictionary::setObject(v9, v12, Buf1);
sub_14003A830((__int64)Buf1);
}
cocos2d::CCArray::addObject(v12, v11);
++v10;
}
while ( v10 < cocos2d::CCArray::count(v2->m_localLevels) );
v4 = v76;
}
v14 = 0;
if ( cocos2d::CCArray::count(v4) )
{
while ( 1 )
{
v15 = (GJGameLevel *)cocos2d::CCArray::objectAtIndex(v4, v14);
v15->m_hasBeenModified = 0;
sub_14003BDB0((__int64)&v80, (__int64)&v15->m_levelName);
if ( !v81 )
sub_14003CCE0((void **)&v80, &qword_1405515B8, 7u);
v16 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v9, &v80);
v18 = v16;
if ( v16 )
break;
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v17);
cocos2d::CCArray::addObject(v19, v15);
v15->m_levelIndex = v7--;
cocos2d::CCDictionary::setObject(v9, v19, &v80);
LABEL_29:
sub_14003A830((__int64)&v80);
++v14;
v4 = v76;
if ( v14 >= cocos2d::CCArray::count(v76) )
goto LABEL_30;
}
v20 = 0;
v21 = 0;
if ( cocos2d::CCArray::count(v16) )
{
do
{
v22 = HIDWORD(cocos2d::CCArray::objectAtIndex(v18, v21)[12].__vftable);
if ( v22 <= v20 )
v22 = v20;
v20 = v22;
++v21;
}
while ( v21 < cocos2d::CCArray::count(v18) );
}
v23 = v20 + 1;
v24 = 0;
if ( cocos2d::CCArray::count(v18) )
{
while ( 1 )
{
v25 = cocos2d::CCArray::objectAtIndex(v18, v24);
v26 = v25;
if ( HIDWORD(v25[12].__vftable) == v15->m_levelRev )
break;
if ( ++v24 >= cocos2d::CCArray::count(v18) )
goto LABEL_23;
}
if ( !BYTE2(v25[13].m_nLuaID) )
{
GJGameLevel::handleStatsConflict(v15);
cocos2d::CCArray::removeObject(v18, v26, 1);
cocos2d::CCArray::addObject(v18, v15);
goto LABEL_28;
}
cocos2d::CCArray::addObject(v18, v15);
HIDWORD(v26[12].__vftable) = v23;
}
else
{
LABEL_23:
v27 = 0;
if ( cocos2d::CCArray::count(v18) )
{
do
{
v28 = cocos2d::CCArray::objectAtIndex(v18, v27);
sub_14003BDB0((__int64)Buf2, (__int64)&v15->m_levelString);
sub_14003BDB0((__int64)Buf1, (__int64)&v28[7].m_nTag);
LODWORD(v28) = sub_14003A760(Buf1, Buf2);
sub_14003A830((__int64)Buf1);
sub_14003A830((__int64)Buf2);
if ( !(_DWORD)v28 )
goto LABEL_28;
}
while ( ++v27 < cocos2d::CCArray::count(v18) );
}
cocos2d::CCArray::addObject(v18, v15);
}
v15->m_levelIndex = v7--;
LABEL_28:
v9 = v74;
goto LABEL_29;
}
LABEL_30:
v2 = a1;
cocos2d::CCArray::removeAllObjects(a1->m_localLevels);
v29 = cocos2d::CCDictionary::allKeys(v9);
for ( i = 0; i < cocos2d::CCArray::count(v29); ++i )
{
v31 = cocos2d::CCArray::stringAtIndex(v29, i);
CString = cocos2d::CCString::getCString(v31);
v80 = 0;
v81 = 0;
v82 = 0;
v33 = -1;
do
++v33;
while ( CString[v33] );
sub_14003A930(&v80, CString, v33);
v34 = (struct cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v9, &v80);
if ( v82 > 0xF )
{
v35 = (void *)v80;
if ( v82 + 1 >= 0x1000 )
{
v35 = *(void **)(v80 - 8);
if ( (unsigned __int64)(v80 - (_QWORD)v35 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v35);
}
v81 = 0;
v82 = 15;
LOBYTE(v80) = 0;
cocos2d::CCArray::addObjectsFromArray(a1->m_localLevels, v34);
}
if ( cocos2d::CCArray::count(a1->m_localLevels) )
qsort(
a1->m_localLevels->data->arr,
a1->m_localLevels->data->num,
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_140142B30);
LABEL_40:
v36 = DS_Dictionary::getArrayForKey(a2, "LLM_03", 0);
v37 = v36;
v77 = v36;
m_localLists = v2->m_localLists;
if ( !m_localLists )
{
if ( v36 )
{
cocos2d::CCObject::retain(v36);
v39 = v2->m_localLists;
if ( v39 )
cocos2d::CCObject::release(v39);
v2->m_localLists = v37;
}
goto LABEL_81;
}
v40 = 0;
v41 = 0;
if ( cocos2d::CCArray::count(m_localLists) )
{
do
{
v42 = cocos2d::CCArray::count(v2->m_localLists);
cocos2d::CCArray::objectAtIndex(v2->m_localLists, v42 + -1 - v41++)[6].m_unknown2 = v40++;
}
while ( v41 < cocos2d::CCArray::count(v2->m_localLists) );
}
v43 = v40 + cocos2d::CCArray::count(v37) + 1;
v45 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v44);
v75 = v45;
v46 = 0;
if ( cocos2d::CCArray::count(v2->m_localLists) )
{
do
{
v47 = cocos2d::CCArray::objectAtIndex(v2->m_localLists, v46);
sub_14003BDB0((__int64)Buf2, (__int64)&v47[7].m_unknown2);
v48 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v45, Buf2);
sub_14003A830((__int64)Buf2);
if ( !v48 )
{
v48 = (cocos2d::CCArray *)cocos2d::CCArray::create(v49);
sub_14003BDB0((__int64)Buf1, (__int64)&v47[7].m_unknown2);
cocos2d::CCDictionary::setObject(v45, v48, Buf1);
sub_14003A830((__int64)Buf1);
}
cocos2d::CCArray::addObject(v48, v47);
++v46;
}
while ( v46 < cocos2d::CCArray::count(v2->m_localLists) );
v37 = v77;
}
v50 = 0;
if ( cocos2d::CCArray::count(v37) )
{
while ( 1 )
{
v51 = (GJLevelList *)cocos2d::CCArray::objectAtIndex(v37, v50);
v51->m_modified = 0;
sub_14003BDB0((__int64)&v80, (__int64)&v51->m_listName);
if ( !v81 )
sub_14003CCE0((void **)&v80, &qword_1405515B8, 7u);
v52 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v45, &v80);
v54 = v52;
if ( v52 )
break;
v55 = (cocos2d::CCArray *)cocos2d::CCArray::create(v53);
cocos2d::CCArray::addObject(v55, v51);
v51->m_listOrder = v43--;
cocos2d::CCDictionary::setObject(v45, v55, &v80);
LABEL_74:
sub_14003A830((__int64)&v80);
++v50;
v37 = v77;
if ( v50 >= cocos2d::CCArray::count(v77) )
goto LABEL_75;
}
v56 = 0;
v57 = 0;
if ( cocos2d::CCArray::count(v52) )
{
do
{
m_uUnknown = cocos2d::CCArray::objectAtIndex(v54, v57)[6].m_uUnknown;
if ( m_uUnknown <= v56 )
m_uUnknown = v56;
v56 = m_uUnknown;
++v57;
}
while ( v57 < cocos2d::CCArray::count(v54) );
}
v59 = v56 + 1;
v60 = 0;
if ( cocos2d::CCArray::count(v54) )
{
while ( 1 )
{
v61 = cocos2d::CCArray::objectAtIndex(v54, v60);
v62 = v61;
if ( v61[6].m_uUnknown == v51->m_listRevision )
break;
if ( ++v60 >= cocos2d::CCArray::count(v54) )
goto LABEL_68;
}
v71 = v61;
if ( !HIBYTE(v61[7].__vftable) )
{
m_listOrder = v51->m_listOrder;
m_unknown2 = v61[6].m_unknown2;
if ( m_listOrder <= m_unknown2 )
m_listOrder = m_unknown2;
v51->m_listOrder = m_listOrder;
cocos2d::CCArray::removeObject(v54, v71, 1);
cocos2d::CCArray::addObject(v54, v51);
goto LABEL_73;
}
if ( GJLevelList::hasMatchingLevels(v51) )
{
LABEL_73:
v45 = v75;
goto LABEL_74;
}
cocos2d::CCArray::addObject(v54, v51);
v62[6].m_uUnknown = v59;
}
else
{
LABEL_68:
v63 = 0;
if ( cocos2d::CCArray::count(v54) )
{
do
{
cocos2d::CCArray::objectAtIndex(v54, v63);
if ( GJLevelList::hasMatchingLevels(v51) )
goto LABEL_73;
}
while ( ++v63 < cocos2d::CCArray::count(v54) );
}
cocos2d::CCArray::addObject(v54, v51);
}
v51->m_listOrder = v43--;
goto LABEL_73;
}
LABEL_75:
v2 = a1;
cocos2d::CCArray::removeAllObjects(a1->m_localLists);
v64 = cocos2d::CCDictionary::allKeys(v45);
for ( j = 0; j < cocos2d::CCArray::count(v64); ++j )
{
v66 = cocos2d::CCArray::stringAtIndex(v64, j);
v67 = cocos2d::CCString::getCString(v66);
v80 = 0;
v81 = 0;
v82 = 0;
v68 = -1;
do
++v68;
while ( v67[v68] );
sub_14003A930(&v80, v67, v68);
v69 = (struct cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(v45, &v80);
sub_14003A830((__int64)&v80);
cocos2d::CCArray::addObjectsFromArray(a1->m_localLists, v69);
}
if ( cocos2d::CCArray::count(a1->m_localLists) )
qsort(
a1->m_localLists->data->arr,
a1->m_localLists->data->num,
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_140142B60);
LABEL_81:
DS_Dictionary::getIntegerForKey(a2, "LLM_02");
if ( v70 < 19 )
LocalLevelManager::updateLevelRevision(v2);
}