//
// GameLevelManager::downloadLevel from 0x3d0040 to 0x3d02a6 (614 bytes)
//
// 4 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x3b194a
// > DailyLevelPage::downloadAndCreateNode @ 0x4d3de6
// > DailyLevelPage::skipDailyLevel @ 0x4d4298
// > DailyLevelPage::dailyStatusFinished @ 0x4d5a9e
//
// 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 GameLevelManager::downloadLevel(GameLevelManager *a1, int a2, bool a3, int a4)
{
char *LevelDownloadKey; // r7
_BOOL4 v7; // r6
cocos2d::CCString *v8; // r0
const char *CString; // r0
cocos2d::CCString *v10; // r0
char *v11; // r0
char *v12; // r10
GJAccountManager *v13; // r0
int v14; // r9
GameManager *v15; // r0
int v16; // r11
cocos2d::CCString *v17; // r0
const char *v18; // r0
cocos2d::CCString *v19; // r0
char *v20; // r0
const void *v21; // r0
unsigned __int8 *v22; // r3
char *v23; // r2
int v24; // [sp+10h] [bp-74h]
char *v25; // [sp+20h] [bp-64h] BYREF
int v26; // [sp+24h] [bp-60h] BYREF
std::string v27; // [sp+28h] [bp-5Ch] BYREF
_BYTE v28[4]; // [sp+2Ch] [bp-58h] BYREF
char *v29; // [sp+30h] [bp-54h] BYREF
char *v30; // [sp+34h] [bp-50h] BYREF
char *v31; // [sp+38h] [bp-4Ch] BYREF
unsigned __int8 v32[20]; // [sp+3Ch] [bp-48h] BYREF
unsigned __int8 v33[44]; // [sp+50h] [bp-34h] BYREF
LevelDownloadKey = (char *)GameLevelManager::getLevelDownloadKey(a1, a2, a3, a4);
if ( !GameLevelManager::isDLActive(a1, LevelDownloadKey) )
{
GameLevelManager::addDLToActive(a1, LevelDownloadKey);
v7 = !GameLevelManager::hasDownloadedLevel(a1, a2);
GameLevelManager::getBasePostString((GameLevelManager *)&v25);
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_54 + 3,
"mfd",
"2893",
103,
98,
&aO1i2r3e45s7t89[10]);
CString = cocos2d::CCString::getCString(v8);
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&levelID=%i&inc=%i&secret=%s",
(const char *)a2,
v7,
CString);
v11 = (char *)cocos2d::CCString::getCString(v10);
sub_774544((int)&v25, v11);
if ( v7 )
{
gen_random((int)&v29, 10);
sub_774544((int)&v25, "&rs=");
sub_774544((int)&v25, v29);
v12 = v29;
v13 = GJAccountManager::sharedState();
v14 = v13->m_accountID - v13->m_unkInt1;
GameManager::sharedState();
sub_775C20(&v26);
v24 = v26;
v15 = GameManager::sharedState();
v16 = v15->m_playerUserID.random - v15->m_playerUserID.seed;
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v18 = cocos2d::CCString::getCString(v17);
v19 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i%i%s%i%s%i%s",
(const char *)a2,
v7,
v12,
v14,
v24,
v16,
v18);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_776584((int)&v30, v20);
sub_774008(&v26);
v21 = (const void *)strlen(v30);
rtsha1::calc((rtsha1 *)v30, v21, (int)v32, v22);
rtsha1::toHexString((rtsha1 *)v32, v33, v23);
sub_776584((int)&v27, (char *)v33);
sub_776584((int)v28, "41274");
cocos2d::ZipUtils::base64EncodeEnc((cocos2d::ZipUtils *)&v31, &v27, (std::string)v28);
sub_774008(v28);
sub_774008(&v27);
sub_774544((int)&v25, "&chk=");
sub_77441C(&v25, &v31);
sub_774008(&v31);
sub_774008(&v30);
sub_774008(&v29);
}
sub_776584((int)&v29, "https://www.boomlings.com/database/downloadGJLevel22.php");
sub_776584((int)&v30, v25);
sub_776584((int)&v31, LevelDownloadKey);
GameLevelManager::ProcessHttpRequest(a1, &v29, (const char **)&v30, &v31, 4);
sub_774008(&v31);
sub_774008(&v30);
sub_774008(&v29);
sub_774008(&v25);
}
}