//
// GameLevelManager::getGJSecretReward from 0x729774 to 0x729d50 (1500 bytes)
//
// 2 xrefs:
// > SecretLayer5::onSubmit @ 0xa95718
// > ??> @ 0x7e5b8
//
// 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
//
__int64 __fastcall GameLevelManager::getGJSecretReward(GameLevelManager *a1, const char **a2)
{
_BOOL4 isDLActive; // w1
__int64 result; // x0
GameManager *v6; // x0
cocos2d::CCString *v7; // x0
char *CString; // x0
char *v9; // x0
const char *v10; // x28
cocos2d::CCString *v11; // x0
cocos2d::CCString *v12; // x0
size_t v13; // x0
void *v14; // x0
int *p_m_unknown2; // x0
char *v16; // x0
char *v17; // x0
void *v18; // x0
void *v19; // x0
char *v20; // x0
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 *v29; // x1
int v30; // w2
unsigned int *p_timeoutForConnect; // x1
int timeoutForConnect; // w2
unsigned int *v33; // x1
int v34; // w2
unsigned int *v35; // x1
int v36; // w2
const char *v37; // [xsp+68h] [xbp+68h]
const char *v38; // [xsp+68h] [xbp+68h]
char *v39; // [xsp+88h] [xbp+88h] BYREF
__int64 v40; // [xsp+90h] [xbp+90h] BYREF
__int64 v41; // [xsp+98h] [xbp+98h]
std::string v42; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v43; // [xsp+A8h] [xbp+A8h] BYREF
const char *v44; // [xsp+B0h] [xbp+B0h] BYREF
const char *v45; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::extension::CCHttpClient *v46; // [xsp+C0h] [xbp+C0h] BYREF
std::string v47; // 0:x2.8
isDLActive = GameLevelManager::isDLActive(a1, "get_sreward");
result = 0;
if ( !isDLActive )
{
GameLevelManager::addDLToActive(a1, "get_sreward");
GameLevelManager::getBasePostString(a1, (__int64)&v39);
v6 = GameManager::sharedState();
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)(unsigned int)(v6->m_chk.random - v6->m_chk.seed));
CString = (char *)cocos2d::CCString::getCString(v7);
sub_D153B8((int)&v40, CString);
sub_D153B8((int)&v42, "59182");
cocos2d::ZipUtils::base64EncodeEnc((cocos2d::ZipUtils *)&v40, &v42, v47);
v9 = (char *)v42.m_data.m_data - 24;
if ( (__int64 *)v42.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)((char *)v42.m_data.m_data - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v42.m_data.m_data - 2);
*((_DWORD *)v42.m_data.m_data - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v9);
}
v10 = *a2;
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)off_50 + 7,
"mfd",
"2893",
103,
98,
"7");
v37 = cocos2d::CCString::getCString(v11);
gen_random(5, (__int64)&v43);
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"&rewardKey=%s&secret=%s&chk=%s%s",
v10,
v37,
v43,
v41);
v38 = cocos2d::CCString::getCString(v12);
v13 = strlen(v38);
sub_D15FD4(&v39, v38, v13);
v14 = (void *)(v43 - 24);
if ( (__int64 *)(v43 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v43 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v43 - 8);
*(_DWORD *)(v43 - 8) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v14);
}
sub_D153B8((int)&v44, "https://www.boomlings.com/database/getGJSecretReward.php");
sub_D153B8((int)&v45, v39);
sub_D153B8((int)&v46, "get_sreward");
GameLevelManager::ProcessHttpRequest(a1, &v44, &v45, &v46, 64);
p_m_unknown2 = &v46[-1].m_unknown2;
if ( &v46[-1].m_unknown2 != (int *)&qword_124B6B0 )
{
if ( &pthread_create )
{
p_timeoutForConnect = (unsigned int *)&v46[-1]._timeoutForConnect;
do
timeoutForConnect = __ldaxr(p_timeoutForConnect);
while ( __stlxr(timeoutForConnect - 1, p_timeoutForConnect) );
}
else
{
timeoutForConnect = v46[-1]._timeoutForConnect;
v46[-1]._timeoutForConnect = timeoutForConnect - 1;
}
if ( timeoutForConnect <= 0 )
operator delete(p_m_unknown2);
}
v16 = (char *)(v45 - 24);
if ( v45 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(v45 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *((_DWORD *)v45 - 2);
*((_DWORD *)v45 - 2) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v16);
}
v17 = (char *)(v44 - 24);
if ( v44 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v44 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *((_DWORD *)v44 - 2);
*((_DWORD *)v44 - 2) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v17);
}
v18 = (void *)(v41 - 24);
if ( (__int64 *)(v41 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)(v41 - 8);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *(_DWORD *)(v41 - 8);
*(_DWORD *)(v41 - 8) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v18);
}
v19 = (void *)(v40 - 24);
if ( (__int64 *)(v40 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)(v40 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *(_DWORD *)(v40 - 8);
*(_DWORD *)(v40 - 8) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v19);
}
v20 = v39 - 24;
if ( v39 - 24 == (char *)&qword_124B6B0 )
return 1;
if ( &pthread_create )
{
v21 = (unsigned int *)(v39 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v39 - 2);
*((_DWORD *)v39 - 2) = v22 - 1;
}
if ( v22 > 0 )
{
return 1;
}
else
{
operator delete(v20);
return 1;
}
}
return result;
}