//
// GameLevelManager::downloadLevel from 0x4bd34c to 0x4bd6a6 (858 bytes)
//
// 5 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x49a02a
// > LevelBrowserLayer::claimRecallChest @ 0x4a9066
// > DailyLevelPage::downloadAndCreateNode @ 0x606ece
// > DailyLevelPage::skipDailyLevel @ 0x607094
// > DailyLevelPage::dailyStatusFinished @ 0x609026
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:50:19 +0000
//
int __fastcall GameLevelManager::downloadLevel(GameLevelManager *this, const char *a2, bool a3, const char *a4)
{
const char *v6; // r9
const char *LevelDownloadKey; // r6
int result; // r0
int v9; // r2
int v10; // r3
int v11; // r5
cocos2d::CCString *v12; // r0
int CString; // r0
cocos2d::CCString *v14; // r0
char *v15; // r0
int v16; // r2
int v17; // r3
cocos2d::CCString *v18; // r0
char *v19; // r0
cocos2d::CCString *v20; // r0
char *v21; // r0
char *v22; // r1
GJAccountManager *v23; // r0
char *v24; // r10
GameManager *v25; // r0
int v26; // r9
int v27; // r0
int *v28; // r0
char *v29; // r11
int v30; // r0
int v31; // r8
cocos2d::CCString *v32; // r0
int v33; // r0
cocos2d::CCString *v34; // r0
const char *v35; // r5
size_t v36; // r0
char *v37; // r5
const void *v38; // r0
unsigned __int8 *v39; // r3
char *v40; // r2
size_t v41; // r0
char *v42; // r1
size_t v43; // r2
size_t v44; // r0
size_t v45; // r0
char *v46[3]; // [sp+1Ch] [bp-A8h] BYREF
char v47; // [sp+28h] [bp-9Ch] BYREF
char v48[7]; // [sp+29h] [bp-9Bh] BYREF
char *v49; // [sp+30h] [bp-94h]
int v50[3]; // [sp+34h] [bp-90h] BYREF
int v51[3]; // [sp+40h] [bp-84h] BYREF
int v52[3]; // [sp+4Ch] [bp-78h] BYREF
int v53[2]; // [sp+58h] [bp-6Ch] BYREF
char *v54; // [sp+60h] [bp-64h]
int v55; // [sp+64h] [bp-60h] BYREF
int v56; // [sp+68h] [bp-5Ch]
char *v57; // [sp+6Ch] [bp-58h]
int v58; // [sp+70h] [bp-54h] BYREF
size_t v59; // [sp+74h] [bp-50h]
char *v60; // [sp+78h] [bp-4Ch]
unsigned __int8 v61[20]; // [sp+7Ch] [bp-48h] BYREF
unsigned __int8 v62[44]; // [sp+90h] [bp-34h] BYREF
v6 = a4;
LevelDownloadKey = (const char *)GameLevelManager::getLevelDownloadKey(this, a2, a3, (int)a4);
result = GameLevelManager::isDLActive(this, LevelDownloadKey);
if ( !result )
{
GameLevelManager::addDLToActive(this, LevelDownloadKey, v9, v10);
v11 = (unsigned __int8)GameLevelManager::hasDownloadedLevel(this, a2) ^ 1;
GameLevelManager::getBasePostString((GameLevelManager *)v46);
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_54 + 3,
"mfd",
"2893",
103,
98,
&a1i2r3e45s789g[9]);
CString = cocos2d::CCString::getCString(v12);
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&levelID=%i&inc=%i&secret=%s",
a2,
v11,
CString);
v15 = (char *)cocos2d::CCString::getCString(v14);
std::string::append(v46, v15);
if ( (int)a2 > 0 && (int)v6 > 0 )
{
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"&dailyID=%i", v6);
v19 = (char *)cocos2d::CCString::getCString(v18);
std::string::append(v46, v19);
v17 = 200000;
if ( (int)v6 > 200000 )
{
v6 = &v47;
GameLevelManager::rewardSessionToken((GameLevelManager *)&v47);
if ( (v47 & 1) != 0 )
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"&rchk=%s", v49);
else
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"&rchk=%s", v48);
v21 = (char *)cocos2d::CCString::getCString(v20);
std::string::append(v46, v21);
std::string::~string((int)&v47);
}
}
if ( v11 )
{
gen_random(v53, 10, v16, v17);
std::string::append(v46, "&rs=");
if ( (v53[0] & 1) != 0 )
v22 = v54;
else
v22 = (char *)v53 + 1;
v23 = (GJAccountManager *)std::string::append(v46, v22);
if ( (v53[0] & 1) != 0 )
v24 = v54;
else
v24 = (char *)v53 + 1;
v25 = (GameManager *)GJAccountManager::sharedState(v23);
v26 = *((_DWORD *)v25 + 70) - *((_DWORD *)v25 + 71);
v27 = GameManager::sharedState(v25);
v28 = std::string::basic_string(v50, v27 + 436);
if ( (v50[0] & 1) != 0 )
v29 = (char *)v50[2];
else
v29 = (char *)v50 + 1;
v30 = GameManager::sharedState((GameManager *)v28);
v31 = *(_DWORD *)(v30 + 464) - *(_DWORD *)(v30 + 468);
v32 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v33 = cocos2d::CCString::getCString(v32);
v34 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i%i%s%i%s%i%s",
a2,
v11,
v24,
v26,
v29,
v31,
v33);
v35 = (const char *)cocos2d::CCString::getCString(v34);
v55 = 0;
v56 = 0;
v57 = nullptr;
v36 = strlen(v35);
std::string::__init(&v55, v35, v36);
std::string::~string((int)v50);
if ( (v55 & 1) != 0 )
v37 = v57;
else
v37 = (char *)&v55 + 1;
v38 = (const void *)strlen(v37);
rtsha1::calc((rtsha1 *)v37, v38, (int)v61, v39);
rtsha1::toHexString((rtsha1 *)v61, v62, v40);
memset(v51, 0, sizeof(v51));
v41 = strlen((const char *)v62);
std::string::__init(v51, v62, v41);
v6 = (const char *)v52;
memset(v52, 0, sizeof(v52));
std::string::__init(v52, "41274", 5u);
cocos2d::ZipUtils::base64EncodeEnc(&v58, v51, v52);
std::string::~string((int)v52);
std::string::~string((int)v51);
std::string::append(v46, "&chk=");
if ( (v58 & 1) != 0 )
{
v42 = v60;
v43 = v59;
}
else
{
v43 = (int)(unsigned __int8)v58 >> 1;
v42 = (char *)&v58 + 1;
}
std::string::append(v46, v42, v43);
std::string::~string((int)&v58);
std::string::~string((int)&v55);
std::string::~string((int)v53);
}
v53[0] = 0;
v53[1] = 0;
v54 = nullptr;
std::string::__init(v53, "https://www.boomlings.com/database/downloadGJLevel22.php", 0x38u);
v55 = 0;
v56 = 0;
if ( ((int)v46[0] & 1) == 0 )
v6 = (char *)v46 + 1;
v57 = nullptr;
if ( ((int)v46[0] & 1) != 0 )
v6 = v46[2];
v44 = strlen(v6);
std::string::__init(&v55, v6, v44);
v58 = 0;
v59 = 0;
v60 = nullptr;
v45 = strlen(LevelDownloadKey);
std::string::__init(&v58, LevelDownloadKey, v45);
GameLevelManager::ProcessHttpRequest(this, v53, (int)&v55, (int)&v58, 4);
std::string::~string((int)&v58);
std::string::~string((int)&v55);
std::string::~string((int)v53);
return std::string::~string((int)v46);
}
return result;
}