//
// GameLevelManager::downloadLevel from 0x140231c00 to 0x140232220 (1568 bytes)
//
// 6 xrefs:
// > DailyLevelPage::dailyStatusFinished @ 0x140170ae1
// > DailyLevelPage::downloadAndCreateNode @ 0x14017106e
// > DailyLevelPage::skipDailyLevel @ 0x140172a51
// > LevelBrowserLayer::claimRecallChest @ 0x1403eb390
// > LevelInfoLayer::downloadLevel @ 0x14041f33d
// > ??> @ 0x14091bf20
//
// This function is hookable on this platform (idp: pc, 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 11:28:30 +0000
//
// Hidden C++ exception states: #wind=13
void __fastcall GameLevelManager::downloadLevel(cocos2d::CCActionManager **a1, __int64 a2, unsigned __int8 a3, int a4)
{
int v5; // r13d
cocos2d::CCActionManager **v6; // rsi
cocos2d::CCString *v7; // rax
char *CString; // r12
int v9; // edi
__int64 v10; // rcx
cocos2d::CCString *v11; // rax
const char *v12; // rax
cocos2d::CCString *v13; // rax
char *v14; // rax
size_t v15; // r15
size_t v16; // r8
__int64 v17; // rcx
cocos2d::CCString *v18; // rax
char *v19; // rax
size_t v20; // r8
__int64 v21; // rax
cocos2d::CCString *v22; // rax
char *v23; // rax
size_t v24; // r8
void **v25; // rdx
size_t v26; // r8
__int64 v27; // rdx
__int64 v28; // rcx
__int64 v29; // rax
int v30; // r14d
const char *v31; // rsi
__int64 v32; // rax
int v33; // edi
void **v34; // rbx
cocos2d::CCString *v35; // rax
const char *v36; // rax
cocos2d::CCString *v37; // rax
const char *v38; // rax
size_t v39; // r8
__int128 *v40; // r8
__int128 *v41; // r9
__int64 v42; // rdx
size_t v43; // r8
void *v44; // rcx
void **v45; // rdx
size_t v46; // r8
_QWORD *v47; // rdx
uintptr_t Reserved; // [rsp+20h] [rbp-E0h]
__int64 v49; // [rsp+28h] [rbp-D8h]
int v50; // [rsp+40h] [rbp-C0h]
void *v51; // [rsp+48h] [rbp-B8h]
void *v52; // [rsp+48h] [rbp-B8h]
__int128 v53; // [rsp+50h] [rbp-B0h] BYREF
__int64 v54; // [rsp+60h] [rbp-A0h]
__int64 v55; // [rsp+68h] [rbp-98h]
cocos2d::CCActionManager **v56; // [rsp+70h] [rbp-90h]
void *v57[2]; // [rsp+78h] [rbp-88h] BYREF
__int64 v58; // [rsp+88h] [rbp-78h]
unsigned __int64 v59; // [rsp+90h] [rbp-70h]
void *Block[2]; // [rsp+98h] [rbp-68h] BYREF
__int64 v61; // [rsp+A8h] [rbp-58h]
unsigned __int64 v62; // [rsp+B0h] [rbp-50h]
_QWORD Src[4]; // [rsp+B8h] [rbp-48h] BYREF
void *v64[2]; // [rsp+D8h] [rbp-28h] BYREF
size_t Size; // [rsp+E8h] [rbp-18h]
unsigned __int64 v66; // [rsp+F0h] [rbp-10h]
__int128 v67; // [rsp+F8h] [rbp-8h] BYREF
__int64 v68; // [rsp+108h] [rbp+8h]
unsigned __int64 v69; // [rsp+110h] [rbp+10h]
_QWORD v70[4]; // [rsp+118h] [rbp+18h] BYREF
_BYTE v71[48]; // [rsp+138h] [rbp+38h] BYREF
v5 = a2;
v6 = a1;
v56 = a1;
v7 = cocos2d::CCString::createWithFormat("%i_%i_%i", a2, a3);
CString = (char *)cocos2d::CCString::getCString(v7);
if ( !GameLevelManager::isDLActive((__int64)v6, CString) )
{
GameLevelManager::addDLToActive((__int64)v6, CString);
v9 = (unsigned __int8)GameLevelManager::hasDownloadedLevel(v6, (unsigned int)v5) ^ 1;
v50 = v9;
GameLevelManager::getBasePostString(v10, Src);
v11 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 87, "mfd", "2893", 103, 98, (const char *)&word_14070D040);
v12 = cocos2d::CCString::getCString(v11);
v13 = cocos2d::CCString::createWithFormat("&levelID=%i&inc=%i&secret=%s", v5, v9, v12);
v14 = (char *)cocos2d::CCString::getCString(v13);
v15 = -1;
v16 = -1;
do
++v16;
while ( v14[v16] );
sub_140044D80(Src, v14, v16);
if ( v5 > 0 )
{
if ( a4 > 0 )
{
v18 = cocos2d::CCString::createWithFormat("&dailyID=%i", a4);
v19 = (char *)cocos2d::CCString::getCString(v18);
v20 = -1;
do
++v20;
while ( v19[v20] );
sub_140044D80(Src, v19, v20);
}
if ( a4 > 200000 )
{
v21 = GameLevelManager::rewardSessionToken(v17, v70);
if ( *(_QWORD *)(v21 + 24) > 0xFu )
v21 = *(_QWORD *)v21;
v22 = cocos2d::CCString::createWithFormat("&rchk=%s", (const char *)v21);
v23 = (char *)cocos2d::CCString::getCString(v22);
v24 = -1;
do
++v24;
while ( v23[v24] );
sub_140044D80(Src, v23, v24);
sub_14003D310((__int64)v70);
}
}
if ( (_BYTE)v9 )
{
sub_1402190E0(v57, 0xAu);
sub_140044D80(Src, "&rs=", 4u);
v25 = v57;
if ( v59 > 0xF )
v25 = (void **)v57[0];
v26 = -1;
do
++v26;
while ( *((_BYTE *)v25 + v26) );
sub_140044D80(Src, v25, v26);
v27 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v51 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v51);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v27 = qword_14090BFD0;
}
sub_14003F4F0((__int64)v70, v27 + 624);
v29 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v52 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v52);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v29 = qword_14090BFD0;
}
v30 = *(_DWORD *)(v29 + 692) - *(_DWORD *)(v29 + 696);
v31 = (const char *)v70;
if ( v70[3] > 0xFu )
v31 = (const char *)v70[0];
v32 = GJAccountManager::sharedState(v28);
v33 = *(_DWORD *)(v32 + 360) - *(_DWORD *)(v32 + 364);
v34 = v57;
if ( v59 > 0xF )
v34 = (void **)v57[0];
LODWORD(v49) = 67;
LODWORD(Reserved) = 112;
v35 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 120, "I25", "fpAa", Reserved, v49, "Qg");
v36 = cocos2d::CCString::getCString(v35);
v37 = cocos2d::CCString::createWithFormat("%i%i%s%i%s%i%s", v5, v50, (const char *)v34, v33, v31, v30, v36);
v38 = cocos2d::CCString::getCString(v37);
v67 = 0;
v68 = 0;
v69 = 0;
v39 = -1;
do
++v39;
while ( v38[v39] );
sub_14003D230(&v67, v38, v39);
sub_14003D310((__int64)v70);
v40 = &v67;
if ( v69 > 0xF )
v40 = (__int128 *)v67;
v41 = &v67;
if ( v69 > 0xF )
v41 = (__int128 *)v67;
v42 = -1;
do
++v42;
while ( *((_BYTE *)v40 + v42) );
sub_14007E1A0((__int64)v41, v42, Block);
sub_14007E470((unsigned __int8 *)Block, v71);
*(_OWORD *)Block = 0;
v61 = 0;
v62 = 0;
v43 = -1;
do
++v43;
while ( v71[v43] );
sub_14003D230(Block, v71, v43);
v53 = 0;
v54 = 5;
v55 = 15;
strcpy((char *)&v53, "41274");
cocos2d::ZipUtils::base64EncodeEnc(v64, Block, &v53);
if ( v62 > 0xF )
{
v44 = Block[0];
if ( v62 + 1 >= 0x1000 )
{
v44 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v44 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v44);
}
v61 = 0;
v62 = 15;
LOBYTE(Block[0]) = 0;
sub_140044D80(Src, "&chk=", 5u);
v45 = v64;
if ( v66 > 0xF )
v45 = (void **)v64[0];
sub_140044D80(Src, v45, Size);
sub_14003D310((__int64)v64);
sub_14003D310((__int64)&v67);
sub_14003D310((__int64)v57);
v6 = v56;
}
v56 = (cocos2d::CCActionManager **)&v53;
*(_OWORD *)v64 = 0;
Size = 0;
v66 = 0;
v46 = -1;
do
++v46;
while ( CString[v46] );
sub_14003D230(v64, CString, v46);
v47 = Src;
if ( Src[3] > 0xFu )
v47 = (_QWORD *)Src[0];
v53 = 0;
v54 = 0;
v55 = 0;
do
++v15;
while ( *((_BYTE *)v47 + v15) );
sub_14003D230(&v53, v47, v15);
*(_OWORD *)v57 = 0;
v58 = 0;
v59 = 0;
v57[0] = sub_14003D460(0x40u);
v58 = 56;
v59 = 63;
strcpy((char *)v57[0], "https://www.boomlings.com/database/downloadGJLevel22.php");
GameLevelManager::ProcessHttpRequest(v6, (__int64)v57, (const char *)&v53, (const char *)v64, 4u);
sub_14003D310((__int64)Src);
}
}