//
// GameLevelManager::processOnDownloadLevelCompleted from 0x3c7258 to 0x3c78de (1670 bytes)
//
// 2 xrefs:
// > GameLevelManager::onDownloadLevelCompleted @ 0x3c790c
// > GameLevelManager::onUpdateLevelCompleted @ 0x3c7970
//
// 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
//
int __fastcall GameLevelManager::processOnDownloadLevelCompleted(
GameLevelManager *a1,
cocos2d::CCArray *a2,
cocos2d::CCArray *a3,
int a4)
{
cocos2d::CCArray *v8; // r6
int result; // r0
int (*v10)(void); // r3
cocos2d::CCString *v11; // r0
int v12; // r7
cocos2d::CCString *v13; // r0
cocos2d::CCString *v14; // r0
cocos2d::CCArray *v15; // r8
_BOOL4 v16; // r9
cocos2d::CCString *v17; // r0
char *CString; // r0
cocos2d::CCString *v19; // r0
char *v20; // r0
cocos2d::CCString *v21; // r0
char *v22; // r0
cocos2d::CCString *v23; // r0
char *v24; // r0
cocos2d::CCString *v25; // r0
char *v26; // r0
cocos2d::CCString *v27; // r0
char *v28; // r1
GJGameLevel *v29; // r4
GameManager *v30; // r0
signed int v31; // r0
cocos2d::CCString *v32; // r0
char *v33; // r0
int v34; // r8
int v35; // r9
int v36; // s16
const void *v37; // r0
unsigned __int8 *v38; // r3
char *v39; // r2
_BOOL4 v40; // r6
void *m_levelUpdateDelegate; // r0
cocos2d::CCString *v42; // r0
char *v43; // r0
cocos2d::CCString *v44; // r0
char *v45; // r0
const void *v46; // r0
unsigned __int8 *v47; // r3
char *v48; // r2
_BOOL4 v49; // r10
void *m_levelDownloadDelegate; // r0
GJGameLevel *SavedLevel; // r0
int v52; // r8
const char *LevelKey; // r0
LevelUpdateDelegate *v54; // r0
int v55; // r3
int v56; // r3
int v57; // r3
LevelDownloadDelegate *v58; // r0
const char *LevelDownloadKey; // r0
LevelDownloadDelegate *v60; // r0
int v61; // [sp+1Ch] [bp-D0h]
_BOOL4 v62; // [sp+20h] [bp-CCh]
MusicDownloadManager *v63; // [sp+28h] [bp-C4h]
char v64[4]; // [sp+34h] [bp-B8h] BYREF
char v65[4]; // [sp+38h] [bp-B4h] BYREF
char v66[4]; // [sp+3Ch] [bp-B0h] BYREF
char *v67; // [sp+40h] [bp-ACh] BYREF
char v68[4]; // [sp+44h] [bp-A8h] BYREF
char v69[4]; // [sp+48h] [bp-A4h] BYREF
char *v70; // [sp+4Ch] [bp-A0h] BYREF
char *v71; // [sp+50h] [bp-9Ch] BYREF
char *v72; // [sp+54h] [bp-98h] BYREF
char v73[4]; // [sp+58h] [bp-94h] BYREF
char *v74; // [sp+5Ch] [bp-90h] BYREF
char v75[4]; // [sp+60h] [bp-8Ch] BYREF
_BYTE v76[20]; // [sp+64h] [bp-88h] BYREF
unsigned __int8 v77[20]; // [sp+78h] [bp-74h] BYREF
unsigned __int8 v78[44]; // [sp+8Ch] [bp-60h] BYREF
unsigned __int8 v79[44]; // [sp+B8h] [bp-34h] BYREF
v8 = sub_3BE530(a3, "_");
if ( !cocos2d::CCArray::count(v8) )
{
if ( a4 )
{
result = (int)a1->m_levelUpdateDelegate;
if ( !result )
return result;
v10 = *(int (**)(void))(*(_DWORD *)result + 4);
}
else
{
result = (int)a1->m_levelDownloadDelegate;
if ( !result )
return result;
v10 = *(int (**)(void))(*(_DWORD *)result + 4);
}
return v10();
}
v11 = cocos2d::CCArray::stringAtIndex(v8, 0);
v12 = cocos2d::CCString::intValue(v11);
v13 = cocos2d::CCArray::stringAtIndex(v8, 1u);
v62 = cocos2d::CCString::boolValue(v13);
v14 = cocos2d::CCArray::stringAtIndex(v8, 2u);
v61 = cocos2d::CCString::intValue(v14);
GameLevelManager::removeDLFromActive(a1, (const char *)a3->__vftable);
v15 = sub_3BE530(a2, "#");
if ( cocos2d::CCArray::count(v15) > 2u )
{
sub_776584((int)v75, "-1");
v16 = sub_3BE0D8((int)a2, (int)v75);
sub_774008(v75);
if ( !v16 )
{
v17 = cocos2d::CCArray::stringAtIndex(v15, 0);
CString = (char *)cocos2d::CCString::getCString(v17);
sub_776584((int)v64, CString);
v19 = cocos2d::CCArray::stringAtIndex(v15, 1u);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_776584((int)v65, v20);
v21 = cocos2d::CCArray::stringAtIndex(v15, 2u);
v22 = (char *)cocos2d::CCString::getCString(v21);
sub_776584((int)v66, v22);
if ( cocos2d::CCArray::count(v15) > 3u )
{
v23 = cocos2d::CCArray::stringAtIndex(v15, 3u);
v24 = (char *)cocos2d::CCString::getCString(v23);
sub_776584((int)v75, v24);
sub_775C20(&v67, v75);
GameLevelManager::storeUserNames(a1, &v67);
sub_774008(&v67);
sub_774008(v75);
}
if ( cocos2d::CCArray::count(v15) > 4u )
{
v25 = cocos2d::CCArray::stringAtIndex(v15, 4u);
v26 = (char *)cocos2d::CCString::getCString(v25);
sub_776584((int)&v74, v26);
if ( cocos2d::CCArray::count(v15) <= 5u )
{
v28 = (char *)&unk_939830;
}
else
{
v27 = cocos2d::CCArray::stringAtIndex(v15, 5u);
v28 = (char *)cocos2d::CCString::getCString(v27);
}
sub_776584((int)v75, v28);
v63 = MusicDownloadManager::sharedState();
sub_775C20(v68, &v74);
sub_775C20(v69, v75);
MusicDownloadManager::createSongsInfo(v63, (std::string)v68, (std::string)v69);
sub_774008(v69);
sub_774008(v68);
sub_774008(v75);
sub_774008(&v74);
}
sub_775C20(&v70, v64);
GameLevelManager::responseToDict(&v70, 0);
v29 = GJGameLevel::create();
sub_774008(&v70);
if ( v29->m_lowDetailMode )
{
v30 = GameManager::sharedState();
if ( GameManager::getGameVariable(v30, "0108") )
v29->m_lowDetailModeToggled = 1;
}
if ( v62 )
v29->m_gauntletLevel = 1;
if ( v12 == -2 )
GJGameLevel::setDailyID(v29, v29->m_dailyID.random - v29->m_dailyID.seed);
sub_775C20(&v71, &v29->m_levelString);
sub_776584((int)&v72, (char *)&unk_939830);
v31 = strlen(v71);
if ( v31 > 39 )
{
v34 = 40;
v35 = 0;
v36 = (int)(float)((float)v31 / 40.0);
do
{
sub_775170(&v71);
sub_77458C(&v72, (unsigned __int8)v71[v35]);
--v34;
v35 += v36;
}
while ( v34 );
}
else
{
sub_775D40(&v72, &v71);
}
v32 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v33 = (char *)cocos2d::CCString::getCString(v32);
sub_774544((int)&v72, v33);
v37 = (const void *)strlen(v72);
rtsha1::calc((rtsha1 *)v72, v37, (int)v76, v38);
rtsha1::toHexString((rtsha1 *)v76, v78, v39);
sub_776584((int)v73, (char *)v78);
v40 = sub_3BE0D8((int)v73, (int)v65);
sub_774008(v73);
if ( !v40 )
{
if ( a4 )
m_levelUpdateDelegate = a1->m_levelUpdateDelegate;
else
m_levelUpdateDelegate = a1->m_levelDownloadDelegate;
if ( m_levelUpdateDelegate )
(*(void (__fastcall **)(void *, int))(*(_DWORD *)m_levelUpdateDelegate + 4))(m_levelUpdateDelegate, v12);
LABEL_73:
sub_774008(&v72);
sub_774008(&v71);
goto LABEL_74;
}
v42 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i,%i,%i,%i,%i,%i,%i,%i",
(const char *)(v29->m_userID.random - v29->m_userID.seed),
v29->m_stars.random - v29->m_stars.seed,
v29->m_demon.random - v29->m_demon.seed,
v29->m_levelID.random - v29->m_levelID.seed,
v29->m_coinsVerified.random - v29->m_coinsVerified.seed,
v29->m_featured,
v29->m_password.random - v29->m_password.seed,
v29->m_dailyID.random - v29->m_dailyID.seed);
v43 = (char *)cocos2d::CCString::getCString(v42);
sub_776584((int)&v74, v43);
v44 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v45 = (char *)cocos2d::CCString::getCString(v44);
sub_774544((int)&v74, v45);
v46 = (const void *)strlen(v74);
rtsha1::calc((rtsha1 *)v74, v46, (int)v77, v47);
rtsha1::toHexString((rtsha1 *)v77, v79, v48);
sub_776584((int)v75, (char *)v79);
v49 = sub_3BE0D8((int)v75, (int)v66);
sub_774008(v75);
if ( !v49 )
{
if ( !a4 )
{
m_levelDownloadDelegate = a1->m_levelDownloadDelegate;
LABEL_50:
if ( m_levelDownloadDelegate )
(*(void (__fastcall **)(void *, int))(*(_DWORD *)m_levelDownloadDelegate + 4))(m_levelDownloadDelegate, v12);
sub_774008(&v74);
goto LABEL_73;
}
LABEL_49:
m_levelDownloadDelegate = a1->m_levelUpdateDelegate;
goto LABEL_50;
}
if ( a4 )
{
if ( v61 > 0 )
GJGameLevel::setDailyID(v29, v61);
SavedLevel = GameLevelManager::getSavedLevel(a1, v29);
if ( !SavedLevel )
goto LABEL_49;
if ( v29->m_levelVersion > SavedLevel->m_levelVersion )
v52 = 3;
else
v52 = 1;
GameLevelManager::saveLevel(a1, v29);
LevelKey = GameLevelManager::getLevelKey(a1, v12);
GameLevelManager::makeTimeStamp(a1, LevelKey);
GameLevelManager::updateLevelRewards(a1, v29);
v54 = a1->m_levelUpdateDelegate;
if ( v54 )
v54->levelUpdateFinished(v54, v29, (UpdateResponse)v52);
}
else
{
switch ( v12 )
{
case -1:
GameLevelManager::saveLevel(a1, v29);
v55 = v29->m_dailyID.random - v29->m_dailyID.seed;
if ( a1->m_activeDailyID < v55 )
a1->m_activeDailyID = v55;
break;
case -2:
GameLevelManager::saveLevel(a1, v29);
v56 = v29->m_dailyID.random - v29->m_dailyID.seed;
if ( a1->m_activeWeeklyID < v56 )
a1->m_activeWeeklyID = v56;
break;
case -3:
GameLevelManager::saveLevel(a1, v29);
v57 = v29->m_dailyID.random - v29->m_dailyID.seed;
if ( a1->m_activeEventID < v57 )
a1->m_activeEventID = v57;
break;
default:
GameLevelManager::markLevelAsDownloaded(a1, v12);
GameLevelManager::saveLevel(a1, v29);
LevelDownloadKey = GameLevelManager::getLevelDownloadKey(a1, v12, v62, v61);
GameLevelManager::makeTimeStamp(a1, LevelDownloadKey);
v60 = a1->m_levelDownloadDelegate;
if ( v60 )
v60->levelDownloadFinished(v60, v29);
GameLevelManager::updateLevelRewards(a1, v29);
goto LABEL_57;
}
v58 = a1->m_levelDownloadDelegate;
if ( v58 )
v58->levelDownloadFinished(v58, v29);
}
LABEL_57:
sub_774008(&v74);
sub_774008(&v72);
sub_774008(&v71);
LABEL_74:
sub_774008(v66);
sub_774008(v65);
return sub_774008(v64);
}
}
if ( a4 )
result = (int)a1->m_levelUpdateDelegate;
else
result = (int)a1->m_levelDownloadDelegate;
if ( result )
{
v10 = *(int (**)(void))(*(_DWORD *)result + 4);
return v10();
}
return result;
}