//
// GameLevelManager::getGJRewards from 0x1000aad70 to 0x1000ab164 (1012 bytes)
//
// 3 xrefs:
// > RewardsPage::init @ 0x1001c440c
// > RewardsPage::onReward @ 0x1001c4628
// > RewardsPage::tryGetRewards @ 0x1001c4cf0
//
// 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 __fastcall GameLevelManager::getGJRewards(GameLevelManager *a1, int a2)
{
bool isDLActive; // w19
GameStatsManager *v5; // x0
cocos2d::CCArray *v6; // x24
int v7; // w25
unsigned int v8; // w26
int v9; // w23
int v10; // w22
cocos2d::CCString *v11; // x0
char *CString; // x0
std::string::size_type size; // x9
char v14; // w8
std::string::size_type v15; // x8
char v16; // w28
std::string *v17; // x27
std::string *v18; // x0
int v19; // w21
std::string *v20; // x27
int v21; // w0
std::string *p_a; // x27
GameManager *v23; // x0
cocos2d::CCString *v24; // x0
char *v25; // x0
cocos2d::CCString *v26; // x0
const char *v27; // x24
std::string *v28; // x8
std::string *v29; // x9
cocos2d::CCString *v30; // x0
const char *v31; // x0
std::string *v32; // x1
int v34; // [xsp+38h] [xbp-128h]
void *v35[2]; // [xsp+40h] [xbp-120h] BYREF
char v36; // [xsp+57h] [xbp-109h]
void *v37[2]; // [xsp+58h] [xbp-108h] BYREF
char v38; // [xsp+6Fh] [xbp-F1h]
std::string v39; // [xsp+70h] [xbp-F0h] BYREF
void *__p[2]; // [xsp+88h] [xbp-D8h] BYREF
char v41; // [xsp+9Fh] [xbp-C1h]
std::string __a; // [xsp+A0h] [xbp-C0h] BYREF
std::string v43; // [xsp+B8h] [xbp-A8h] BYREF
std::string __str; // [xsp+D0h] [xbp-90h] BYREF
std::string v45; // [xsp+E8h] [xbp-78h] BYREF
std::allocator v46; // [xsp+107h] [xbp-59h] BYREF
isDLActive = GameLevelManager::isDLActive(a1, "rew_state");
if ( !isDLActive )
{
GameLevelManager::addDLToActive(a1, "rew_state");
GameLevelManager::getBasePostString(&v45);
v5 = GameStatsManager::sharedState();
v6 = cocos2d::CCDictionary::allKeys(v5->m_dailyChests);
v7 = sub_10024A36C(v6);
v34 = a2;
if ( v7 >= 1 )
{
v8 = 0;
v9 = 0;
v10 = 0;
while ( 1 )
{
v11 = cocos2d::CCArray::stringAtIndex(v6, v8);
CString = (char *)cocos2d::CCString::getCString(v11);
sub_100009900(&__str, CString);
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
v14 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = __str.__r_.__value_.__l.__size_;
if ( size < 3 )
goto LABEL_25;
std::string::basic_string(&v43, &__str, 0, 1u, (std::allocator *)&__a);
v15 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v15 = __str.__r_.__value_.__l.__size_;
std::string::basic_string(&__a, &__str, 2u, v15 - 2, &v46);
v16 = HIBYTE(v43.__r_.__value_.__r.__words[2]);
if ( SHIBYTE(v43.__r_.__value_.__r.__words[2]) < 0 )
{
v17 = (std::string *)v43.__r_.__value_.__r.__words[0];
v18 = (std::string *)v43.__r_.__value_.__r.__words[0];
}
else
{
v17 = &v43;
v18 = &v43;
}
if ( atoi((const char *)v18) == 1 )
break;
v21 = atoi((const char *)v17);
v19 = SHIBYTE(__a.__r_.__value_.__r.__words[2]);
if ( v21 != 2 )
goto LABEL_22;
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
{
p_a = (std::string *)__a.__r_.__value_.__r.__words[0];
if ( v9 >= atoi(__a.__r_.__value_.__l.__data_) )
goto LABEL_31;
}
else
{
p_a = &__a;
if ( v9 >= atoi((const char *)&__a) )
goto LABEL_23;
}
v9 = atoi((const char *)p_a);
if ( (v19 & 0x80000000) == 0 )
{
LABEL_23:
if ( v16 < 0 )
goto LABEL_32;
goto LABEL_24;
}
LABEL_31:
operator delete(__a.__r_.__value_.__l.__data_);
if ( (*((_BYTE *)&v43.__r_.__value_.__s + 23) & 0x80) != 0 )
LABEL_32:
operator delete(v43.__r_.__value_.__l.__data_);
LABEL_24:
v14 = HIBYTE(__str.__r_.__value_.__r.__words[2]);
LABEL_25:
if ( v14 < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( v7 == ++v8 )
goto LABEL_34;
}
v19 = SHIBYTE(__a.__r_.__value_.__r.__words[2]);
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
{
v20 = (std::string *)__a.__r_.__value_.__r.__words[0];
if ( v10 >= atoi(__a.__r_.__value_.__l.__data_) )
goto LABEL_31;
}
else
{
v20 = &__a;
if ( v10 >= atoi((const char *)&__a) )
goto LABEL_23;
}
v10 = atoi((const char *)v20);
LABEL_22:
if ( (v19 & 0x80000000) == 0 )
goto LABEL_23;
goto LABEL_31;
}
v10 = 0;
v9 = 0;
LABEL_34:
v23 = GameManager::sharedState();
v24 = (cocos2d::CCString *)sub_100268F4C("%i", v23->m_chk.random - v23->m_chk.seed);
v25 = (char *)cocos2d::CCString::getCString(v24);
sub_100009900(&__str, v25);
sub_100009900(__p, "59182");
cocos2d::ZipUtils::base64EncodeEnc(&v43, &__str, __p);
if ( v41 < 0 )
operator delete(__p[0]);
v26 = (cocos2d::CCString *)sub_100268F4C("%c%s%s%c%c%s", 87, "mfd", "2893", 103, 98, "7");
v27 = cocos2d::CCString::getCString(v26);
sub_100087A84(5, &__a);
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v28 = &__a;
else
v28 = (std::string *)__a.__r_.__value_.__r.__words[0];
v29 = &v43;
if ( (v43.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v29 = (std::string *)v43.__r_.__value_.__r.__words[0];
v30 = (cocos2d::CCString *)sub_100268F4C(
"&rewardType=%i&secret=%s&chk=%s%s&r1=%i&r2=%i",
v34,
v27,
(const char *)v28,
(const char *)v29,
v10,
v9);
v31 = cocos2d::CCString::getCString(v30);
std::string::append(&v45, v31);
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__a.__r_.__value_.__l.__data_);
sub_100009900(&v39, "https://www.boomlings.com/database/getGJRewards.php");
if ( (v45.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v32 = &v45;
else
v32 = (std::string *)v45.__r_.__value_.__r.__words[0];
sub_100009900(v37, (char *)v32);
sub_100009900(v35, "rew_state");
GameLevelManager::ProcessHttpRequest(a1, &v39, (char *)v37, (const std::string::value_type *)v35, 46);
if ( v36 < 0 )
operator delete(v35[0]);
if ( v38 < 0 )
operator delete(v37[0]);
if ( SHIBYTE(v39.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v39.__r_.__value_.__l.__data_);
if ( SHIBYTE(v43.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v43.__r_.__value_.__l.__data_);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
if ( SHIBYTE(v45.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v45.__r_.__value_.__l.__data_);
}
return !isDLActive;
}