//
// GameLevelManager::getGJChallenges from 0x140167510 to 0x140167963 (1107 bytes)
//
// 4 xrefs:
// > ChallengesPage::init @ 0x140085b65
// > ChallengesPage::tryGetChallenges @ 0x1400860cf
// > ChallengesPage::updateTimers @ 0x1400867a6
// > ??> @ 0x1406cacec
//
// 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
//
// Hidden C++ exception states: #wind=8
bool GameLevelManager::getGJChallenges(GameLevelManager *a1)
{
__int64 v2; // rbx
void *v3; // rcx
__int64 v5; // rax
__int64 v6; // rcx
void *v7; // rcx
__int64 v8; // rax
cocos2d::CCString *v9; // rax
const char *CString; // rax
size_t v11; // rbx
size_t v12; // r8
const char *v13; // rax
const char *v14; // rdi
const char *v15; // rsi
cocos2d::CCString *v16; // rax
const char *v17; // rax
cocos2d::CCString *v18; // rax
char *v19; // rax
size_t v20; // r8
_QWORD *v21; // rdx
void *v22; // rcx
void *v23; // [rsp+40h] [rbp-C0h]
__int128 v24; // [rsp+48h] [rbp-B8h] BYREF
__int64 v25; // [rsp+58h] [rbp-A8h]
__int64 v26; // [rsp+60h] [rbp-A0h]
__int128 v27; // [rsp+68h] [rbp-98h] BYREF
__int64 v28; // [rsp+78h] [rbp-88h]
__int64 v29; // [rsp+80h] [rbp-80h]
__int128 *v30; // [rsp+88h] [rbp-78h]
void *Block[2]; // [rsp+98h] [rbp-68h] BYREF
__int64 v32; // [rsp+A8h] [rbp-58h]
unsigned __int64 v33; // [rsp+B0h] [rbp-50h]
void *v34[2]; // [rsp+B8h] [rbp-48h] BYREF
__int64 v35; // [rsp+C8h] [rbp-38h]
unsigned __int64 v36; // [rsp+D0h] [rbp-30h]
__int128 v37; // [rsp+D8h] [rbp-28h] BYREF
__int64 v38; // [rsp+E8h] [rbp-18h]
__int64 v39; // [rsp+F0h] [rbp-10h]
_QWORD Src[4]; // [rsp+F8h] [rbp-8h] BYREF
_QWORD v41[4]; // [rsp+118h] [rbp+18h] BYREF
Block[1] = nullptr;
v32 = 8;
v33 = 15;
Block[0] = (void *)0x6C6168635F746567LL;
v2 = cocos2d::CCDictionary::objectForKey(a1->m_downloadObjects, Block);
if ( v33 > 0xF )
{
v3 = Block[0];
if ( v33 + 1 >= 0x1000 )
{
v3 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v3 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v3);
}
if ( v2 )
return 0;
Block[1] = nullptr;
v32 = 8;
v33 = 15;
Block[0] = (void *)0x6C6168635F746567LL;
v5 = cocos2d::CCNode::create();
cocos2d::CCDictionary::setObject(a1->m_downloadObjects, v5, Block);
if ( v33 > 0xF )
{
v7 = Block[0];
if ( v33 + 1 >= 0x1000 )
{
v7 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v7 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v7);
}
GameLevelManager::getBasePostString(v6, Src);
v8 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v23 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v8 = qword_1406C2ED8;
}
v9 = cocos2d::CCString::createWithFormat("%i", *(_DWORD *)(v8 + 888) - *(_DWORD *)(v8 + 892));
CString = cocos2d::CCString::getCString(v9);
*(_OWORD *)v34 = 0;
v35 = 0;
v36 = 0;
v11 = -1;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003A930(v34, CString, v12);
*(_OWORD *)Block = 0;
v32 = 5;
v33 = 15;
strcpy((char *)Block, "19847");
cocos2d::ZipUtils::base64EncodeEnc(v41, v34, Block);
v13 = (const char *)sub_140142B90(&v37, 5u);
v14 = v13;
v15 = (const char *)v41;
if ( v41[3] > 0xFu )
v15 = (const char *)v41[0];
if ( *((_QWORD *)v13 + 3) > 0xFu )
v14 = *(const char **)v13;
v16 = cocos2d::CCString::createWithFormat("%c%s%s%c%c%s", 87, "mfd", "2893", 103, 98, (const char *)&word_140531E88);
v17 = cocos2d::CCString::getCString(v16);
v18 = cocos2d::CCString::createWithFormat("&world=%i&gdl=%i&secret=%s&chk=%s%s", 0, 0, v17, v14, v15);
v19 = (char *)cocos2d::CCString::getCString(v18);
v20 = -1;
do
++v20;
while ( v19[v20] );
sub_140041270(Src, v19, v20);
sub_14003A830((__int64)&v37);
v30 = &v37;
v28 = 8;
v29 = 15;
v27 = 0x6C6168635F746567uLL;
v21 = Src;
if ( Src[3] > 0xFu )
v21 = (_QWORD *)Src[0];
v37 = 0;
v38 = 0;
v39 = 0;
do
++v11;
while ( *((_BYTE *)v21 + v11) );
sub_14003A930(&v37, v21, v11);
v24 = 0;
*(_QWORD *)&v24 = sub_14003AA10(0x40u);
v25 = 54;
v26 = 63;
strcpy((char *)v24, "https://www.boomlings.com/database/getGJChallenges.php");
GameLevelManager::ProcessHttpRequest(a1, (__int64)&v24, (const char *)&v37, (const char *)&v27, 47);
sub_14003A830((__int64)v41);
if ( v36 > 0xF )
{
v22 = v34[0];
if ( v36 + 1 >= 0x1000 )
{
v22 = *((void **)v34[0] - 1);
if ( (unsigned __int64)((char *)v34[0] - (char *)v22 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v22);
}
v35 = 0;
v36 = 15;
LOBYTE(v34[0]) = 0;
sub_14003A830((__int64)Src);
return 1;
}