//
// GameLevelManager::onGetGJChallengesCompleted from 0x6fdda8 to 0x6fe92c (2948 bytes)
//
// 2 xrefs:
// > GameLevelManager::handleIt @ 0x7323b4
// > ??> @ 0x63c30
//
// 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::onGetGJChallengesCompleted(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
GJChallengeDelegate *v11; // x0
cocos2d::CCArray *v13; // x24
cocos2d::CCString *v14; // x0
char *CString; // x0
cocos2d::CCString *v16; // x0
char *v17; // x0
GJChallengeDelegate *m_GJChallengeDelegate; // x0
char *v19; // x0
void *v20; // x0
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x26
int v24; // w1
void *v25; // x0
double v26; // d0
cocos2d::CCString *v27; // x0
size_t v28; // x0
char *v29; // x26
unsigned int v30; // w0
unsigned __int8 *v31; // x3
char *v32; // x2
size_t v33; // x28
GJChallengeItem *v34; // x4
size_t v35; // x2
int v36; // w26
__int64 v37; // x28
char *v38; // x0
GJChallengeDelegate *v39; // x0
char *v40; // x0
unsigned int *v41; // x1
int v42; // w2
unsigned int *v43; // x3
int v44; // w1
char *v45; // x0
cocos2d::CCArray *v46; // x27
void *m_GJRewardDelegate; // x0
void *v48; // x0
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
unsigned int *v64; // x1
int v65; // w2
cocos2d::CCString *v66; // x0
char *v67; // x0
GameManager *v68; // x0
int v69; // w28
GJRewardDelegate *v70; // x0
cocos2d::CCString *v71; // x0
int v72; // w28
GJAccountManager *v73; // x0
cocos2d::CCString *v74; // x0
cocos2d::CCString *v75; // x0
char *v76; // x0
cocos2d::CCString *v77; // x0
char *v78; // x0
cocos2d::CCString *v79; // x0
char *v80; // x0
int i; // w28
GameStatsManager *v82; // x0
GameStatsManager *v83; // x0
GameStatsManager *v84; // x0
__int64 *v85; // x1
GJChallengeItem *v86; // x27
GameStatsManager *v87; // x0
GameStatsManager *v88; // x0
GameStatsManager *v89; // x0
GJChallengeDelegate *v90; // x0
GameStatsManager *v91; // x0
__int64 v92; // [xsp+0h] [xbp+0h] BYREF
__int64 *v93; // [xsp+60h] [xbp+60h]
int v94; // [xsp+6Ch] [xbp+6Ch]
GJChallengeItem *SecondaryQueuedChallenge; // [xsp+70h] [xbp+70h]
GameStatsManager *QueuedChallenge; // [xsp+78h] [xbp+78h]
GJChallengeItem *Challenge; // [xsp+80h] [xbp+80h]
const char *v98; // [xsp+88h] [xbp+88h]
__int64 v99; // [xsp+98h] [xbp+98h] BYREF
void *v100; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v101; // [xsp+A8h] [xbp+A8h] BYREF
char *v102; // [xsp+B0h] [xbp+B0h] BYREF
void *v103; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v104; // [xsp+C0h] [xbp+C0h] BYREF
std::string v105; // [xsp+C8h] [xbp+C8h] BYREF
__int64 v106; // [xsp+D0h] [xbp+D0h] BYREF
__int64 v107; // [xsp+D8h] [xbp+D8h] BYREF
__int64 v108; // [xsp+E0h] [xbp+E0h] BYREF
__int64 v109; // [xsp+E8h] [xbp+E8h] BYREF
__int64 v110; // [xsp+F0h] [xbp+F0h] BYREF
void *v111; // [xsp+F8h] [xbp+F8h] BYREF
unsigned __int8 v112[24]; // [xsp+100h] [xbp+100h] BYREF
unsigned __int8 v113[48]; // [xsp+118h] [xbp+118h] BYREF
std::string v114; // 0:x1.8
std::string v115; // 0:x2.8
GameLevelManager::removeDLFromActive(a1, "get_chal");
sub_D153B8((int)&v111, "-1");
v4 = v111;
v5 = *((_QWORD *)v111 - 3);
v6 = *((_QWORD *)*a2 - 3);
if ( v5 > v6 )
v7 = *((_QWORD *)*a2 - 3);
else
v7 = *((_QWORD *)v111 - 3);
v8 = memcmp(*a2, v111, 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 )
{
v23 = v4 - 2;
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(v4 - 2);
*(v4 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v10);
LABEL_7:
if ( v8 && (v13 = sub_6F004C(a2, "|"), (unsigned int)cocos2d::CCArray::count(v13) > 1) )
{
v14 = cocos2d::CCArray::stringAtIndex(v13, 0);
CString = (char *)cocos2d::CCString::getCString(v14);
sub_D153B8((unsigned int)&v92 + 152, CString);
v16 = cocos2d::CCArray::stringAtIndex(v13, 1u);
v17 = (char *)cocos2d::CCString::getCString(v16);
sub_D153B8((int)&v100, v17);
if ( *(_QWORD *)(v99 - 24) <= 4u )
{
m_GJChallengeDelegate = a1->m_GJChallengeDelegate;
if ( m_GJChallengeDelegate )
m_GJChallengeDelegate->challengeStatusFailed(m_GJChallengeDelegate);
LABEL_20:
v19 = (char *)v100 - 24;
if ( (char *)v100 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)((char *)v100 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *((_DWORD *)v100 - 2);
*((_DWORD *)v100 - 2) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v19);
}
v20 = (void *)(v99 - 24);
if ( (__int64 *)(v99 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v99 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(v99 - 8);
*(_DWORD *)(v99 - 8) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v20);
}
return _stack_chk_guard;
}
sub_D14F84(&v101, &v99, 5, -1);
sub_D163D4(&v99, &v101);
v25 = (void *)(v101 - 24);
if ( (__int64 *)(v101 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v101 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(v101 - 8);
*(_DWORD *)(v101 - 8) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v25);
}
*(_QWORD *)&v26 = sub_D18D28(&v102, &v99).n128_u64[0];
v27 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&qword_68 + 7,
"C36",
"fpYa",
80,
116,
"dg",
v26);
v98 = cocos2d::CCString::getCString(v27);
v28 = strlen(v98);
sub_D15FD4(&v102, v98, v28);
v29 = v102;
v30 = strlen(v102);
rtsha1::calc((rtsha1 *)v29, (const void *)v30, (__int64)v112, v31);
rtsha1::toHexString((rtsha1 *)v112, v113, v32);
sub_D153B8((int)&v103, (char *)v113);
v98 = (const char *)v103;
v33 = *((_QWORD *)v103 - 3);
v34 = *((GJChallengeItem **)v100 - 3);
Challenge = v34;
if ( (unsigned __int64)v34 > v33 )
v35 = v33;
else
v35 = (size_t)v34;
v36 = memcmp(v103, v100, v35);
if ( !v36 )
{
v36 = 0x7FFFFFFF;
v37 = v33 - (_QWORD)Challenge;
if ( v37 <= 0x7FFFFFFF )
{
if ( v37 >= (__int64)0xFFFFFFFF80000000LL )
v36 = v37;
else
v36 = 0x80000000;
}
}
v38 = (char *)(v98 - 24);
if ( v98 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v98 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *((_DWORD *)v98 - 2);
*((_DWORD *)v98 - 2) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v38);
}
if ( v36 )
{
v39 = a1->m_GJChallengeDelegate;
if ( v39 )
v39->challengeStatusFailed(v39);
LABEL_45:
v40 = v102 - 24;
if ( v102 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v102 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *((_DWORD *)v102 - 2);
*((_DWORD *)v102 - 2) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v40);
}
goto LABEL_20;
}
sub_D153B8((int)&v105, "19847");
cocos2d::ZipUtils::base64DecodeEnc((cocos2d::ZipUtils *)&v99, &v105, v115);
v45 = (char *)v105.m_data.m_data - 24;
if ( (__int64 *)v105.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v64 = (unsigned int *)((char *)v105.m_data.m_data - 8);
do
v65 = __ldaxr(v64);
while ( __stlxr(v65 - 1, v64) );
}
else
{
v65 = *((_DWORD *)v105.m_data.m_data - 2);
*((_DWORD *)v105.m_data.m_data - 2) = v65 - 1;
}
if ( v65 <= 0 )
operator delete(v45);
}
v46 = sub_6F004C(&v104, ":");
if ( (unsigned int)cocos2d::CCArray::count(v46) <= 8 )
{
m_GJRewardDelegate = a1->m_GJChallengeDelegate;
if ( !m_GJRewardDelegate )
{
LABEL_61:
v48 = (void *)(v104 - 24);
if ( (__int64 *)(v104 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v49 = (unsigned int *)(v104 - 8);
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *(_DWORD *)(v104 - 8);
*(_DWORD *)(v104 - 8) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v48);
}
goto LABEL_45;
}
LABEL_60:
(*(void (__fastcall **)(void *))(*(_QWORD *)m_GJRewardDelegate + 8LL))(m_GJRewardDelegate);
goto LABEL_61;
}
v55 = cocos2d::CCArray::stringAtIndex(v46, 1u);
v56 = cocos2d::CCString::intValue(v55);
if ( v56 <= 0 )
goto LABEL_79;
v57 = GameManager::sharedState();
v57->m_playerUserID.value = v56;
v98 = (const char *)v57;
v58 = rand();
v59 = v98;
v60 = (int)(float)((float)((float)v58 * 4.6566e-10) * 1000.0);
*((_DWORD *)v98 + 140) = v60;
*((_DWORD *)v59 + 139) = v56 + v60;
v61 = cocos2d::CCArray::stringAtIndex(v46, 2u);
v62 = cocos2d::CCString::intValue(v61);
v63 = GameManager::sharedState();
if ( v62 != v63->m_chk.random - v63->m_chk.seed )
{
LABEL_79:
m_GJRewardDelegate = a1->m_GJRewardDelegate;
if ( !m_GJRewardDelegate )
goto LABEL_61;
goto LABEL_60;
}
v66 = cocos2d::CCArray::stringAtIndex(v46, 3u);
v67 = (char *)cocos2d::CCString::getCString(v66);
sub_D153B8((int)&v106, v67);
v68 = GameManager::sharedState();
v98 = (const char *)&v107;
sub_D18D28(&v107, &v68->m_playerUDID);
v69 = sub_D17014(&v106, v98);
if ( (__int64 *)(v107 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v107 - 24));
if ( v69
|| (v71 = cocos2d::CCArray::stringAtIndex(v46, 4u),
v72 = cocos2d::CCString::intValue(v71),
v73 = GJAccountManager::sharedState(),
v72 != v73->m_accountID - v73->m_unkInt1) )
{
v70 = a1->m_GJRewardDelegate;
if ( v70 )
v70->rewardsStatusFailed(v70);
if ( (__int64 *)(v106 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v106 - 24));
goto LABEL_61;
}
v74 = cocos2d::CCArray::stringAtIndex(v46, 5u);
v94 = cocos2d::CCString::intValue(v74);
v75 = cocos2d::CCArray::stringAtIndex(v46, 6u);
v76 = (char *)cocos2d::CCString::getCString(v75);
v93 = &v108;
sub_D153B8((int)&v108, v76);
v77 = cocos2d::CCArray::stringAtIndex(v46, 7u);
v78 = (char *)cocos2d::CCString::getCString(v77);
sub_D153B8((int)&v109, v78);
v79 = cocos2d::CCArray::stringAtIndex(v46, 8u);
v80 = (char *)cocos2d::CCString::getCString(v79);
sub_D153B8((int)&v110, v80);
for ( i = 1; i != 4; ++i )
{
v82 = GameStatsManager::sharedState();
Challenge = GameStatsManager::getChallenge(v82, i);
v83 = GameStatsManager::sharedState();
QueuedChallenge = (GameStatsManager *)GameStatsManager::getQueuedChallenge(v83, i);
v84 = GameStatsManager::sharedState();
SecondaryQueuedChallenge = GameStatsManager::getSecondaryQueuedChallenge(v84, i);
if ( i == 1 )
{
v85 = v93;
}
else if ( i == 2 )
{
v85 = &v109;
}
else
{
v85 = &v110;
}
sub_D18D28(&v111, v85);
v86 = (GJChallengeItem *)GJChallengeItem::createFromString((GJChallengeItem *)&v111, v114);
if ( (char *)v111 - 24 != (char *)&qword_124B6B0 )
sub_6EE220((char *)v111 - 24);
v86->m_position = i;
v87 = GameStatsManager::sharedState();
if ( !GameStatsManager::hasCompletedChallenge(v87, v86)
&& (!Challenge || Challenge->m_timeLeft < v86->m_timeLeft)
&& (!QueuedChallenge || SLODWORD(QueuedChallenge->m_obAnchorPointInPoints.y) < v86->m_timeLeft)
&& (!SecondaryQueuedChallenge || SecondaryQueuedChallenge->m_timeLeft < v86->m_timeLeft) )
{
if ( (!Challenge || Challenge->m_canClaim) && QueuedChallenge )
{
v88 = GameStatsManager::sharedState();
GameStatsManager::storeSecondaryQueuedChallenge(v88, i, v86);
}
else
{
v91 = GameStatsManager::sharedState();
GameStatsManager::storeQueuedChallenge(v91, i, v86);
}
}
}
v89 = GameStatsManager::sharedState();
GameStatsManager::storeChallengeTime(v89, v94);
v90 = a1->m_GJChallengeDelegate;
if ( v90 )
v90->challengeStatusFinished(v90);
if ( (__int64 *)(v110 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v110 - 24));
if ( (__int64 *)(v109 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v109 - 24));
if ( (__int64 *)(v108 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v108 - 24));
if ( (__int64 *)(v106 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v106 - 24));
if ( (__int64 *)(v104 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v104 - 24));
if ( v102 - 24 != (char *)&qword_124B6B0 )
sub_6EE220(v102 - 24);
if ( (char *)v100 - 24 != (char *)&qword_124B6B0 )
sub_6EE220((char *)v100 - 24);
if ( (__int64 *)(v99 - 24) != &qword_124B6B0 )
sub_6EE220((void *)(v99 - 24));
}
else
{
v11 = a1->m_GJChallengeDelegate;
if ( v11 )
v11->challengeStatusFailed(v11);
}
return _stack_chk_guard;
}