//
// GameLevelManager::onGetOnlineLevelsCompleted from 0x705110 to 0x705d94 (3204 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732f14
// > ??> @ 0x7e9c0
//
// 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
//
__int64 __fastcall GameLevelManager::onGetOnlineLevelsCompleted(GameLevelManager *a1, const void **a2, const char **a3)
{
_DWORD *v4; // x24
unsigned __int64 v5; // x25
unsigned __int64 v6; // x23
size_t v7; // x2
int v8; // w20
__int64 v9; // x23
__int64 *v10; // x0
LevelManagerDelegate *v11; // x0
cocos2d::CCArray *v13; // x20
char *v14; // x0
cocos2d::CCString *v15; // x0
char *CString; // x0
cocos2d::CCString *v17; // x0
char *v18; // x0
cocos2d::CCString *v19; // x0
char *v20; // x0
cocos2d::CCString *v21; // x0
char *v22; // x0
cocos2d::CCString *v23; // x0
char *v24; // x0
char *v25; // x0
cocos2d::CCArray *Levels; // x26
char *v27; // x0
unsigned int v28; // w22
_DWORD *v29; // x20
cocos2d::CCString *v30; // x0
char *v31; // x0
char *v32; // x1
char *v33; // x0
char v34; // w28
__int64 v35; // x1
__int64 v36; // x25
char *v37; // x0
_QWORD *v38; // x1
char *v39; // x0
__int64 v40; // x3
__int64 v41; // x25
char v42; // w28
char *v43; // x0
cocos2d::CCString *v44; // x0
size_t v45; // x0
cocos2d::CCString *v46; // x0
size_t v47; // x0
char *v48; // x0
unsigned int *v49; // x24
int v50; // w1
unsigned int *v51; // x1
int v52; // w2
cocos2d::CCString *v53; // x0
size_t v54; // x0
char *v55; // x20
unsigned int v56; // w0
unsigned __int8 *v57; // x3
char *v58; // x2
LevelManagerDelegate *m_levelManagerDelegate; // x19
void (__fastcall *setupPageInfo)(LevelManagerDelegate *__hidden, std::string, const unsigned __int8 *); // x22
long double v61; // q0
void *v62; // x0
char *v63; // x0
LevelManagerDelegate *v64; // x0
char *v65; // x0
void *v66; // x0
void *v67; // x0
void *v68; // x0
void *v69; // x0
void *v70; // x0
unsigned int *v71; // x19
int v72; // w1
MusicDownloadManager *v73; // x26
void *v74; // x0
void *v75; // x0
unsigned int *v76; // x1
int v77; // w2
unsigned int *v78; // x1
int v79; // w2
unsigned int *v80; // x1
int v81; // w2
unsigned int *v82; // x1
int v83; // w2
unsigned int *v84; // x1
int v85; // w2
unsigned int *v86; // x1
int v87; // w2
unsigned int *v88; // x1
int v89; // w2
unsigned int *v90; // x1
int v91; // w2
unsigned int *v92; // x1
int v93; // w2
unsigned int *v94; // x1
int v95; // w2
unsigned int *v96; // x1
int v97; // w2
unsigned int *v98; // x1
int v99; // w2
char *v100; // [xsp+78h] [xbp+78h]
const char *v102; // [xsp+88h] [xbp+88h]
const char *v103; // [xsp+88h] [xbp+88h]
const char *v104; // [xsp+88h] [xbp+88h]
__int64 v105; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v106; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v107; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v108; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v109; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v110; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v111; // [xsp+D0h] [xbp+D0h] BYREF
char *v112; // [xsp+D8h] [xbp+D8h] BYREF
char *v113; // [xsp+E0h] [xbp+E0h] BYREF
char *v114; // [xsp+E8h] [xbp+E8h] BYREF
__int64 v115; // [xsp+F0h] [xbp+F0h] BYREF
void *v116; // [xsp+F8h] [xbp+F8h] BYREF
unsigned __int8 v117[24]; // [xsp+100h] [xbp+100h] BYREF
unsigned __int8 v118[48]; // [xsp+118h] [xbp+118h] BYREF
v100 = (char *)*a3;
GameLevelManager::removeDLFromActive(a1, *a3);
sub_D153B8((int)&v116, "-1");
v4 = v116;
v5 = *((_QWORD *)v116 - 3);
v6 = *((_QWORD *)*a2 - 3);
if ( v5 > v6 )
v7 = *((_QWORD *)*a2 - 3);
else
v7 = *((_QWORD *)v116 - 3);
v8 = memcmp(*a2, v116, v7);
if ( v8 || (v8 = 0x7FFFFFFF, v9 = v6 - v5, v9 > 0x7FFFFFFF) )
{
v10 = (__int64 *)(v4 - 6);
if ( v4 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v10 = (__int64 *)(v4 - 6);
if ( v9 >= (__int64)0xFFFFFFFF80000000LL )
v8 = v9;
else
v8 = 0x80000000;
if ( v10 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v49 = v4 - 2;
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *(v4 - 2);
*(v4 - 2) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v10);
LABEL_7:
if ( !v8 )
goto LABEL_8;
sub_D153B8((int)&v116, (char *)*a2);
v13 = sub_6F004C(&v116, "#");
v14 = (char *)v116 - 24;
if ( (char *)v116 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v78 = (unsigned int *)((char *)v116 - 8);
do
v79 = __ldaxr(v78);
while ( __stlxr(v79 - 1, v78) );
}
else
{
v79 = *((_DWORD *)v116 - 2);
*((_DWORD *)v116 - 2) = v79 - 1;
}
if ( v79 <= 0 )
operator delete(v14);
}
if ( (unsigned int)cocos2d::CCArray::count(v13) > 4 )
{
v15 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 0);
CString = (char *)cocos2d::CCString::getCString(v15);
sub_D153B8((int)&v105, CString);
v17 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 1u);
v18 = (char *)cocos2d::CCString::getCString(v17);
sub_D153B8((int)&v106, v18);
v19 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 2u);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_D153B8((int)&v107, v20);
v21 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v13, 3u);
v22 = (char *)cocos2d::CCString::getCString(v21);
sub_D153B8((int)&v108, v22);
v23 = cocos2d::CCArray::stringAtIndex(v13, 4u);
v24 = (char *)cocos2d::CCString::getCString(v23);
sub_D153B8((int)&v109, v24);
if ( *(_QWORD *)(v107 - 24) )
{
v73 = MusicDownloadManager::sharedState();
sub_D18D28(&v110, &v107);
sub_D153B8((int)&v111, &byte_F288A0);
MusicDownloadManager::createSongsInfo(v73, (std::string)&v110, (std::string)&v111);
v74 = (void *)(v111 - 24);
if ( (__int64 *)(v111 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v98 = (unsigned int *)(v111 - 8);
do
v99 = __ldaxr(v98);
while ( __stlxr(v99 - 1, v98) );
}
else
{
v99 = *(_DWORD *)(v111 - 8);
*(_DWORD *)(v111 - 8) = v99 - 1;
}
if ( v99 <= 0 )
operator delete(v74);
}
v75 = (void *)(v110 - 24);
if ( (__int64 *)(v110 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v76 = (unsigned int *)(v110 - 8);
do
v77 = __ldaxr(v76);
while ( __stlxr(v77 - 1, v76) );
}
else
{
v77 = *(_DWORD *)(v110 - 8);
*(_DWORD *)(v110 - 8) = v77 - 1;
}
if ( v77 <= 0 )
operator delete(v75);
}
}
sub_D18D28(&v112, &v106);
GameLevelManager::storeUserNames(a1, &v112);
v25 = v112 - 24;
if ( v112 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v88 = (unsigned int *)(v112 - 8);
do
v89 = __ldaxr(v88);
while ( __stlxr(v89 - 1, v88) );
}
else
{
v89 = *((_DWORD *)v112 - 2);
*((_DWORD *)v112 - 2) = v89 - 1;
}
if ( v89 <= 0 )
operator delete(v25);
}
sub_D18D28(&v113, &v105);
Levels = GameLevelManager::createAndGetLevels((__int64)a1, &v113);
v27 = v113 - 24;
if ( v113 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v84 = (unsigned int *)(v113 - 8);
do
v85 = __ldaxr(v84);
while ( __stlxr(v85 - 1, v84) );
}
else
{
v85 = *((_DWORD *)v113 - 2);
*((_DWORD *)v113 - 2) = v85 - 1;
}
if ( v85 <= 0 )
operator delete(v27);
}
sub_D153B8((int)&v114, &byte_F288A0);
v28 = 0;
while ( v28 < (unsigned int)cocos2d::CCArray::count(Levels) )
{
v29 = (_DWORD *)cocos2d::CCArray::objectAtIndex(Levels, v28);
v30 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v29[82] - v29[83]));
v31 = (char *)cocos2d::CCString::getCString(v30);
sub_D153B8((int)&v116, v31);
v32 = (char *)v116;
if ( *((_QWORD *)v116 - 3) )
{
if ( (*((_DWORD *)v116 - 2) & 0x80000000) == 0 )
{
sub_D176A8(&v116);
v32 = (char *)v116;
}
v33 = v114;
v34 = *v32;
v35 = *((_QWORD *)v114 - 3);
v36 = v35 + 1;
if ( (unsigned __int64)(v35 + 1) > *((_QWORD *)v114 - 2) || *((int *)v114 - 2) > 0 )
{
sub_D15888(&v114, v35 + 1);
v33 = v114;
v35 = *((_QWORD *)v114 - 3);
}
v33[v35] = v34;
v37 = v114;
if ( v114 - 24 != (char *)&qword_124B6B0 )
{
*((_DWORD *)v114 - 2) = 0;
*((_QWORD *)v37 - 3) = v36;
v37[v36] = 0;
}
v38 = v116;
if ( (*((_DWORD *)v116 - 2) & 0x80000000) == 0 )
{
sub_D176A8(&v116);
v38 = v116;
}
v39 = v114;
v40 = *((_QWORD *)v114 - 3);
v41 = v40 + 1;
v42 = *((_BYTE *)v38 + *(v38 - 3) - 1);
if ( (unsigned __int64)(v40 + 1) > *((_QWORD *)v114 - 2) || *((int *)v114 - 2) > 0 )
{
sub_D15888(&v114, v40 + 1);
v39 = v114;
v40 = *((_QWORD *)v114 - 3);
}
v39[v40] = v42;
v43 = v114;
if ( v114 - 24 != (char *)&qword_124B6B0 )
{
*((_DWORD *)v114 - 2) = 0;
*((_QWORD *)v43 - 3) = v41;
v43[v41] = 0;
}
}
v44 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v29[172] - v29[173]));
v102 = cocos2d::CCString::getCString(v44);
v45 = strlen(v102);
sub_D15FD4(&v114, v102, v45);
v46 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v29[177] - v29[178]));
v103 = cocos2d::CCString::getCString(v46);
v47 = strlen(v103);
sub_D15FD4(&v114, v103, v47);
v48 = (char *)v116 - 24;
if ( (char *)v116 - 24 == (char *)&qword_124B6B0 )
goto LABEL_39;
if ( &pthread_create )
{
v51 = (unsigned int *)((char *)v116 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *((_DWORD *)v116 - 2);
*((_DWORD *)v116 - 2) = v52 - 1;
}
if ( v52 > 0 )
{
LABEL_39:
++v28;
}
else
{
++v28;
operator delete(v48);
}
}
v53 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v104 = cocos2d::CCString::getCString(v53);
v54 = strlen(v104);
sub_D15FD4(&v114, v104, v54);
v55 = v114;
v56 = strlen(v114);
rtsha1::calc((rtsha1 *)v55, (const void *)v56, (__int64)v117, v57);
rtsha1::toHexString((rtsha1 *)v117, v118, v58);
m_levelManagerDelegate = a1->m_levelManagerDelegate;
if ( m_levelManagerDelegate )
{
setupPageInfo = m_levelManagerDelegate->setupPageInfo;
*(__n128 *)&v61 = sub_D18D28(&v115, &v108);
((void (__fastcall *)(LevelManagerDelegate *, __int64 *, char *, long double))setupPageInfo)(
m_levelManagerDelegate,
&v115,
v100,
v61);
v62 = (void *)(v115 - 24);
if ( (__int64 *)(v115 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v96 = (unsigned int *)(v115 - 8);
do
v97 = __ldaxr(v96);
while ( __stlxr(v97 - 1, v96) );
}
else
{
v97 = *(_DWORD *)(v115 - 8);
*(_DWORD *)(v115 - 8) = v97 - 1;
}
if ( v97 <= 0 )
operator delete(v62);
}
}
GameLevelManager::saveFetchedLevels(a1, Levels);
sub_D18D28(&v116, &v108);
GameLevelManager::storeSearchResult(a1, Levels, (char **)&v116, v100);
v63 = (char *)v116 - 24;
if ( (char *)v116 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v92 = (unsigned int *)((char *)v116 - 8);
do
v93 = __ldaxr(v92);
while ( __stlxr(v93 - 1, v92) );
}
else
{
v93 = *((_DWORD *)v116 - 2);
*((_DWORD *)v116 - 2) = v93 - 1;
}
if ( v93 <= 0 )
operator delete(v63);
}
v64 = a1->m_levelManagerDelegate;
if ( v64 )
v64->loadLevelsFinished(v64, Levels, (const unsigned __int8 *)v100);
v65 = v114 - 24;
if ( v114 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v86 = (unsigned int *)(v114 - 8);
do
v87 = __ldaxr(v86);
while ( __stlxr(v87 - 1, v86) );
}
else
{
v87 = *((_DWORD *)v114 - 2);
*((_DWORD *)v114 - 2) = v87 - 1;
}
if ( v87 <= 0 )
operator delete(v65);
}
v66 = (void *)(v109 - 24);
if ( (__int64 *)(v109 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v94 = (unsigned int *)(v109 - 8);
do
v95 = __ldaxr(v94);
while ( __stlxr(v95 - 1, v94) );
}
else
{
v95 = *(_DWORD *)(v109 - 8);
*(_DWORD *)(v109 - 8) = v95 - 1;
}
if ( v95 <= 0 )
operator delete(v66);
}
v67 = (void *)(v108 - 24);
if ( (__int64 *)(v108 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v90 = (unsigned int *)(v108 - 8);
do
v91 = __ldaxr(v90);
while ( __stlxr(v91 - 1, v90) );
}
else
{
v91 = *(_DWORD *)(v108 - 8);
*(_DWORD *)(v108 - 8) = v91 - 1;
}
if ( v91 <= 0 )
operator delete(v67);
}
v68 = (void *)(v107 - 24);
if ( (__int64 *)(v107 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v82 = (unsigned int *)(v107 - 8);
do
v83 = __ldaxr(v82);
while ( __stlxr(v83 - 1, v82) );
}
else
{
v83 = *(_DWORD *)(v107 - 8);
*(_DWORD *)(v107 - 8) = v83 - 1;
}
if ( v83 <= 0 )
operator delete(v68);
}
v69 = (void *)(v106 - 24);
if ( (__int64 *)(v106 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v80 = (unsigned int *)(v106 - 8);
do
v81 = __ldaxr(v80);
while ( __stlxr(v81 - 1, v80) );
}
else
{
v81 = *(_DWORD *)(v106 - 8);
*(_DWORD *)(v106 - 8) = v81 - 1;
}
if ( v81 <= 0 )
operator delete(v69);
}
v70 = (void *)(v105 - 24);
if ( (__int64 *)(v105 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v71 = (unsigned int *)(v105 - 8);
do
v72 = __ldaxr(v71);
while ( __stlxr(v72 - 1, v71) );
}
else
{
v72 = *(_DWORD *)(v105 - 8);
*(_DWORD *)(v105 - 8) = v72 - 1;
}
if ( v72 <= 0 )
operator delete(v70);
}
}
else
{
LABEL_8:
v11 = a1->m_levelManagerDelegate;
if ( v11 )
v11->loadLevelsFailed(v11, (const unsigned __int8 *)v100);
}
return _stack_chk_guard;
}