//
// GameLevelManager::getGJRewards from 0x3d3d68 to 0x3d3fa8 (576 bytes)
//
// 3 xrefs:
// > RewardsPage::tryGetRewards @ 0x4e6842
// > RewardsPage::init @ 0x4e7766
// > RewardsPage::onReward @ 0x4e9112
//
// 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)
{
GameStatsManager *v2; // r0
cocos2d::CCArray *v3; // r10
signed int v4; // r6
signed int v5; // r8
int v6; // r9
cocos2d::CCString *v7; // r0
char *CString; // r0
int v9; // r0
int v10; // r0
int v11; // r0
int v12; // r3
GameManager *v13; // r0
cocos2d::CCString *v14; // r0
char *v15; // r0
cocos2d::CCString *v16; // r0
cocos2d::CCString *v17; // r0
char *v18; // r0
int v20; // [sp+14h] [bp-40h]
const char *v22; // [sp+1Ch] [bp-38h]
char *v24; // [sp+2Ch] [bp-28h] BYREF
std::string v25; // [sp+30h] [bp-24h] BYREF
int v26; // [sp+34h] [bp-20h] BYREF
_BYTE v27[4]; // [sp+38h] [bp-1Ch] BYREF
int v28; // [sp+3Ch] [bp-18h] BYREF
char *v29; // [sp+40h] [bp-14h] BYREF
char *v30; // [sp+44h] [bp-10h] BYREF
char *v31; // [sp+48h] [bp-Ch] BYREF
if ( GameLevelManager::isDLActive(a1, "rew_state") )
return 0;
GameLevelManager::addDLToActive(a1, "rew_state");
GameLevelManager::getBasePostString((GameLevelManager *)&v24);
v2 = GameStatsManager::sharedState();
v3 = cocos2d::CCDictionary::allKeys(v2->m_dailyChests);
v4 = 0;
v5 = cocos2d::CCArray::count(v3);
v6 = 0;
v20 = 0;
while ( v4 < v5 )
{
v7 = cocos2d::CCArray::stringAtIndex(v3, v4);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_776584((int)&v29, CString);
if ( *((_DWORD *)v29 - 3) > 2u )
{
sub_776158(&v30, &v29, 0, 1);
sub_776158(&v31, &v29, 2, *((_DWORD *)v29 - 3) - 2);
v9 = atoi(v30);
if ( v9 == 1 )
{
v10 = atoi(v31);
if ( v6 < v10 )
v6 = v10;
}
else if ( v9 == 2 )
{
v11 = atoi(v31);
v12 = v20;
if ( v20 < v11 )
v12 = v11;
v20 = v12;
}
sub_774008(&v31);
sub_774008(&v30);
}
++v4;
sub_774008(&v29);
}
v13 = GameManager::sharedState();
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(v13->m_chk.random - v13->m_chk.seed));
v15 = (char *)cocos2d::CCString::getCString(v14);
sub_776584((int)&v25, v15);
sub_776584((int)v27, "59182");
cocos2d::ZipUtils::base64EncodeEnc((cocos2d::ZipUtils *)&v26, &v25, (std::string)v27);
sub_774008(v27);
v16 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_54 + 3,
"mfd",
"2893",
103,
98,
&aO1i2r3e45s7t89[10]);
v22 = cocos2d::CCString::getCString(v16);
gen_random((int)&v28, 5);
v17 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&rewardType=%i&secret=%s&chk=%s%s&r1=%i&r2=%i",
(const char *)a2,
v22,
v28,
v26,
v6,
v20);
v18 = (char *)cocos2d::CCString::getCString(v17);
sub_774544((int)&v24, v18);
sub_774008(&v28);
sub_776584((int)&v29, "https://www.boomlings.com/database/getGJRewards.php");
sub_776584((int)&v30, v24);
sub_776584((int)&v31, "rew_state");
GameLevelManager::ProcessHttpRequest(a1, &v29, (const char **)&v30, &v31, 46);
sub_774008(&v31);
sub_774008(&v30);
sub_774008(&v29);
sub_774008(&v26);
sub_774008(&v25);
sub_774008(&v24);
return 1;
}