//
// GameLevelManager::downloadLevel from 0x71dfa0 to 0x71e794 (2036 bytes)
//
// 5 xrefs:
// > LevelInfoLayer::downloadLevel @ 0x6d78c4
// > DailyLevelPage::downloadAndCreateNode @ 0x913008
// > DailyLevelPage::skipDailyLevel @ 0x9137f8
// > DailyLevelPage::dailyStatusFinished @ 0x915e5c
// > ??> @ 0x9b418
//
// 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; // x21
_BOOL4 v7; // w23
cocos2d::CCString *v8; // x0
const char *CString; // x0
cocos2d::CCString *v10; // x0
size_t v11; // x0
size_t v12; // x0
char *v13; // x28
GJAccountManager *v14; // x0
unsigned int v15; // w27
GameManager *v16; // x0
unsigned int v17; // w26
cocos2d::CCString *v18; // x0
const char *v19; // x0
cocos2d::CCString *v20; // x0
char *v21; // x0
int *p_m_leaderboardLevelPoints; // x0
char *v23; // x23
unsigned int v24; // w0
unsigned __int8 *v25; // x3
char *v26; // x2
char *v27; // x0
void *v28; // x0
int *p_m_unknown2; // x0
char *v30; // x0
char *v31; // x0
unsigned int *v32; // x1
int v33; // w2
int *v34; // x0
char *v35; // x0
char *v36; // x0
char *v37; // x21
unsigned int *v38; // x20
int v39; // w0
unsigned int *v40; // x1
int v41; // w2
unsigned int *v42; // x1
int v43; // w2
unsigned int *v44; // x1
int v45; // w2
unsigned int *v46; // x1
int v47; // w2
unsigned int *p_timeoutForConnect; // x1
int timeoutForConnect; // w2
unsigned int *p_m_practiceOpacity; // x1
int m_practiceOpacity_low; // w2
unsigned int *v52; // x1
int v53; // w2
unsigned int *v54; // x1
int v55; // w2
const char *v56; // [xsp+68h] [xbp+68h]
char *v57; // [xsp+68h] [xbp+68h]
GameManager *v58; // [xsp+68h] [xbp+68h]
char *v59; // [xsp+88h] [xbp+88h] BYREF
GameManager *v60; // [xsp+90h] [xbp+90h] BYREF
__int64 v61; // [xsp+98h] [xbp+98h] BYREF
std::string v62; // [xsp+A0h] [xbp+A0h] BYREF
char *v63; // [xsp+A8h] [xbp+A8h] BYREF
char *v64; // [xsp+B0h] [xbp+B0h] BYREF
cocos2d::extension::CCHttpClient *v65; // [xsp+B8h] [xbp+B8h] BYREF
unsigned __int8 v66[24]; // [xsp+C0h] [xbp+C0h] BYREF
unsigned __int8 v67[48]; // [xsp+D8h] [xbp+D8h] BYREF
std::string v68; // 0:x2.8
LevelDownloadKey = (char *)GameLevelManager::getLevelDownloadKey(a1, a2, a3, a4);
if ( !GameLevelManager::isDLActive(a1, LevelDownloadKey) )
{
GameLevelManager::addDLToActive(a1, LevelDownloadKey);
v7 = !GameLevelManager::hasDownloadedLevel(a1, a2);
GameLevelManager::getBasePostString(a1, (__int64)&v59);
v8 = (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(v8);
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&levelID=%i&inc=%i&secret=%s",
(const char *)(unsigned int)a2,
v7,
CString);
v56 = cocos2d::CCString::getCString(v10);
v11 = strlen(v56);
sub_D15FD4(&v59, v56, v11);
if ( v7 )
{
gen_random(10, (__int64)&v63);
sub_D15FD4(&v59, "&rs=", 4);
v57 = v63;
v12 = strlen(v63);
sub_D15FD4(&v59, v57, v12);
v13 = v63;
v14 = GJAccountManager::sharedState();
v15 = v14->m_accountID - v14->m_unkInt1;
GameManager::sharedState();
sub_D18D28(&v60);
v58 = v60;
v16 = GameManager::sharedState();
v17 = v16->m_playerUserID.random - v16->m_playerUserID.seed;
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_78,
"I25",
"fpAa",
112,
67,
"Qg");
v19 = cocos2d::CCString::getCString(v18);
v20 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i%i%s%i%s%i%s",
(const char *)(unsigned int)a2,
v7,
v13,
v15,
v58,
v17,
v19);
v21 = (char *)cocos2d::CCString::getCString(v20);
sub_D153B8((int)&v64, v21);
p_m_leaderboardLevelPoints = &v60[-1].m_leaderboardLevelPoints;
if ( &v60[-1].m_leaderboardLevelPoints != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_m_practiceOpacity = (unsigned int *)&v60[-1].m_practiceOpacity;
do
m_practiceOpacity_low = __ldaxr(p_m_practiceOpacity);
while ( __stlxr(m_practiceOpacity_low - 1, p_m_practiceOpacity) );
}
else
{
m_practiceOpacity_low = LODWORD(v60[-1].m_practiceOpacity);
LODWORD(v60[-1].m_practiceOpacity) = m_practiceOpacity_low - 1;
}
if ( m_practiceOpacity_low <= 0 )
operator delete(p_m_leaderboardLevelPoints);
}
v23 = v64;
v24 = strlen(v64);
rtsha1::calc((rtsha1 *)v23, (const void *)v24, (__int64)v66, v25);
rtsha1::toHexString((rtsha1 *)v66, v67, v26);
sub_D153B8((int)&v61, (char *)v67);
sub_D153B8((int)&v62, "41274");
cocos2d::ZipUtils::base64EncodeEnc((cocos2d::ZipUtils *)&v61, &v62, v68);
v27 = (char *)v62.m_data.m_data - 24;
if ( (__int64 *)v62.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v54 = (unsigned int *)((char *)v62.m_data.m_data - 8);
do
v55 = __ldaxr(v54);
while ( __stlxr(v55 - 1, v54) );
}
else
{
v55 = *((_DWORD *)v62.m_data.m_data - 2);
*((_DWORD *)v62.m_data.m_data - 2) = v55 - 1;
}
if ( v55 <= 0 )
operator delete(v27);
}
v28 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v46 = (unsigned int *)(v61 - 8);
do
v47 = __ldaxr(v46);
while ( __stlxr(v47 - 1, v46) );
}
else
{
v47 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v47 - 1;
}
if ( v47 <= 0 )
operator delete(v28);
}
sub_D15FD4(&v59, "&chk=", 5);
sub_D15E14(&v59, &v65);
p_m_unknown2 = &v65[-1].m_unknown2;
if ( &v65[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v65[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v65[-1]._timeoutForConnect;
v65[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
}
v30 = v64 - 24;
if ( v64 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)(v64 - 8);
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = *((_DWORD *)v64 - 2);
*((_DWORD *)v64 - 2) = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v30);
}
v31 = v63 - 24;
if ( v63 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v32 = (unsigned int *)(v63 - 8);
do
v33 = __ldaxr(v32);
while ( __stlxr(v33 - 1, v32) );
}
else
{
v33 = *((_DWORD *)v63 - 2);
*((_DWORD *)v63 - 2) = v33 - 1;
}
if ( v33 <= 0 )
operator delete(v31);
}
}
sub_D153B8((int)&v63, "https://www.boomlings.com/database/downloadGJLevel22.php");
sub_D153B8((int)&v64, v59);
sub_D153B8((int)&v65, LevelDownloadKey);
GameLevelManager::ProcessHttpRequest(a1, (const char **)&v63, (const char **)&v64, &v65, 4);
v34 = &v65[-1].m_unknown2;
if ( &v65[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v42 = (unsigned int *)&v65[-1]._timeoutForConnect;
do
v43 = __ldaxr(v42);
while ( __stlxr(v43 - 1, v42) );
}
else
{
v43 = v65[-1]._timeoutForConnect;
v65[-1]._timeoutForConnect = v43 - 1;
}
if ( v43 <= 0 )
operator delete(v34);
}
v35 = v64 - 24;
if ( v64 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v44 = (unsigned int *)(v64 - 8);
do
v45 = __ldaxr(v44);
while ( __stlxr(v45 - 1, v44) );
}
else
{
v45 = *((_DWORD *)v64 - 2);
*((_DWORD *)v64 - 2) = v45 - 1;
}
if ( v45 <= 0 )
operator delete(v35);
}
v36 = v63 - 24;
if ( v63 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v40 = (unsigned int *)(v63 - 8);
do
v41 = __ldaxr(v40);
while ( __stlxr(v41 - 1, v40) );
}
else
{
v41 = *((_DWORD *)v63 - 2);
*((_DWORD *)v63 - 2) = v41 - 1;
}
if ( v41 <= 0 )
operator delete(v36);
}
v37 = v59 - 24;
if ( v59 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v38 = (unsigned int *)(v59 - 8);
do
v39 = __ldaxr(v38);
while ( __stlxr(v39 - 1, v38) );
}
else
{
v39 = *((_DWORD *)v59 - 2);
*((_DWORD *)v59 - 2) = v39 - 1;
}
if ( v39 <= 0 )
operator delete(v37);
}
}
}