//
// GameLevelManager::onGetGJRewardsCompleted from 0x3c38ac to 0x3c3c6e (962 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x3d7520
//
// 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
//
int __fastcall GameLevelManager::onGetGJRewardsCompleted(GameLevelManager *a1, cocos2d::CCArray *a2)
{
_BOOL4 v4; // r7
cocos2d::CCArray *v5; // r6
int result; // r0
cocos2d::CCString *v7; // r0
char *CString; // r0
cocos2d::CCString *v9; // r0
char *v10; // r0
cocos2d::CCString *v11; // r0
char *v12; // r0
const void *v13; // r0
unsigned __int8 *v14; // r3
char *v15; // r2
_BOOL4 v16; // r9
GJRewardDelegate *v17; // r0
cocos2d::CCArray *v18; // r9
cocos2d::CCString *v19; // r0
int v20; // r10
GameManager *v21; // r0
cocos2d::CCString *v22; // r0
int v23; // r10
GameManager *v24; // r0
GJRewardDelegate *v25; // r0
cocos2d::CCString *v26; // r0
char *v27; // r0
GameManager *v28; // r0
cocos2d::CCString *v29; // r0
int v30; // r11
GJAccountManager *v31; // r0
GJRewardDelegate *v32; // r0
cocos2d::CCString *v33; // r0
cocos2d::CCString *v34; // r0
char *v35; // r0
cocos2d::CCString *v36; // r0
cocos2d::CCString *v37; // r0
cocos2d::CCString *v38; // r0
char *v39; // r0
cocos2d::CCString *v40; // r0
cocos2d::CCString *v41; // r0
GameStatsManager *v42; // r11
GameStatsManager *v43; // r11
GJRewardDelegate *m_GJRewardDelegate; // r0
_BOOL4 v45; // [sp+14h] [bp-4Ch]
int v46; // [sp+18h] [bp-48h]
int v47; // [sp+1Ch] [bp-44h]
int v48; // [sp+20h] [bp-40h]
int v49; // [sp+24h] [bp-3Ch]
int v50; // [sp+28h] [bp-38h]
std::string v51; // [sp+30h] [bp-30h] BYREF
char v52[4]; // [sp+34h] [bp-2Ch] BYREF
char v53[4]; // [sp+38h] [bp-28h] BYREF
char *v54; // [sp+3Ch] [bp-24h] BYREF
char v55[4]; // [sp+40h] [bp-20h] BYREF
cocos2d::CCArray v56; // [sp+44h] [bp-1Ch] BYREF
GameLevelManager::removeDLFromActive(a1, "rew_state");
sub_776584((int)&v56.m_uIndexInArray, "-1");
v4 = sub_3BE0D8((int)a2, (int)&v56.m_uIndexInArray);
sub_774008(&v56.m_uIndexInArray);
if ( !v4 )
{
v5 = sub_3BE530(a2, "|");
if ( cocos2d::CCArray::count(v5) > 1u )
{
v7 = cocos2d::CCArray::stringAtIndex(v5, 0);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_776584((int)&v51, CString);
v9 = cocos2d::CCArray::stringAtIndex(v5, 1u);
v10 = (char *)cocos2d::CCString::getCString(v9);
sub_776584((int)v52, v10);
sub_776158(v53, &v51, 5, -1);
sub_774794(&v51, v53);
sub_774008(v53);
sub_775C20(&v54, &v51);
v11 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_70,
"C26",
"fpYa",
81,
67,
"tg");
v12 = (char *)cocos2d::CCString::getCString(v11);
sub_774544((int)&v54, v12);
v13 = (const void *)strlen(v54);
rtsha1::calc((rtsha1 *)v54, v13, (int)&v56.m_uUnknown, v14);
rtsha1::toHexString((rtsha1 *)&v56.m_uUnknown, (const unsigned __int8 *)&v56.data, v15);
sub_776584((int)v55, (char *)&v56.data);
v16 = sub_3BE0D8((int)v55, (int)v52);
sub_774008(v55);
if ( v16 )
{
sub_776584((int)&v56.m_uID, "59182");
cocos2d::ZipUtils::base64DecodeEnc((cocos2d::ZipUtils *)&v56, &v51, (std::string)&v56.m_uID);
sub_774008(&v56.m_uID);
v18 = sub_3BE530(&v56, ":");
if ( cocos2d::CCArray::count(v18) > 0xBu
&& (v19 = cocos2d::CCArray::stringAtIndex(v18, 1u), v20 = cocos2d::CCString::intValue(v19), v20 > 0)
&& (v21 = GameManager::sharedState(),
GameManager::setPlayerUserID(v21, v20),
v22 = cocos2d::CCArray::stringAtIndex(v18, 2u),
v23 = cocos2d::CCString::intValue(v22),
v24 = GameManager::sharedState(),
v23 == v24->m_chk.random - v24->m_chk.seed) )
{
v26 = cocos2d::CCArray::stringAtIndex(v18, 3u);
v27 = (char *)cocos2d::CCString::getCString(v26);
sub_776584((int)&v56.m_nLuaID, v27);
v28 = GameManager::sharedState();
sub_775C20(&v56.m_nTag, &v28->m_playerUDID);
v45 = sub_3BE0D8((int)&v56.m_nLuaID, (int)&v56.m_nTag);
sub_774008(&v56.m_nTag);
if ( v45 )
{
v29 = cocos2d::CCArray::stringAtIndex(v18, 4u);
v30 = cocos2d::CCString::intValue(v29);
v31 = GJAccountManager::sharedState();
if ( v30 == v31->m_accountID - v31->m_unkInt1 )
{
v33 = cocos2d::CCArray::stringAtIndex(v18, 5u);
v46 = cocos2d::CCString::intValue(v33);
v34 = cocos2d::CCArray::stringAtIndex(v18, 6u);
v35 = (char *)cocos2d::CCString::getCString(v34);
sub_776584((int)&v56.m_uReference, v35);
v36 = cocos2d::CCArray::stringAtIndex(v18, 7u);
v47 = cocos2d::CCString::intValue(v36);
v37 = cocos2d::CCArray::stringAtIndex(v18, 8u);
v48 = cocos2d::CCString::intValue(v37);
v38 = cocos2d::CCArray::stringAtIndex(v18, 9u);
v39 = (char *)cocos2d::CCString::getCString(v38);
sub_776584((int)&v56.m_uAutoReleaseCount, v39);
v40 = cocos2d::CCArray::stringAtIndex(v18, 0xAu);
v49 = cocos2d::CCString::intValue(v40);
v41 = cocos2d::CCArray::stringAtIndex(v18, 0xBu);
v50 = cocos2d::CCString::intValue(v41);
v42 = GameStatsManager::sharedState();
sub_775C20(&v56.m_eObjType, &v56.m_uReference);
GameStatsManager::storeRewardState(v42, Small, v47, v46, (std::string)&v56.m_eObjType);
sub_774008(&v56.m_eObjType);
v43 = GameStatsManager::sharedState();
sub_775C20(&v56.m_uIndexInArray, &v56.m_uAutoReleaseCount);
GameStatsManager::storeRewardState(v43, Large, v49, v48, (std::string)&v56.m_uIndexInArray);
sub_774008(&v56.m_uIndexInArray);
m_GJRewardDelegate = a1->m_GJRewardDelegate;
if ( m_GJRewardDelegate )
m_GJRewardDelegate->rewardsStatusFinished(m_GJRewardDelegate, v50);
sub_774008(&v56.m_uAutoReleaseCount);
sub_774008(&v56.m_uReference);
sub_774008(&v56.m_nLuaID);
sub_774008(&v56);
sub_774008(&v54);
sub_774008(v52);
return sub_774008(&v51);
}
}
v32 = a1->m_GJRewardDelegate;
if ( v32 )
v32->rewardsStatusFailed(v32);
sub_774008(&v56.m_nLuaID);
}
else
{
v25 = a1->m_GJRewardDelegate;
if ( v25 )
v25->rewardsStatusFailed(v25);
}
sub_774008(&v56);
}
else
{
v17 = a1->m_GJRewardDelegate;
if ( v17 )
v17->rewardsStatusFailed(v17);
}
sub_774008(&v54);
sub_774008(v52);
return sub_774008(&v51);
}
}
result = (int)a1->m_GJRewardDelegate;
if ( result )
return (*(int (__fastcall **)(int))(*(_DWORD *)result + 4))(result);
return result;
}