//
// GameLevelManager::getGJRewards from 0x729d50 to 0x72a5f0 (2208 bytes)
//
// 4 xrefs:
// > RewardsPage::tryGetRewards @ 0x934760
// > RewardsPage::init @ 0x935b90
// > RewardsPage::onReward @ 0x938d1c
// > ??> @ 0xa2ed0
//
// 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::getGJRewards(GameLevelManager *a1, int a2)
{
_BOOL4 isDLActive; // w1
bool result; // w0
GameStatsManager *v4; // x0
cocos2d::CCArray *v5; // x24
int v6; // w23
unsigned int v7; // w19
int v8; // w26
cocos2d::CCString *v9; // x0
char *CString; // x0
const char *v11; // x1
__int64 *v12; // x0
unsigned __int64 v13; // x4
const char *v14; // x28
int v15; // w0
cocos2d::extension::CCHttpClient *v16; // x27
int *p_m_unknown2; // x0
char *v18; // x0
unsigned int *v19; // x1
int v20; // w2
GameManager *v21; // x0
cocos2d::CCString *v22; // x0
char *v23; // x0
char *v24; // x0
cocos2d::CCString *v25; // x0
const char *v26; // x20
cocos2d::CCString *v27; // x0
size_t v28; // x0
void *v29; // x0
int *v30; // x0
char *v31; // x0
char *v32; // x0
void *v33; // x0
void *v34; // x0
char *v35; // x0
int v36; // w0
unsigned int *p_timeoutForConnect; // x2
int timeoutForConnect; // w1
unsigned int *v39; // x1
int v40; // w2
int v41; // w0
unsigned int *v42; // x19
int v43; // w1
unsigned int *v44; // x1
int v45; // w2
unsigned int *v46; // x1
int v47; // w2
unsigned int *v48; // x1
int v49; // w2
unsigned int *v50; // x1
int v51; // w2
unsigned int *v52; // x1
int v53; // w2
unsigned int *v54; // x1
int v55; // w2
unsigned int *v56; // x1
int v57; // w2
int v60; // [xsp+88h] [xbp+88h]
const char *v61; // [xsp+88h] [xbp+88h]
char *v62; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v63; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v64; // [xsp+B8h] [xbp+B8h]
std::string v65; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v66; // [xsp+C8h] [xbp+C8h] BYREF
const char *v67; // [xsp+D0h] [xbp+D0h] BYREF
const char *v68; // [xsp+D8h] [xbp+D8h] BYREF
cocos2d::extension::CCHttpClient *v69; // [xsp+E0h] [xbp+E0h] BYREF
std::string v70; // 0:x2.8
isDLActive = GameLevelManager::isDLActive(a1, "rew_state");
result = 0;
if ( !isDLActive )
{
GameLevelManager::addDLToActive(a1, "rew_state");
GameLevelManager::getBasePostString(a1, (__int64)&v62);
v4 = GameStatsManager::sharedState();
v5 = cocos2d::CCDictionary::allKeys(v4->m_dailyChests);
v6 = cocos2d::CCArray::count(v5);
if ( v6 > 0 )
{
v7 = 0;
v60 = 0;
v8 = 0;
while ( 1 )
{
while ( 1 )
{
v9 = cocos2d::CCArray::stringAtIndex(v5, v7);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v67, CString);
v11 = v67;
v12 = (__int64 *)(v67 - 24);
if ( *((_QWORD *)v67 - 3) > 2u )
break;
if ( v12 != &qword_124B6B0 )
goto LABEL_13;
LABEL_5:
if ( v6 == ++v7 )
goto LABEL_18;
}
sub_D14F84(&v68, &v67, 0, 1);
v13 = *((_QWORD *)v67 - 3);
if ( v13 <= 1 )
sub_D13C5C(
"%s: __pos (which is %zu) > this->size() (which is %zu)",
"basic_string::substr",
2u,
*((_QWORD *)v67 - 3));
sub_D14F84(&v69, &v67, 2, v13 - 2);
v14 = v68;
v15 = atoi(v68);
v16 = v69;
if ( v15 == 1 )
{
v36 = atoi((const char *)v69);
if ( v8 < v36 )
v8 = v36;
p_m_unknown2 = &v16[-1].m_unknown2;
if ( &v16[-1].m_unknown2 == (int *)&qword_124B6B0 )
{
LABEL_11:
v18 = (char *)(v14 - 24);
if ( v14 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_12;
LABEL_36:
if ( &pthread_create )
{
v39 = (unsigned int *)(v14 - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v14 - 2);
*((_DWORD *)v14 - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v18);
goto LABEL_12;
}
}
else
{
if ( v15 == 2 )
{
v41 = atoi((const char *)v69);
if ( v60 >= v41 )
v41 = v60;
v60 = v41;
}
p_m_unknown2 = &v16[-1].m_unknown2;
if ( &v16[-1].m_unknown2 == (int *)&qword_124B6B0 )
goto LABEL_11;
}
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v16[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v16[-1]._timeoutForConnect;
v16[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
v14 = v68;
v18 = (char *)(v68 - 24);
if ( v68 - 24 != (const char *)&qword_124B6B0 )
goto LABEL_36;
LABEL_12:
v11 = v67;
v12 = (__int64 *)(v67 - 24);
if ( v67 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_5;
LABEL_13:
if ( &pthread_create )
{
v19 = (unsigned int *)(v11 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 - 2) = v20 - 1;
}
if ( v20 > 0 )
goto LABEL_5;
++v7;
operator delete(v12);
if ( v6 == v7 )
goto LABEL_18;
}
}
v60 = 0;
v8 = 0;
LABEL_18:
v21 = GameManager::sharedState();
v22 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v21->m_chk.random - v21->m_chk.seed));
v23 = (char *)cocos2d::CCString::getCString(v22);
sub_D153B8((int)&v63, v23);
sub_D153B8((int)&v65, "59182");
cocos2d::ZipUtils::base64EncodeEnc((cocos2d::ZipUtils *)&v63, &v65, v70);
v24 = (char *)v65.m_data.m_data - 24;
if ( (__int64 *)v65.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v44 = (unsigned int *)((char *)v65.m_data.m_data - 8);
do
v45 = __ldaxr(v44);
while ( __stlxr(v45 - 1, v44) );
}
else
{
v45 = *((_DWORD *)v65.m_data.m_data - 2);
*((_DWORD *)v65.m_data.m_data - 2) = v45 - 1;
}
if ( v45 <= 0 )
operator delete(v24);
}
v25 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
v26 = cocos2d::CCString::getCString(v25);
gen_random(5, (__int64)&v66);
v27 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&rewardType=%i&secret=%s&chk=%s%s&r1=%i&r2=%i",
(const char *)(unsigned int)a2,
v26,
v66,
v64,
(unsigned int)v8,
(unsigned int)v60);
v61 = cocos2d::CCString::getCString(v27);
v28 = strlen(v61);
sub_D15FD4(&v62, v61, v28);
v29 = (void *)(v66 - 24);
if ( (__int64 *)(v66 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v48 = (unsigned int *)(v66 - 8);
do
v49 = __ldaxr(v48);
while ( __stlxr(v49 - 1, v48) );
}
else
{
v49 = *(_DWORD *)(v66 - 8);
*(_DWORD *)(v66 - 8) = v49 - 1;
}
if ( v49 <= 0 )
operator delete(v29);
}
sub_D153B8((int)&v67, "https://www.boomlings.com/database/getGJRewards.php");
sub_D153B8((int)&v68, v62);
sub_D153B8((int)&v69, "rew_state");
GameLevelManager::ProcessHttpRequest(a1, &v67, &v68, &v69, 46);
v30 = &v69[-1].m_unknown2;
if ( &v69[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v52 = (unsigned int *)&v69[-1]._timeoutForConnect;
do
v53 = __ldaxr(v52);
while ( __stlxr(v53 - 1, v52) );
}
else
{
v53 = v69[-1]._timeoutForConnect;
v69[-1]._timeoutForConnect = v53 - 1;
}
if ( v53 <= 0 )
operator delete(v30);
}
v31 = (char *)(v68 - 24);
if ( v68 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v46 = (unsigned int *)(v68 - 8);
do
v47 = __ldaxr(v46);
while ( __stlxr(v47 - 1, v46) );
}
else
{
v47 = *((_DWORD *)v68 - 2);
*((_DWORD *)v68 - 2) = v47 - 1;
}
if ( v47 <= 0 )
operator delete(v31);
}
v32 = (char *)(v67 - 24);
if ( v67 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v54 = (unsigned int *)(v67 - 8);
do
v55 = __ldaxr(v54);
while ( __stlxr(v55 - 1, v54) );
}
else
{
v55 = *((_DWORD *)v67 - 2);
*((_DWORD *)v67 - 2) = v55 - 1;
}
if ( v55 <= 0 )
operator delete(v32);
}
v33 = (void *)(v64 - 24);
if ( (__int64 *)(v64 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v50 = (unsigned int *)(v64 - 8);
do
v51 = __ldaxr(v50);
while ( __stlxr(v51 - 1, v50) );
}
else
{
v51 = *(_DWORD *)(v64 - 8);
*(_DWORD *)(v64 - 8) = v51 - 1;
}
if ( v51 <= 0 )
operator delete(v33);
}
v34 = (void *)(v63 - 24);
if ( (__int64 *)(v63 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v56 = (unsigned int *)(v63 - 8);
do
v57 = __ldaxr(v56);
while ( __stlxr(v57 - 1, v56) );
}
else
{
v57 = *(_DWORD *)(v63 - 8);
*(_DWORD *)(v63 - 8) = v57 - 1;
}
if ( v57 <= 0 )
operator delete(v34);
}
v35 = v62 - 24;
if ( v62 - 24 == (char *)&qword_124B6B0 )
return 1;
if ( &pthread_create )
{
v42 = (unsigned int *)(v62 - 8);
do
v43 = __ldaxr(v42);
while ( __stlxr(v43 - 1, v42) );
}
else
{
v43 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v43 - 1;
}
if ( v43 > 0 )
{
return 1;
}
else
{
operator delete(v35);
return 1;
}
}
return result;
}