//
// GameLevelManager::processOnDownloadLevelCompleted from 0x10009fd4c to 0x1000a06e4 (2456 bytes)
//
// 2 xrefs:
// > GameLevelManager::onDownloadLevelCompleted @ 0x10008b2b8
// > GameLevelManager::onUpdateLevelCompleted @ 0x10008b39c
//
// 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 __fastcall GameLevelManager::processOnDownloadLevelCompleted(
GameLevelManager *a1,
std::string *a2,
std::string *a3,
int a4)
{
std::string *v5; // x24
cocos2d::CCArray *v8; // x22
cocos2d::CCString *v9; // x0
__int64 v10; // x20
cocos2d::CCString *v11; // x0
_BOOL4 v12; // w23
cocos2d::CCString *v13; // x0
int v14; // w22
cocos2d::CCArray *v15; // x24
_BOOL4 v16; // w0
_BOOL4 v17; // w25
void *v18; // x0
void *m_levelUpdateDelegate; // x0
cocos2d::CCString *v20; // x0
char *CString; // x0
cocos2d::CCString *v22; // x0
char *v23; // x0
cocos2d::CCString *v24; // x0
char *v25; // x0
cocos2d::CCString *v26; // x0
char *v27; // x0
cocos2d::CCString *v28; // x0
char *v29; // x0
cocos2d::CCString *v30; // x0
char *v31; // x1
MusicDownloadManager *v32; // x24
cocos2d::CCDictionary *v33; // x0
GJGameLevel *v34; // x24
GameManager *v35; // x0
int v36; // w25
float v37; // s0
std::string *p_str; // x0
int v39; // w0
__int64 v40; // x26
__int64 v41; // x27
int v42; // w28
std::string *v43; // x8
cocos2d::CCString *v44; // x0
const char *v45; // x0
std::string *v46; // x25
size_t v47; // x0
_QWORD *v48; // x0
bool v49; // w0
bool v50; // w25
cocos2d::CCString *v51; // x0
char *v52; // x0
cocos2d::CCString *v53; // x0
const char *v54; // x0
std::string *v55; // x25
size_t v56; // x0
bool v57; // w25
float v58; // s0
GJGameLevel *SavedLevel_1; // x0
__int64 v60; // x21
cocos2d::CCString *v61; // x0
const char *v62; // x0
GameLevelManager *v63; // x0
LevelUpdateDelegate *v64; // x0
void *v65; // x0
void *v66; // x0
int v67; // w8
int v68; // w8
int v69; // w8
LevelDownloadDelegate *v70; // x0
cocos2d::CCString *v71; // x0
const char *v72; // x0
GameLevelManager *m_levelDownloadDelegate; // x0
void *v74[2]; // [xsp+48h] [xbp-218h] BYREF
char v75; // [xsp+5Fh] [xbp-201h]
std::string v76; // [xsp+60h] [xbp-200h] BYREF
std::string v77; // [xsp+78h] [xbp-1E8h] BYREF
std::string __str; // [xsp+90h] [xbp-1D0h] BYREF
void *v79[2]; // [xsp+B0h] [xbp-1B0h] BYREF
__int64 v80; // [xsp+C0h] [xbp-1A0h]
__int128 v81; // [xsp+D0h] [xbp-190h] BYREF
__int64 v82; // [xsp+E0h] [xbp-180h]
__int128 __dst; // [xsp+F0h] [xbp-170h] BYREF
__int64 v84; // [xsp+100h] [xbp-160h]
__int128 __p; // [xsp+110h] [xbp-150h] BYREF
__int64 v86; // [xsp+120h] [xbp-140h]
void *v87[2]; // [xsp+130h] [xbp-130h] BYREF
char v88; // [xsp+147h] [xbp-119h]
void *v89[2]; // [xsp+148h] [xbp-118h] BYREF
char v90; // [xsp+15Fh] [xbp-101h]
__int128 v91; // [xsp+160h] [xbp-100h] BYREF
__int64 v92; // [xsp+170h] [xbp-F0h]
char v93[16]; // [xsp+178h] [xbp-E8h] BYREF
__int64 v94; // [xsp+188h] [xbp-D8h]
char v95[20]; // [xsp+1A4h] [xbp-BCh] BYREF
char __s[16]; // [xsp+1B8h] [xbp-A8h] BYREF
__int64 v97; // [xsp+1C8h] [xbp-98h]
_BYTE v98[20]; // [xsp+1E4h] [xbp-7Ch] BYREF
v5 = a3;
v8 = (cocos2d::CCArray *)sub_100093338(a3, "_");
if ( !(unsigned int)sub_10024A36C(v8) )
{
if ( (a4 & 1) != 0 )
{
m_levelUpdateDelegate = a1->m_levelUpdateDelegate;
if ( !m_levelUpdateDelegate )
return;
}
else
{
m_levelUpdateDelegate = a1->m_levelDownloadDelegate;
if ( !m_levelUpdateDelegate )
return;
}
(*(void (__fastcall **)(void *, _QWORD))(*(_QWORD *)m_levelUpdateDelegate + 8LL))(m_levelUpdateDelegate, 0);
return;
}
v9 = cocos2d::CCArray::stringAtIndex(v8, 0);
v10 = cocos2d::CCString::intValue(v9);
v11 = cocos2d::CCArray::stringAtIndex(v8, 1u);
v12 = cocos2d::CCString::boolValue(v11);
v13 = cocos2d::CCArray::stringAtIndex(v8, 2u);
v14 = cocos2d::CCString::intValue(v13);
if ( SHIBYTE(v5->__r_.__value_.__r.__words[2]) < 0 )
v5 = (std::string *)v5->__r_.__value_.__r.__words[0];
GameLevelManager::removeDLFromActive(a1, (const char *)v5);
v15 = (cocos2d::CCArray *)sub_100093338(a2, "#");
if ( (unsigned int)sub_10024A36C(v15) < 3 )
goto LABEL_7;
sub_100009900(__s, "-1");
v16 = sub_1000045BC(a2, __s);
v17 = v16;
if ( SHIBYTE(v97) < 0 )
{
operator delete(*(void **)__s);
if ( v17 )
goto LABEL_7;
LABEL_18:
v20 = cocos2d::CCArray::stringAtIndex(v15, 0);
CString = (char *)cocos2d::CCString::getCString(v20);
sub_100009900(&v91, CString);
v22 = cocos2d::CCArray::stringAtIndex(v15, 1u);
v23 = (char *)cocos2d::CCString::getCString(v22);
sub_100009900(v89, v23);
v24 = cocos2d::CCArray::stringAtIndex(v15, 2u);
v25 = (char *)cocos2d::CCString::getCString(v24);
sub_100009900(v87, v25);
if ( (unsigned int)sub_10024A36C(v15) >= 4 )
{
v26 = cocos2d::CCArray::stringAtIndex(v15, 3u);
v27 = (char *)cocos2d::CCString::getCString(v26);
sub_100009900(__s, v27);
if ( SHIBYTE(v97) < 0 )
{
sub_1000097D0(&__p, *(void **)__s, *(unsigned __int64 *)&__s[8]);
}
else
{
__p = *(_OWORD *)__s;
v86 = v97;
}
GameLevelManager::storeUserNames((__int64)a1, (__int64 *)&__p);
if ( SHIBYTE(v86) < 0 )
operator delete((void *)__p);
if ( SHIBYTE(v97) < 0 )
operator delete(*(void **)__s);
}
if ( (unsigned int)sub_10024A36C(v15) >= 5 )
{
v28 = cocos2d::CCArray::stringAtIndex(v15, 4u);
v29 = (char *)cocos2d::CCString::getCString(v28);
sub_100009900(__s, v29);
if ( (unsigned int)sub_10024A36C(v15) < 6 )
{
v31 = "";
}
else
{
v30 = cocos2d::CCArray::stringAtIndex(v15, 5u);
v31 = (char *)cocos2d::CCString::getCString(v30);
}
sub_100009900(v93, v31);
v32 = MusicDownloadManager::sharedState();
if ( SHIBYTE(v97) < 0 )
{
sub_1000097D0(&__dst, *(void **)__s, *(unsigned __int64 *)&__s[8]);
}
else
{
__dst = *(_OWORD *)__s;
v84 = v97;
}
if ( SHIBYTE(v94) < 0 )
{
sub_1000097D0(&v81, *(void **)v93, *(unsigned __int64 *)&v93[8]);
}
else
{
v81 = *(_OWORD *)v93;
v82 = v94;
}
MusicDownloadManager::createSongsInfo(v32, &__dst, &v81);
if ( SHIBYTE(v82) < 0 )
operator delete((void *)v81);
if ( SHIBYTE(v84) < 0 )
operator delete((void *)__dst);
if ( SHIBYTE(v94) < 0 )
operator delete(*(void **)v93);
if ( SHIBYTE(v97) < 0 )
operator delete(*(void **)__s);
}
if ( SHIBYTE(v92) < 0 )
{
sub_1000097D0(v79, (void *)v91, *((unsigned __int64 *)&v91 + 1));
}
else
{
*(_OWORD *)v79 = v91;
v80 = v92;
}
v33 = GameLevelManager::responseToDict((char *)v79, 0);
v34 = GJGameLevel::create(v33, 1);
if ( SHIBYTE(v80) < 0 )
operator delete(v79[0]);
if ( v34->m_lowDetailMode )
{
v35 = GameManager::sharedState();
if ( GameManager::getGameVariable(v35, "0108") )
v34->m_lowDetailModeToggled = 1;
}
if ( v12 )
v34->m_gauntletLevel = 1;
if ( (_DWORD)v10 == -2 )
{
v36 = v34->m_dailyID.random - v34->m_dailyID.seed;
v34->m_dailyID.value = v36;
v37 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v34->m_dailyID.seed = (int)v37;
v34->m_dailyID.random = v36 + (int)v37;
}
if ( v34->m_levelString.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&__str, (void *)v34->m_levelString.m_data.m_long.capacitym1, v34->m_levelString.m_data.m_long.size);
else
__str = (std::string)v34->m_levelString;
sub_100009900(&v77, "");
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_str = &__str;
else
p_str = (std::string *)__str.__r_.__value_.__r.__words[0];
v39 = strlen((const char *)p_str);
if ( v39 > 39 )
{
v40 = 0;
v41 = (int)(float)((float)(unsigned int)v39 / 40.0);
v42 = 40;
do
{
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v43 = &__str;
else
v43 = (std::string *)__str.__r_.__value_.__r.__words[0];
std::string::push_back(&v77, v43->__r_.__value_.__s.__data_[v40]);
v40 += v41;
--v42;
}
while ( v42 );
}
else
{
std::string::operator=(&v77, &__str);
}
v44 = (cocos2d::CCString *)sub_100268F4C("%c%s%s%c%c%s", 120, "I25", "fpAa", 112, 67, "Qg");
v45 = cocos2d::CCString::getCString(v44);
v46 = &v77;
std::string::append(&v77, v45);
if ( (v77.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v46 = (std::string *)v77.__r_.__value_.__r.__words[0];
v47 = strlen((const char *)v46);
sub_1000F7448(v46, v47, v98);
sub_1000F78E0(v98, __s);
v48 = sub_100009900(v93, __s);
v49 = sub_1000045BC(v48, v89);
v50 = v49;
if ( SHIBYTE(v94) < 0 )
{
operator delete(*(void **)v93);
if ( v50 )
{
LABEL_73:
v51 = (cocos2d::CCString *)sub_100268F4C(
"%i,%i,%i,%i,%i,%i,%i,%i",
v34->m_userID.random - v34->m_userID.seed,
v34->m_stars.random - v34->m_stars.seed,
v34->m_demon.random - v34->m_demon.seed,
v34->m_levelID.random - v34->m_levelID.seed,
v34->m_coinsVerified.random - v34->m_coinsVerified.seed,
v34->m_featured,
v34->m_password.random - v34->m_password.seed,
v34->m_dailyID.random - v34->m_dailyID.seed);
v52 = (char *)cocos2d::CCString::getCString(v51);
sub_100009900(&v76, v52);
v53 = (cocos2d::CCString *)sub_100268F4C("%c%s%s%c%c%s", 120, "I25", "fpAa", 112, 67, "Qg");
v54 = cocos2d::CCString::getCString(v53);
v55 = &v76;
std::string::append(&v76, v54);
if ( (v76.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v55 = (std::string *)v76.__r_.__value_.__r.__words[0];
v56 = strlen((const char *)v55);
sub_1000F7448(v55, v56, v95);
sub_1000F78E0(v95, v93);
sub_100009900(v74, v93);
v57 = sub_1000045BC(v74, v87);
if ( v75 < 0 )
operator delete(v74[0]);
if ( v57 )
{
if ( a4 )
{
if ( v14 >= 1 )
{
v34->m_dailyID.value = v14;
v58 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v34->m_dailyID.seed = (int)v58;
v34->m_dailyID.random = v14 + (int)v58;
}
SavedLevel_1 = GameLevelManager::getSavedLevel_1(a1, v34);
if ( SavedLevel_1 )
{
if ( v34->m_levelVersion <= SavedLevel_1->m_levelVersion )
v60 = 1;
else
v60 = 3;
GameLevelManager::saveLevel(a1, v34);
v61 = (cocos2d::CCString *)sub_100268F4C("%i", v10);
v62 = cocos2d::CCString::getCString(v61);
GameLevelManager::makeTimeStamp(a1, v62);
GameLevelManager::updateLevelRewards(v63, v34);
v64 = a1->m_levelUpdateDelegate;
if ( v64 )
((void (__fastcall *)(LevelUpdateDelegate *, GJGameLevel *, __int64))v64->levelUpdateFinished)(
v64,
v34,
v60);
goto LABEL_114;
}
v66 = a1->m_levelUpdateDelegate;
if ( v66 )
goto LABEL_105;
}
else
{
switch ( (_DWORD)v10 )
{
case 0xFFFFFFFF:
GameLevelManager::saveLevel(a1, v34);
v68 = v34->m_dailyID.random - v34->m_dailyID.seed;
if ( a1->m_activeDailyID < v68 )
a1->m_activeDailyID = v68;
break;
case 0xFFFFFFFE:
GameLevelManager::saveLevel(a1, v34);
v67 = v34->m_dailyID.random - v34->m_dailyID.seed;
if ( a1->m_activeWeeklyID < v67 )
a1->m_activeWeeklyID = v67;
break;
case 0xFFFFFFFD:
GameLevelManager::saveLevel(a1, v34);
v69 = v34->m_dailyID.random - v34->m_dailyID.seed;
if ( a1->m_activeEventID < v69 )
a1->m_activeEventID = v69;
break;
default:
GameLevelManager::markLevelAsDownloaded(a1, v10);
GameLevelManager::saveLevel(a1, v34);
v71 = (cocos2d::CCString *)sub_100268F4C("%i_%i_%i", v10, v12, v14);
v72 = cocos2d::CCString::getCString(v71);
GameLevelManager::makeTimeStamp(a1, v72);
m_levelDownloadDelegate = (GameLevelManager *)a1->m_levelDownloadDelegate;
if ( m_levelDownloadDelegate )
m_levelDownloadDelegate = (GameLevelManager *)((__int64 (__fastcall *)(GameLevelManager *, GJGameLevel *))m_levelDownloadDelegate->copyWithZone)(
m_levelDownloadDelegate,
v34);
GameLevelManager::updateLevelRewards(m_levelDownloadDelegate, v34);
goto LABEL_114;
}
v70 = a1->m_levelDownloadDelegate;
if ( v70 )
((void (__fastcall *)(LevelDownloadDelegate *, GJGameLevel *))v70->levelDownloadFinished)(v70, v34);
}
}
else
{
if ( (a4 & 1) == 0 )
{
v66 = a1->m_levelDownloadDelegate;
if ( !v66 )
goto LABEL_114;
goto LABEL_105;
}
v66 = a1->m_levelUpdateDelegate;
if ( v66 )
LABEL_105:
(*(void (__fastcall **)(void *, __int64))(*(_QWORD *)v66 + 8LL))(v66, v10);
}
LABEL_114:
if ( SHIBYTE(v76.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v76.__r_.__value_.__l.__data_);
goto LABEL_116;
}
}
else if ( v49 )
{
goto LABEL_73;
}
if ( (a4 & 1) != 0 )
{
v65 = a1->m_levelUpdateDelegate;
if ( !v65 )
goto LABEL_116;
}
else
{
v65 = a1->m_levelDownloadDelegate;
if ( !v65 )
{
LABEL_116:
if ( SHIBYTE(v77.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v77.__r_.__value_.__l.__data_);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( v88 < 0 )
operator delete(v87[0]);
if ( v90 < 0 )
operator delete(v89[0]);
if ( SHIBYTE(v92) < 0 )
operator delete((void *)v91);
return;
}
}
(*(void (__fastcall **)(void *, __int64))(*(_QWORD *)v65 + 8LL))(v65, v10);
goto LABEL_116;
}
if ( !v16 )
goto LABEL_18;
LABEL_7:
if ( (a4 & 1) != 0 )
{
v18 = a1->m_levelUpdateDelegate;
if ( !v18 )
return;
goto LABEL_9;
}
v18 = a1->m_levelDownloadDelegate;
if ( v18 )
LABEL_9:
(*(void (__fastcall **)(void *, __int64))(*(_QWORD *)v18 + 8LL))(v18, v10);
}