//
// GameLevelManager::onGetMapPacksCompleted from 0x14014f700 to 0x14014fded (1773 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x1401430e9
// > ??> @ 0x1406ca818
//
// 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=8
void __fastcall GameLevelManager::onGetMapPacksCompleted(GameLevelManager *a1, const void **a2, __int64 a3)
{
const char *v6; // r13
const void *v7; // rcx
unsigned __int64 v8; // rdi
unsigned __int64 v9; // rbx
size_t v10; // r8
_BYTE *v11; // rdx
size_t v12; // r8
cocos2d::CCArray *v13; // rbx
LevelManagerDelegate *m_levelManagerDelegate; // rcx
__int64 v15; // rcx
cocos2d::CCString *v16; // rax
const char *CString; // rax
size_t v18; // r8
cocos2d::CCString *v19; // rax
const char *v20; // rax
size_t v21; // r8
cocos2d::CCString *v22; // rax
const char *v23; // rax
size_t v24; // r8
__int64 v25; // rax
__int64 v26; // rcx
cocos2d::CCArray *MapPacks; // r14
unsigned int i; // ebx
struct cocos2d::CCObject *v29; // rdi
cocos2d::CCString *v30; // rax
const char *v31; // rax
size_t v32; // r8
char *p_Buf2; // rdx
__int128 *v34; // rax
cocos2d::CCString *v35; // rax
char *v36; // rax
size_t v37; // r8
cocos2d::CCString *v38; // rax
char *v39; // rax
size_t v40; // r8
void *v41; // rcx
cocos2d::CCString *v42; // rax
char *v43; // rax
size_t v44; // r8
__int128 *v45; // r9
__int128 *v46; // r8
__int64 v47; // rdx
size_t v48; // r8
int v49; // ebx
LevelManagerDelegate *v50; // rcx
unsigned int j; // ebx
__int64 v52; // rdx
__int64 v53; // rcx
__int64 v54; // r8
__int64 v55; // r9
struct cocos2d::CCObject *v56; // rdi
cocos2d::CCString *v57; // rax
const char *v58; // rax
size_t v59; // r8
void *v60; // rcx
__int64 v61; // rax
void **v62; // rsi
__int64 v63; // rbx
unsigned __int64 v64; // rdi
LevelManagerDelegate *v65; // rcx
char v67[32]; // [rsp+50h] [rbp-B0h] BYREF
const void **v68; // [rsp+70h] [rbp-90h]
__int64 v69; // [rsp+78h] [rbp-88h]
__int128 Buf2; // [rsp+80h] [rbp-80h] BYREF
__int128 v71; // [rsp+90h] [rbp-70h]
__int128 v72; // [rsp+A0h] [rbp-60h] BYREF
__int64 v73; // [rsp+B0h] [rbp-50h]
unsigned __int64 v74; // [rsp+B8h] [rbp-48h]
void *Src[2]; // [rsp+C0h] [rbp-40h] BYREF
unsigned __int64 v76; // [rsp+D0h] [rbp-30h]
unsigned __int64 v77; // [rsp+D8h] [rbp-28h]
_OWORD Buf1[2]; // [rsp+E0h] [rbp-20h] BYREF
_OWORD v79[2]; // [rsp+100h] [rbp+0h] BYREF
unsigned __int8 v80[24]; // [rsp+120h] [rbp+20h] BYREF
_BYTE v81[48]; // [rsp+138h] [rbp+38h] BYREF
v68 = a2;
v69 = a3;
v6 = (const char *)a3;
if ( *(_QWORD *)(a3 + 24) > 0xFu )
v6 = *(const char **)a3;
GameLevelManager::removeDLFromActive(a1, v6);
Buf2 = 0;
*(_QWORD *)&v71 = 2;
*((_QWORD *)&v71 + 1) = 15;
strcpy((char *)&Buf2, "-1");
v7 = a2;
v8 = (unsigned __int64)a2[3];
if ( v8 > 0xF )
v7 = *a2;
v9 = (unsigned __int64)a2[2];
v10 = v9;
if ( v9 > 2 )
v10 = 2;
if ( !memcmp(v7, &Buf2, v10) && v9 == 2 )
goto LABEL_14;
v11 = a2;
if ( v8 > 0xF )
v11 = *a2;
Buf2 = 0;
v71 = 0;
v12 = -1;
do
++v12;
while ( v11[v12] );
sub_14003A930(&Buf2, v11, v12);
v13 = sub_140140F70((__int64 *)&Buf2, "#");
sub_14003A830((__int64)&Buf2);
if ( cocos2d::CCArray::count(v13) < 3 )
{
LABEL_14:
m_levelManagerDelegate = a1->m_levelManagerDelegate;
if ( m_levelManagerDelegate )
m_levelManagerDelegate->loadLevelsFailed_0(m_levelManagerDelegate, v6);
sub_14003A830((__int64)a2);
v15 = a3;
}
else
{
v16 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 0);
CString = cocos2d::CCString::getCString(v16);
memset(v79, 0, sizeof(v79));
v18 = -1;
do
++v18;
while ( CString[v18] );
sub_14003A930(v79, CString, v18);
v19 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 1u);
v20 = cocos2d::CCString::getCString(v19);
*(_OWORD *)Src = 0;
v76 = 0;
v77 = 0;
v21 = -1;
do
++v21;
while ( v20[v21] );
sub_14003A930(Src, v20, v21);
v22 = cocos2d::CCArray::stringAtIndex(v13, 2u);
v23 = cocos2d::CCString::getCString(v22);
memset(Buf1, 0, sizeof(Buf1));
v24 = -1;
do
++v24;
while ( v23[v24] );
sub_14003A930(Buf1, v23, v24);
v25 = sub_14003BDB0((__int64)v67, (__int64)v79);
MapPacks = (cocos2d::CCArray *)GameLevelManager::createAndGetMapPacks(v26, v25);
v72 = 0;
v73 = 0;
v74 = 15;
LOBYTE(v72) = 0;
for ( i = 0; i < cocos2d::CCArray::count(MapPacks); ++i )
{
v29 = cocos2d::CCArray::objectAtIndex(MapPacks, i);
v30 = cocos2d::CCString::createWithFormat("%i", v29[5].m_uOrderOfArrival);
v31 = cocos2d::CCString::getCString(v30);
Buf2 = 0;
v71 = 0u;
v32 = -1;
do
++v32;
while ( v31[v32] );
sub_14003A930(&Buf2, v31, v32);
if ( (_QWORD)v71 )
{
p_Buf2 = (char *)&Buf2;
if ( *((_QWORD *)&v71 + 1) > 0xFu )
p_Buf2 = (char *)Buf2;
sub_14003B190((void **)&v72, *p_Buf2);
v34 = &Buf2;
if ( *((_QWORD *)&v71 + 1) > 0xFu )
v34 = (__int128 *)Buf2;
sub_14003B190((void **)&v72, *((_BYTE *)v34 + v71 - 1));
}
v35 = cocos2d::CCString::createWithFormat("%i", LODWORD(v29[6].__vftable));
v36 = (char *)cocos2d::CCString::getCString(v35);
v37 = -1;
do
++v37;
while ( v36[v37] );
sub_140041270(&v72, v36, v37);
v38 = cocos2d::CCString::createWithFormat("%i", HIDWORD(v29[6].__vftable));
v39 = (char *)cocos2d::CCString::getCString(v38);
v40 = -1;
do
++v40;
while ( v39[v40] );
sub_140041270(&v72, v39, v40);
if ( *((_QWORD *)&v71 + 1) > 0xFu )
{
v41 = (void *)Buf2;
if ( (unsigned __int64)(*((_QWORD *)&v71 + 1) + 1LL) >= 0x1000 )
{
v41 = *(void **)(Buf2 - 8);
if ( (unsigned __int64)(Buf2 - (_QWORD)v41 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v41);
}
}
v42 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 120, "I25", "fpAa", 112, 67, "Qg");
v43 = (char *)cocos2d::CCString::getCString(v42);
v44 = -1;
do
++v44;
while ( v43[v44] );
sub_140041270(&v72, v43, v44);
v45 = &v72;
if ( v74 > 0xF )
v45 = (__int128 *)v72;
v46 = &v72;
if ( v74 > 0xF )
v46 = (__int128 *)v72;
v47 = -1;
do
++v47;
while ( *((_BYTE *)v46 + v47) );
sub_140070860((__int64)v45, v47, v80);
sub_140070B30(v80, v81);
Buf2 = 0;
v71 = 0;
v48 = -1;
do
++v48;
while ( v81[v48] );
sub_14003A930(&Buf2, v81, v48);
v49 = sub_14003A760(Buf1, &Buf2);
sub_14003A830((__int64)&Buf2);
if ( v49 )
{
v50 = a1->m_levelManagerDelegate;
if ( v50 )
v50->loadLevelsFailed_0(v50, v6);
}
else
{
for ( j = 0; j < cocos2d::CCArray::count(MapPacks); ++j )
{
v56 = cocos2d::CCArray::objectAtIndex(MapPacks, j);
v57 = cocos2d::CCString::createWithFormat("pack_%i", v56[5].m_uOrderOfArrival);
v58 = cocos2d::CCString::getCString(v57);
Buf2 = 0;
v71 = 0u;
v59 = -1;
do
++v59;
while ( v58[v59] );
sub_14003A930(&Buf2, v58, v59);
cocos2d::CCDictionary::setObject(a1->m_savedPacks, v56, &Buf2);
if ( *((_QWORD *)&v71 + 1) > 0xFu )
{
v60 = (void *)Buf2;
if ( (unsigned __int64)(*((_QWORD *)&v71 + 1) + 1LL) >= 0x1000 )
{
v60 = *(void **)(Buf2 - 8);
if ( (unsigned __int64)(Buf2 - (_QWORD)v60 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v60);
}
}
if ( a1->m_levelManagerDelegate )
{
v61 = sub_14003BDB0((__int64)&Buf2, (__int64)Src);
a1->m_levelManagerDelegate->setupPageInfo(a1->m_levelManagerDelegate, (std::string *)v61, v6);
}
Buf2 = 0;
v71 = 0u;
v62 = Src;
if ( v77 > 0xF )
v62 = (void **)Src[0];
v63 = 0x7FFFFFFFFFFFFFFFLL;
v64 = v76;
if ( v76 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v53, v52, v54, v55);
*((_QWORD *)&v71 + 1) = 15;
if ( v76 > 0xF )
{
if ( (v76 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v63 = v76 | 0xF;
if ( (v76 | 0xF) < 0x16 )
v63 = 22;
}
*(_QWORD *)&Buf2 = sub_14003AA10(v63 + 1);
*(_QWORD *)&v71 = v64;
*((_QWORD *)&v71 + 1) = v63;
memcpy((void *)Buf2, v62, v64 + 1);
}
else
{
*(_QWORD *)&v71 = v76;
Buf2 = *(_OWORD *)v62;
}
GameLevelManager::storeSearchResult(a1, (__int64)MapPacks, &Buf2, v6);
v65 = a1->m_levelManagerDelegate;
if ( v65 )
v65->loadLevelsFinished_0(v65, MapPacks, v6);
}
sub_14003A830((__int64)&v72);
sub_14003A830((__int64)Buf1);
sub_14003A830((__int64)Src);
sub_14003A830((__int64)v79);
sub_14003A830((__int64)a2);
v15 = a3;
}
sub_14003A830(v15);
}