//
// GameLevelManager::onGetGauntletsCompleted from 0x1401514f0 to 0x140151aa3 (1459 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x140143c35
// > ??> @ 0x1406ca878
//
// 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::onGetGauntletsCompleted(GameLevelManager *a1, const void **a2, const char *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
void *v14; // rcx
LevelManagerDelegate *m_levelManagerDelegate; // 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
__int64 v22; // rdx
__int64 v23; // rcx
__int64 v24; // r8
__int64 v25; // r9
void **v26; // rsi
__int64 v27; // rbx
unsigned __int64 v28; // rdi
cocos2d::CCArray *MapPacks; // rsi
unsigned int i; // ebx
struct cocos2d::CCObject *v31; // rdi
cocos2d::CCString *v32; // rax
char *v33; // rax
size_t v34; // r8
void **v35; // rdx
cocos2d::CCString *v36; // rax
char *v37; // rax
size_t v38; // r8
__int128 *v39; // r8
__int128 *v40; // r9
__int64 v41; // rdx
unsigned int j; // ebx
struct cocos2d::CCObject *v43; // rdi
cocos2d::CCString *v44; // rax
const char *v45; // rax
size_t v46; // r8
void *v47; // rcx
LevelManagerDelegate *v48; // rcx
__int128 Buf2; // [rsp+58h] [rbp-A8h] BYREF
__m128i si128; // [rsp+68h] [rbp-98h]
__int128 v51; // [rsp+78h] [rbp-88h] BYREF
__int64 v52; // [rsp+88h] [rbp-78h]
unsigned __int64 v53; // [rsp+90h] [rbp-70h]
void *v54[2]; // [rsp+98h] [rbp-68h] BYREF
size_t Size; // [rsp+A8h] [rbp-58h]
unsigned __int64 v56; // [rsp+B0h] [rbp-50h]
__int128 v57; // [rsp+B8h] [rbp-48h] BYREF
__int64 v58; // [rsp+C8h] [rbp-38h]
unsigned __int64 v59; // [rsp+D0h] [rbp-30h]
void *Src[2]; // [rsp+D8h] [rbp-28h] BYREF
unsigned __int64 v61; // [rsp+E8h] [rbp-18h]
unsigned __int64 v62; // [rsp+F0h] [rbp-10h]
_OWORD v63[2]; // [rsp+F8h] [rbp-8h] BYREF
_BYTE v64[48]; // [rsp+118h] [rbp+18h] BYREF
v6 = a3;
if ( *((_QWORD *)a3 + 3) > 0xFu )
v6 = *(const char **)a3;
GameLevelManager::removeDLFromActive(a1, v6);
Buf2 = 0;
si128.m128i_i64[0] = 2;
si128.m128i_i64[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_19;
v11 = a2;
if ( v8 > 0xF )
v11 = *a2;
Buf2 = 0;
si128 = 0;
v12 = -1;
do
++v12;
while ( v11[v12] );
sub_14003A930(&Buf2, v11, v12);
v13 = sub_140140F70((__int64 *)&Buf2, "#");
if ( si128.m128i_i64[1] > 0xFuLL )
{
v14 = (void *)Buf2;
if ( (unsigned __int64)(si128.m128i_i64[1] + 1) >= 0x1000 )
{
v14 = *(void **)(Buf2 - 8);
if ( (unsigned __int64)(Buf2 - (_QWORD)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
si128 = _mm_load_si128((const __m128i *)&xmmword_140623F30);
LOBYTE(Buf2) = 0;
if ( cocos2d::CCArray::count(v13) < 2 )
{
LABEL_19:
m_levelManagerDelegate = a1->m_levelManagerDelegate;
if ( m_levelManagerDelegate )
m_levelManagerDelegate->loadLevelsFailed_0(m_levelManagerDelegate, v6);
}
else
{
v16 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 0);
CString = cocos2d::CCString::getCString(v16);
*(_OWORD *)Src = 0;
v61 = 0;
v62 = 0;
v18 = -1;
do
++v18;
while ( CString[v18] );
sub_14003A930(Src, CString, v18);
v19 = cocos2d::CCArray::stringAtIndex(v13, 1u);
v20 = cocos2d::CCString::getCString(v19);
memset(v63, 0, sizeof(v63));
v21 = -1;
do
++v21;
while ( v20[v21] );
sub_14003A930(v63, v20, v21);
Buf2 = 0;
si128 = 0u;
v26 = Src;
if ( v62 > 0xF )
v26 = (void **)Src[0];
v27 = 0x7FFFFFFFFFFFFFFFLL;
v28 = v61;
if ( v61 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v23, v22, v24, v25);
si128.m128i_i64[1] = 15;
if ( v61 > 0xF )
{
if ( (v61 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v27 = v61 | 0xF;
if ( (v61 | 0xF) < 0x16 )
v27 = 22;
}
*(_QWORD *)&Buf2 = sub_14003AA10(v27 + 1);
si128.m128i_i64[0] = v28;
si128.m128i_i64[1] = v27;
memcpy((void *)Buf2, v26, v28 + 1);
}
else
{
si128.m128i_i64[0] = v61;
Buf2 = *(_OWORD *)v26;
}
MapPacks = (cocos2d::CCArray *)GameLevelManager::createAndGetMapPacks(v23, (__int64)&Buf2);
v51 = 0;
v52 = 0;
v53 = 15;
LOBYTE(v51) = 0;
for ( i = 0; i < cocos2d::CCArray::count(MapPacks); ++i )
{
v31 = cocos2d::CCArray::objectAtIndex(MapPacks, i);
v32 = cocos2d::CCString::createWithFormat("%i", v31[5].m_uOrderOfArrival);
v33 = (char *)cocos2d::CCString::getCString(v32);
v34 = -1;
do
++v34;
while ( v33[v34] );
sub_140041270(&v51, v33, v34);
sub_14003BDB0((__int64)v54, (__int64)&v31[6].m_unknown2);
v35 = v54;
if ( v56 > 0xF )
v35 = (void **)v54[0];
sub_140041270(&v51, v35, Size);
sub_14003A830((__int64)v54);
}
v36 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 120, "I25", "fpAa", 112, 67, "Qg");
v37 = (char *)cocos2d::CCString::getCString(v36);
v38 = -1;
do
++v38;
while ( v37[v38] );
sub_140041270(&v51, v37, v38);
v39 = &v51;
if ( v53 > 0xF )
v39 = (__int128 *)v51;
v40 = &v51;
if ( v53 > 0xF )
v40 = (__int128 *)v51;
v41 = -1;
do
++v41;
while ( *((_BYTE *)v39 + v41) );
sub_140070860((__int64)v40, v41, &v57);
sub_140070B30((unsigned __int8 *)&v57, v64);
for ( j = 0; j < cocos2d::CCArray::count(MapPacks); ++j )
{
v43 = cocos2d::CCArray::objectAtIndex(MapPacks, j);
LOBYTE(v43[7].m_eObjType) = 1;
v44 = cocos2d::CCString::createWithFormat("%i", v43[5].m_uOrderOfArrival);
v45 = cocos2d::CCString::getCString(v44);
v57 = 0;
v58 = 0;
v59 = 0;
v46 = -1;
do
++v46;
while ( v45[v46] );
sub_14003A930(&v57, v45, v46);
cocos2d::CCDictionary::setObject(a1->m_savedGauntlets, v43, &v57);
if ( v59 > 0xF )
{
v47 = (void *)v57;
if ( v59 + 1 >= 0x1000 )
{
v47 = *(void **)(v57 - 8);
if ( (unsigned __int64)(v57 - (_QWORD)v47 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v47);
}
}
*(_OWORD *)v54 = 0;
Size = 0;
v56 = 15;
LOBYTE(v54[0]) = 0;
GameLevelManager::storeSearchResult(a1, (__int64)MapPacks, v54, v6);
v48 = a1->m_levelManagerDelegate;
if ( v48 )
v48->loadLevelsFinished_0(v48, MapPacks, v6);
sub_14003A830((__int64)&v51);
sub_14003A830((__int64)v63);
sub_14003A830((__int64)Src);
}
sub_14003A830((__int64)a2);
sub_14003A830((__int64)a3);
}