//
// GameLevelManager::downloadLevel from 0x81fe3c to 0x820484 (1608 bytes)
//
// 6 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x7e5d28
// > LevelBrowserLayer::claimRecallChest @ 0x7fca8c
// > DailyLevelPage::downloadAndCreateNode @ 0xa6cfc0
// > DailyLevelPage::skipDailyLevel @ 0xa6d21c
// > DailyLevelPage::dailyStatusFinished @ 0xa6df24
// > ??> @ 0xcc958
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:55:00 +0000
//
__int64 __fastcall GameLevelManager::downloadLevel(GameLevelManager *this, const char *a2, unsigned __int8 a3, int a4)
{
unsigned int v5; // w23
char *LevelDownloadKey; // x21
_BOOL4 v9; // w24
cocos2d::CCString *v10; // x0
__int64 CString; // x0
cocos2d::CCString *v12; // x0
size_t v13; // x0
const char *v14; // x1
cocos2d::CCString *v15; // x0
size_t v16; // x0
const char *v17; // x1
size_t v18; // x0
char *v19; // x28
__int64 v20; // x0
GameManager *v21; // x0
__int64 v22; // x2
char v23; // w0
GameManager *v24; // x0
__int64 v25; // x1
char *v26; // x27
__int64 v27; // x0
unsigned int v28; // w26
cocos2d::CCString *v29; // x0
__int64 v30; // x0
cocos2d::CCString *v31; // x0
size_t v32; // x0
char *v33; // x23
unsigned int v34; // w0
unsigned __int8 *v35; // x3
char *v36; // x2
size_t v37; // x0
char *v38; // x1
size_t v39; // x2
const char *v40; // x1
size_t v41; // x0
size_t v42; // x0
cocos2d::CCString *v43; // x0
size_t v44; // x0
char *v45; // [xsp+68h] [xbp+68h]
char *v46; // [xsp+68h] [xbp+68h]
char *v47; // [xsp+68h] [xbp+68h]
unsigned int v48; // [xsp+68h] [xbp+68h]
char *v49; // [xsp+68h] [xbp+68h]
char *v50; // [xsp+68h] [xbp+68h]
char *v51; // [xsp+68h] [xbp+68h]
__int64 v52[2]; // [xsp+70h] [xbp+70h] BYREF
void *v53; // [xsp+80h] [xbp+80h]
void *v54[2]; // [xsp+88h] [xbp+88h] BYREF
void *v55; // [xsp+98h] [xbp+98h]
GameManager *v56; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v57; // [xsp+A8h] [xbp+A8h]
void *v58; // [xsp+B0h] [xbp+B0h]
__int64 v59[2]; // [xsp+B8h] [xbp+B8h] BYREF
void *v60; // [xsp+C8h] [xbp+C8h]
__int64 v61[2]; // [xsp+D0h] [xbp+D0h] BYREF
void *v62; // [xsp+E0h] [xbp+E0h]
GJAccountManager *v63[2]; // [xsp+E8h] [xbp+E8h] BYREF
void *v64; // [xsp+F8h] [xbp+F8h]
__int64 v65; // [xsp+100h] [xbp+100h] BYREF
__int64 v66; // [xsp+108h] [xbp+108h]
void *v67; // [xsp+110h] [xbp+110h]
__int64 v68; // [xsp+118h] [xbp+118h] BYREF
size_t v69; // [xsp+120h] [xbp+120h]
void *v70; // [xsp+128h] [xbp+128h]
unsigned __int8 v71[24]; // [xsp+130h] [xbp+130h] BYREF
unsigned __int8 v72[48]; // [xsp+148h] [xbp+148h] BYREF
v5 = (unsigned int)a2;
LevelDownloadKey = (char *)GameLevelManager::getLevelDownloadKey(this, a2, a3);
if ( !GameLevelManager::isDLActive(this, LevelDownloadKey) )
{
GameLevelManager::addDLToActive(this, LevelDownloadKey);
v9 = !GameLevelManager::hasDownloadedLevel(this, (const char *)v5);
GameLevelManager::getBasePostString(v52);
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
CString = cocos2d::CCString::getCString(v10);
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&levelID=%i&inc=%i&secret=%s",
(const char *)v5,
v9,
CString);
v45 = (char *)cocos2d::CCString::getCString(v12);
v13 = strlen(v45);
std::string::append((__int64)v52, v45, v13);
if ( (int)v5 > 0 )
{
if ( a4 > 0 )
{
v43 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&dailyID=%i",
(const char *)(unsigned int)a4);
v51 = (char *)cocos2d::CCString::getCString(v43);
v44 = strlen(v51);
std::string::append((__int64)v52, v51, v44);
}
if ( a4 > 200000 )
{
GameLevelManager::rewardSessionToken(v54);
v14 = (char *)v54 + 1;
if ( ((__int64)v54[0] & 1) != 0 )
v14 = (const char *)v55;
v15 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"&rchk=%s", v14);
v46 = (char *)cocos2d::CCString::getCString(v15);
v16 = strlen(v46);
std::string::append((__int64)v52, v46, v16);
if ( ((__int64)v54[0] & 1) != 0 )
operator delete(v55);
}
}
if ( v9 )
{
gen_random(10, (__int64 *)v63);
std::string::append((__int64)v52, "&rs=", 4u);
v17 = (char *)v63 + 1;
if ( ((__int64)v63[0] & 1) != 0 )
v17 = (const char *)v64;
v47 = (char *)v17;
v18 = strlen(v17);
std::string::append((__int64)v52, v47, v18);
v19 = (char *)v63 + 1;
if ( ((__int64)v63[0] & 1) != 0 )
v19 = (char *)v64;
v20 = GJAccountManager::sharedState((GJAccountManager *)LOBYTE(v63[0]));
v21 = (GameManager *)(unsigned int)(*(_DWORD *)(v20 + 352) - *(_DWORD *)(v20 + 356));
v48 = (unsigned int)v21;
v22 = GameManager::sharedState(v21) + 608;
v23 = *(_BYTE *)v22;
v56 = nullptr;
v57 = 0;
v58 = nullptr;
if ( (v23 & 1) != 0 )
{
std::string::__init((__int64 *)&v56, *(void **)(v22 + 16), *(_QWORD *)(v22 + 8));
}
else
{
v24 = *(GameManager **)v22;
v25 = *(_QWORD *)(v22 + 8);
v58 = *(void **)(v22 + 16);
v56 = v24;
v57 = v25;
}
v26 = (char *)&v56 + 1;
if ( ((unsigned __int8)v56 & 1) != 0 )
v26 = (char *)v58;
v27 = GameManager::sharedState((GameManager *)(unsigned __int8)v56);
v28 = *(_DWORD *)(v27 + 660) - *(_DWORD *)(v27 + 664);
v29 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v30 = cocos2d::CCString::getCString(v29);
v31 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i%i%s%i%s%i%s",
(const char *)v5,
v9,
v19,
v48,
v26,
v28,
v30);
v49 = (char *)cocos2d::CCString::getCString(v31);
v65 = 0;
v66 = 0;
v67 = nullptr;
v32 = strlen(v49);
std::string::__init(&v65, v49, v32);
if ( ((unsigned __int8)v56 & 1) != 0 )
operator delete(v58);
v33 = (char *)&v65 + 1;
if ( (v65 & 1) != 0 )
v33 = (char *)v67;
v34 = strlen(v33);
rtsha1::calc((rtsha1 *)v33, (const void *)v34, (__int64)v71, v35);
rtsha1::toHexString((rtsha1 *)v71, v72, v36);
v59[0] = 0;
v59[1] = 0;
v60 = nullptr;
v37 = strlen((const char *)v72);
std::string::__init(v59, v72, v37);
v61[0] = 0;
v61[1] = 0;
v62 = nullptr;
std::string::__init(v61, "41274", 5u);
cocos2d::ZipUtils::base64EncodeEnc(&v68, v59, v61);
if ( (v61[0] & 1) != 0 )
operator delete(v62);
if ( (v59[0] & 1) != 0 )
operator delete(v60);
std::string::append((__int64)v52, "&chk=", 5u);
if ( (v68 & 1) != 0 )
{
v38 = (char *)v70;
v39 = v69;
}
else
{
v39 = (unsigned __int8)v68 >> 1;
v38 = (char *)&v68 + 1;
}
std::string::append((__int64)v52, v38, v39);
if ( (v68 & 1) != 0 )
operator delete(v70);
if ( (v65 & 1) != 0 )
operator delete(v67);
if ( ((__int64)v63[0] & 1) != 0 )
operator delete(v64);
}
v63[0] = nullptr;
v63[1] = nullptr;
v64 = nullptr;
std::string::__init((__int64 *)v63, "https://www.boomlings.com/database/downloadGJLevel22.php", 0x38u);
v40 = (char *)v52 + 1;
if ( (v52[0] & 1) != 0 )
v40 = (const char *)v53;
v50 = (char *)v40;
v65 = 0;
v66 = 0;
v67 = nullptr;
v41 = strlen(v40);
std::string::__init(&v65, v50, v41);
v68 = 0;
v69 = 0;
v70 = nullptr;
v42 = strlen(LevelDownloadKey);
std::string::__init(&v68, LevelDownloadKey, v42);
GameLevelManager::ProcessHttpRequest(this, (__int64 *)v63, (__int64)&v65, (char *)&v68, 4);
if ( (v68 & 1) != 0 )
operator delete(v70);
if ( (v65 & 1) != 0 )
operator delete(v67);
if ( ((__int64)v63[0] & 1) != 0 )
operator delete(v64);
if ( (v52[0] & 1) != 0 )
operator delete(v53);
}
return _stack_chk_guard;
}