//
// GameLevelManager::getGJChallenges from 0x72a5f0 to 0x72abc8 (1496 bytes)
//
// 3 xrefs:
// > ChallengesPage::tryGetChallenges @ 0x906b7c
// > ChallengesPage::init @ 0x90849c
// > ??> @ 0x39cf0
//
// 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
//
bool GameLevelManager::getGJChallenges(GameLevelManager *a1)
{
_BOOL4 isDLActive; // w1
bool result; // w0
GameManager *v4; // x0
cocos2d::CCString *v5; // x0
char *CString; // x0
char *v7; // x0
cocos2d::CCString *v8; // x0
const char *v9; // x28
cocos2d::CCString *v10; // x0
size_t v11; // x0
void *v12; // x0
int *p_m_unknown2; // x0
char *v14; // x0
char *v15; // x0
void *v16; // x0
void *v17; // x0
char *v18; // x0
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *p_timeoutForConnect; // x1
int timeoutForConnect; // w2
unsigned int *v31; // x1
int v32; // w2
unsigned int *v33; // x1
int v34; // w2
const char *v35; // [xsp+68h] [xbp+68h]
char *v36; // [xsp+88h] [xbp+88h] BYREF
__int64 v37; // [xsp+90h] [xbp+90h] BYREF
__int64 v38; // [xsp+98h] [xbp+98h]
std::string v39; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v40; // [xsp+A8h] [xbp+A8h] BYREF
const char *v41; // [xsp+B0h] [xbp+B0h] BYREF
const char *v42; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::extension::CCHttpClient *v43; // [xsp+C0h] [xbp+C0h] BYREF
std::string v44; // 0:x2.8
isDLActive = GameLevelManager::isDLActive(a1, "get_chal");
result = 0;
if ( !isDLActive )
{
GameLevelManager::addDLToActive(a1, "get_chal");
GameLevelManager::getBasePostString(a1, (__int64)&v36);
v4 = GameManager::sharedState();
v5 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v4->m_chk.random - v4->m_chk.seed));
CString = (char *)cocos2d::CCString::getCString(v5);
sub_D153B8((int)&v37, CString);
sub_D153B8((int)&v39, "19847");
cocos2d::ZipUtils::base64EncodeEnc((cocos2d::ZipUtils *)&v37, &v39, v44);
v7 = (char *)v39.m_data.m_data - 24;
if ( (__int64 *)v39.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)((char *)v39.m_data.m_data - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v39.m_data.m_data - 2);
*((_DWORD *)v39.m_data.m_data - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v7);
}
v8 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
v9 = cocos2d::CCString::getCString(v8);
gen_random(5, (__int64)&v40);
v10 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&world=%i&gdl=%i&secret=%s&chk=%s%s",
nullptr,
0,
v9,
v40,
v38);
v35 = cocos2d::CCString::getCString(v10);
v11 = strlen(v35);
sub_D15FD4(&v36, v35, v11);
v12 = (void *)(v40 - 24);
if ( (__int64 *)(v40 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(v40 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(_DWORD *)(v40 - 8);
*(_DWORD *)(v40 - 8) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v12);
}
sub_D153B8((int)&v41, "https://www.boomlings.com/database/getGJChallenges.php");
sub_D153B8((int)&v42, v36);
sub_D153B8((int)&v43, "get_chal");
GameLevelManager::ProcessHttpRequest(a1, &v41, &v42, &v43, 47);
p_m_unknown2 = &v43[-1].m_unknown2;
if ( &v43[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v43[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v43[-1]._timeoutForConnect;
v43[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
}
v14 = (char *)(v42 - 24);
if ( v42 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v42 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v42 - 2);
*((_DWORD *)v42 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v14);
}
v15 = (char *)(v41 - 24);
if ( v41 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v31 = (unsigned int *)(v41 - 8);
do
v32 = __ldaxr(v31);
while ( __stlxr(v32 - 1, v31) );
}
else
{
v32 = *((_DWORD *)v41 - 2);
*((_DWORD *)v41 - 2) = v32 - 1;
}
if ( v32 <= 0 )
operator delete(v15);
}
v16 = (void *)(v38 - 24);
if ( (__int64 *)(v38 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v38 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v38 - 8);
*(_DWORD *)(v38 - 8) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v16);
}
v17 = (void *)(v37 - 24);
if ( (__int64 *)(v37 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v37 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(_DWORD *)(v37 - 8);
*(_DWORD *)(v37 - 8) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v17);
}
v18 = v36 - 24;
if ( v36 - 24 == (char *)&qword_124B6B0 )
return 1;
if ( &pthread_create )
{
v19 = (unsigned int *)(v36 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v36 - 2);
*((_DWORD *)v36 - 2) = v20 - 1;
}
if ( v20 > 0 )
{
return 1;
}
else
{
operator delete(v18);
return 1;
}
}
return result;
}