//
// GameLevelManager::onGetGJRewardsCompleted from 0x6fd2a8 to 0x6fdda0 (2808 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x732034
// > ??> @ 0x97878
//
// 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::onGetGJRewardsCompleted(GameLevelManager *a1, const void **a2)
{
_DWORD *v4; // x26
unsigned __int64 v5; // x27
unsigned __int64 v6; // x20
size_t v7; // x2
int v8; // w24
__int64 v9; // x20
__int64 *v10; // x0
GJRewardDelegate *v11; // x0
cocos2d::CCArray *v13; // x24
cocos2d::CCString *v14; // x0
char *CString; // x0
cocos2d::CCString *v16; // x0
char *v17; // x0
unsigned __int64 v18; // x3
void *v19; // x0
double v20; // d0
cocos2d::CCString *v21; // x0
size_t v22; // x0
char *v23; // x26
unsigned int v24; // w0
unsigned __int8 *v25; // x3
char *v26; // x2
size_t v27; // x28
size_t v28; // x4
size_t v29; // x2
int v30; // w26
__int64 v31; // x28
char *v32; // x0
GJRewardDelegate *m_GJRewardDelegate; // x0
char *v34; // x0
char *v35; // x0
void *v36; // x0
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x26
int v40; // w1
unsigned int *v41; // x3
int v42; // w1
char *v43; // x0
cocos2d::CCArray *v44; // x27
GJRewardDelegate *v45; // x0
void *v46; // x0
unsigned int *v47; // x1
int v48; // w2
unsigned int *v49; // x1
int v50; // w2
unsigned int *v51; // x1
int v52; // w2
unsigned int *v53; // x1
int v54; // w2
cocos2d::CCString *v55; // x0
int v56; // w28
GameManager *v57; // x0
int v58; // w0
const char *v59; // x3
int v60; // w2
cocos2d::CCString *v61; // x0
int v62; // w28
GameManager *v63; // x0
cocos2d::CCString *v64; // x0
char *v65; // x0
GameManager *v66; // x0
const char *v67; // x2
GJRewardDelegate *v68; // x0
unsigned int *v69; // x1
int v70; // w2
cocos2d::CCString *v71; // x0
GJAccountManager *v72; // x0
cocos2d::CCString *v73; // x0
cocos2d::CCString *v74; // x0
char *v75; // x0
cocos2d::CCString *v76; // x0
cocos2d::CCString *v77; // x0
cocos2d::CCString *v78; // x0
char *v79; // x0
cocos2d::CCString *v80; // x0
cocos2d::CCString *v81; // x0
GameStatsManager *v82; // x27
GameStatsManager *v83; // x27
GJRewardDelegate *v84; // x0
__int64 v85; // [xsp+0h] [xbp+0h] BYREF
__int64 *v86; // [xsp+68h] [xbp+68h]
unsigned int v87; // [xsp+74h] [xbp+74h]
int v88; // [xsp+78h] [xbp+78h]
int v89; // [xsp+7Ch] [xbp+7Ch]
size_t v90; // [xsp+80h] [xbp+80h]
const char *v91; // [xsp+88h] [xbp+88h]
__int64 v92; // [xsp+98h] [xbp+98h] BYREF
void *v93; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v94; // [xsp+A8h] [xbp+A8h] BYREF
char *v95; // [xsp+B0h] [xbp+B0h] BYREF
void *v96; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v97; // [xsp+C0h] [xbp+C0h] BYREF
std::string v98; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v99; // [xsp+D0h] [xbp+D0h] BYREF
__int64 v100; // [xsp+D8h] [xbp+D8h] BYREF
__int64 v101; // [xsp+E0h] [xbp+E0h] BYREF
__int64 v102; // [xsp+E8h] [xbp+E8h] BYREF
__int64 v103; // [xsp+F0h] [xbp+F0h] BYREF
void *v104; // [xsp+F8h] [xbp+F8h] BYREF
unsigned __int8 v105[24]; // [xsp+100h] [xbp+100h] BYREF
unsigned __int8 v106[48]; // [xsp+118h] [xbp+118h] BYREF
std::string v107; // 0:x2.8
GameLevelManager::removeDLFromActive(a1, "rew_state");
sub_D153B8((int)&v104, "-1");
v4 = v104;
v5 = *((_QWORD *)v104 - 3);
v6 = *((_QWORD *)*a2 - 3);
if ( v5 > v6 )
v7 = *((_QWORD *)*a2 - 3);
else
v7 = *((_QWORD *)v104 - 3);
v8 = memcmp(*a2, v104, v7);
if ( v8 || (v8 = 0x7FFFFFFF, v9 = v6 - v5, v9 > 0x7FFFFFFF) )
{
v10 = (__int64 *)(v4 - 6);
if ( v4 - 6 == (_DWORD *)&qword_124B6B0 )
goto LABEL_7;
}
else
{
v10 = (__int64 *)(v4 - 6);
if ( v9 >= (__int64)0xFFFFFFFF80000000LL )
v8 = v9;
else
v8 = 0x80000000;
if ( v10 == &qword_124B6B0 )
goto LABEL_7;
}
if ( &pthread_create )
{
v39 = v4 - 2;
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *(v4 - 2);
*(v4 - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v10);
LABEL_7:
if ( v8 )
{
v13 = sub_6F004C(a2, "|");
if ( (unsigned int)cocos2d::CCArray::count(v13) > 1 )
{
v14 = cocos2d::CCArray::stringAtIndex(v13, 0);
CString = (char *)cocos2d::CCString::getCString(v14);
sub_D153B8((unsigned int)&v85 + 152, CString);
v16 = cocos2d::CCArray::stringAtIndex(v13, 1u);
v17 = (char *)cocos2d::CCString::getCString(v16);
sub_D153B8((int)&v93, v17);
v18 = *(_QWORD *)(v92 - 24);
if ( v18 <= 4 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", 5u, v18);
sub_D14F84(&v94, &v92, 5, -1);
sub_D163D4(&v92, &v94);
v19 = (void *)(v94 - 24);
if ( (__int64 *)(v94 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v94 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(v94 - 8);
*(_DWORD *)(v94 - 8) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v19);
}
*(_QWORD *)&v20 = sub_D18D28(&v95, &v92).n128_u64[0];
v21 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&qword_70,
"C26",
"fpYa",
81,
67,
"tg",
v20);
v91 = cocos2d::CCString::getCString(v21);
v22 = strlen(v91);
sub_D15FD4(&v95, v91, v22);
v23 = v95;
v24 = strlen(v95);
rtsha1::calc((rtsha1 *)v23, (const void *)v24, (__int64)v105, v25);
rtsha1::toHexString((rtsha1 *)v105, v106, v26);
sub_D153B8((int)&v96, (char *)v106);
v91 = (const char *)v96;
v27 = *((_QWORD *)v96 - 3);
v28 = *((_QWORD *)v93 - 3);
v90 = v28;
if ( v28 > v27 )
v29 = v27;
else
v29 = v28;
v30 = memcmp(v96, v93, v29);
if ( !v30 )
{
v30 = 0x7FFFFFFF;
v31 = v27 - v90;
if ( v31 <= 0x7FFFFFFF )
{
if ( v31 >= (__int64)0xFFFFFFFF80000000LL )
v30 = v31;
else
v30 = 0x80000000;
}
}
v32 = (char *)(v91 - 24);
if ( v91 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v91 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *((_DWORD *)v91 - 2);
*((_DWORD *)v91 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v32);
}
if ( v30 )
{
m_GJRewardDelegate = a1->m_GJRewardDelegate;
if ( m_GJRewardDelegate )
m_GJRewardDelegate->rewardsStatusFailed(m_GJRewardDelegate);
LABEL_28:
v34 = v95 - 24;
if ( v95 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(v95 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *((_DWORD *)v95 - 2);
*((_DWORD *)v95 - 2) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v34);
}
v35 = (char *)v93 - 24;
if ( (char *)v93 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v49 = (unsigned int *)((char *)v93 - 8);
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *((_DWORD *)v93 - 2);
*((_DWORD *)v93 - 2) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v35);
}
v36 = (void *)(v92 - 24);
if ( (__int64 *)(v92 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)(v92 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *(_DWORD *)(v92 - 8);
*(_DWORD *)(v92 - 8) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v36);
}
return _stack_chk_guard;
}
sub_D153B8((int)&v98, "59182");
cocos2d::ZipUtils::base64DecodeEnc((cocos2d::ZipUtils *)&v92, &v98, v107);
v43 = (char *)v98.m_data.m_data - 24;
if ( (__int64 *)v98.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v69 = (unsigned int *)((char *)v98.m_data.m_data - 8);
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *((_DWORD *)v98.m_data.m_data - 2);
*((_DWORD *)v98.m_data.m_data - 2) = v70 - 1;
}
if ( v70 <= 0 )
operator delete(v43);
}
v44 = sub_6F004C(&v97, ":");
if ( (unsigned int)cocos2d::CCArray::count(v44) <= 0xB )
goto LABEL_51;
v55 = cocos2d::CCArray::stringAtIndex(v44, 1u);
v56 = cocos2d::CCString::intValue(v55);
if ( v56 <= 0 )
goto LABEL_51;
v57 = GameManager::sharedState();
v57->m_playerUserID.value = v56;
v91 = (const char *)v57;
v58 = rand();
v59 = v91;
v60 = (int)(float)((float)((float)v58 * 4.6566e-10) * 1000.0);
*((_DWORD *)v91 + 140) = v60;
*((_DWORD *)v59 + 139) = v56 + v60;
v61 = cocos2d::CCArray::stringAtIndex(v44, 2u);
v62 = cocos2d::CCString::intValue(v61);
v63 = GameManager::sharedState();
if ( v62 == v63->m_chk.random - v63->m_chk.seed )
{
v64 = cocos2d::CCArray::stringAtIndex(v44, 3u);
v65 = (char *)cocos2d::CCString::getCString(v64);
v91 = (const char *)&v99;
sub_D153B8((int)&v99, v65);
v66 = GameManager::sharedState();
sub_D18D28(&v100, &v66->m_playerUDID);
v67 = (const char *)(unsigned int)sub_D17014(v91, &v100);
if ( (__int64 *)(v100 - 24) != &qword_124B6B0 )
{
v91 = v67;
sub_6EE220((void *)(v100 - 24));
LODWORD(v67) = (_DWORD)v91;
}
if ( !(_DWORD)v67 )
{
v71 = cocos2d::CCArray::stringAtIndex(v44, 4u);
LODWORD(v91) = cocos2d::CCString::intValue(v71);
v72 = GJAccountManager::sharedState();
if ( (_DWORD)v91 == v72->m_accountID - v72->m_unkInt1 )
{
v73 = cocos2d::CCArray::stringAtIndex(v44, 5u);
LODWORD(v91) = cocos2d::CCString::intValue(v73);
v74 = cocos2d::CCArray::stringAtIndex(v44, 6u);
v75 = (char *)cocos2d::CCString::getCString(v74);
v86 = &v101;
sub_D153B8((int)&v101, v75);
v76 = cocos2d::CCArray::stringAtIndex(v44, 7u);
LODWORD(v90) = cocos2d::CCString::intValue(v76);
v77 = cocos2d::CCArray::stringAtIndex(v44, 8u);
v89 = cocos2d::CCString::intValue(v77);
v78 = cocos2d::CCArray::stringAtIndex(v44, 9u);
v79 = (char *)cocos2d::CCString::getCString(v78);
sub_D153B8((int)&v102, v79);
v80 = cocos2d::CCArray::stringAtIndex(v44, 0xAu);
v88 = cocos2d::CCString::intValue(v80);
v81 = cocos2d::CCArray::stringAtIndex(v44, 0xBu);
v87 = cocos2d::CCString::intValue(v81);
v82 = GameStatsManager::sharedState();
sub_D18D28(&v103, v86);
GameStatsManager::storeRewardState(v82, Small, v90, (int)v91, (std::string)&v103);
if ( (__int64 *)(v103 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v103 - 24));
v83 = GameStatsManager::sharedState();
sub_D18D28(&v104, &v102);
GameStatsManager::storeRewardState(v83, Large, v88, v89, (std::string)&v104);
if ( (char *)v104 - 24 != (char *)&qword_124B6B0 )
sub_6EE220((char *)v104 - 24);
v84 = a1->m_GJRewardDelegate;
if ( v84 )
v84->rewardsStatusFinished(v84, v87);
if ( (__int64 *)(v102 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v102 - 24));
if ( (__int64 *)(v101 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v101 - 24));
if ( (__int64 *)(v99 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v99 - 24));
if ( (__int64 *)(v97 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v97 - 24));
if ( v95 - 24 != (char *)&qword_124B6B0 )
sub_6EE220(v95 - 24);
if ( (char *)v93 - 24 != (char *)&qword_124B6B0 )
sub_6EE220((char *)v93 - 24);
if ( (__int64 *)(v92 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v92 - 24));
return _stack_chk_guard;
}
}
v68 = a1->m_GJRewardDelegate;
if ( v68 )
v68->rewardsStatusFailed(v68);
if ( (__int64 *)(v99 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v99 - 24));
}
else
{
LABEL_51:
v45 = a1->m_GJRewardDelegate;
if ( v45 )
v45->rewardsStatusFailed(v45);
}
v46 = (void *)(v97 - 24);
if ( (__int64 *)(v97 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v47 = (unsigned int *)(v97 - 8);
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *(_DWORD *)(v97 - 8);
*(_DWORD *)(v97 - 8) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v46);
}
goto LABEL_28;
}
}
v11 = a1->m_GJRewardDelegate;
if ( v11 )
v11->rewardsStatusFailed(v11);
return _stack_chk_guard;
}