//
// GameLevelManager::onGetGJChallengesCompleted from 0x10008f7d4 to 0x10008feb0 (1756 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x100088bc0
//
// 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
//
void __fastcall GameLevelManager::onGetGJChallengesCompleted(GameLevelManager *a1, _QWORD *a2)
{
_BOOL4 v4; // w0
_BOOL4 v5; // w21
GJChallengeDelegate *m_GJChallengeDelegate; // x0
cocos2d::CCArray *v7; // x20
cocos2d::CCString *v8; // x0
char *CString; // x0
cocos2d::CCString *v10; // x0
char *v11; // x0
std::string::size_type size; // x8
GJChallengeDelegate *v13; // x0
cocos2d::CCString *v14; // x0
const char *v15; // x0
std::string *p_a; // x20
size_t v17; // x0
bool v18; // w0
bool v19; // w20
cocos2d::CCArray *v20; // x21
void *m_GJRewardDelegate; // x0
GJChallengeDelegate *v22; // x0
cocos2d::CCString *v23; // x0
int v24; // w20
GameManager *v25; // x22
float v26; // s0
cocos2d::CCString *v27; // x0
int v28; // w20
GameManager *v29; // x0
cocos2d::CCString *v30; // x0
char *v31; // x0
GameManager *v32; // x0
bool v33; // w20
cocos2d::CCString *v34; // x0
int v35; // w20
GJAccountManager *v36; // x0
cocos2d::CCString *v37; // x0
int v38; // w20
cocos2d::CCString *v39; // x0
char *v40; // x0
cocos2d::CCString *v41; // x0
char *v42; // x0
cocos2d::CCString *v43; // x0
char *v44; // x0
int i; // w21
GameStatsManager *v46; // x0
GJChallengeItem *Challenge; // x22
GameStatsManager *v48; // x0
GJChallengeItem *QueuedChallenge; // x23
GameStatsManager *v50; // x0
GJChallengeItem *SecondaryQueuedChallenge; // x25
void **v52; // x8
char *v53; // x9
void *v54; // x1
void **v55; // x8
GJChallengeItem *v56; // x24
GameStatsManager *v57; // x0
GameStatsManager *v58; // x0
GameStatsManager *v59; // x0
GameStatsManager *v60; // x0
GJChallengeDelegate *v61; // x0
GJRewardDelegate *v62; // x0
void *v63[2]; // [xsp+30h] [xbp-1A0h] BYREF
void *v64; // [xsp+40h] [xbp-190h]
void *v65[2]; // [xsp+50h] [xbp-180h] BYREF
char v66; // [xsp+67h] [xbp-169h] BYREF
void *v67[2]; // [xsp+68h] [xbp-168h] BYREF
char v68; // [xsp+7Fh] [xbp-151h] BYREF
void *__dst[2]; // [xsp+80h] [xbp-150h] BYREF
char *longStorage; // [xsp+90h] [xbp-140h] BYREF
void *v71[2]; // [xsp+98h] [xbp-138h] BYREF
char v72; // [xsp+AFh] [xbp-121h]
void *__p[2]; // [xsp+B0h] [xbp-120h] BYREF
char v74; // [xsp+C7h] [xbp-109h]
void *v75[2]; // [xsp+C8h] [xbp-108h] BYREF
char v76; // [xsp+DFh] [xbp-F1h]
std::string __a; // [xsp+E0h] [xbp-F0h] BYREF
void *v78[2]; // [xsp+F8h] [xbp-D8h] BYREF
char v79; // [xsp+10Fh] [xbp-C1h]
std::string __str; // [xsp+110h] [xbp-C0h] BYREF
std::string v81; // [xsp+130h] [xbp-A0h] BYREF
_BYTE v82[20]; // [xsp+15Ch] [xbp-74h] BYREF
GameLevelManager::removeDLFromActive(a1, "get_chal");
sub_100009900(&v81, "-1");
v4 = sub_1000045BC(a2, &v81);
v5 = v4;
if ( SHIBYTE(v81.__r_.__value_.__r.__words[2]) < 0 )
{
operator delete(v81.__r_.__value_.__l.__data_);
if ( v5 )
{
LABEL_3:
m_GJChallengeDelegate = a1->m_GJChallengeDelegate;
if ( !m_GJChallengeDelegate )
return;
goto LABEL_4;
}
}
else if ( v4 )
{
goto LABEL_3;
}
v7 = (cocos2d::CCArray *)sub_100093338(a2, "|");
if ( (unsigned int)sub_10024A36C(v7) <= 1 )
{
m_GJChallengeDelegate = a1->m_GJChallengeDelegate;
if ( !m_GJChallengeDelegate )
return;
LABEL_4:
((void (__fastcall *)(GJChallengeDelegate *))m_GJChallengeDelegate->challengeStatusFailed)(m_GJChallengeDelegate);
return;
}
v8 = cocos2d::CCArray::stringAtIndex(v7, 0);
CString = (char *)cocos2d::CCString::getCString(v8);
sub_100009900(&__str, CString);
v10 = cocos2d::CCArray::stringAtIndex(v7, 1u);
v11 = (char *)cocos2d::CCString::getCString(v10);
sub_100009900(v78, v11);
size = HIBYTE(__str.__r_.__value_.__r.__words[2]);
if ( (__str.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = __str.__r_.__value_.__l.__size_;
if ( size <= 4 )
{
v13 = a1->m_GJChallengeDelegate;
if ( v13 )
((void (__fastcall *)(GJChallengeDelegate *))v13->challengeStatusFailed)(v13);
goto LABEL_94;
}
std::string::basic_string(&v81, &__str, 5u, 0xFFFFFFFFFFFFFFFFLL, (std::allocator *)&__a);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
__str = v81;
if ( SHIBYTE(v81.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__a, __str.__r_.__value_.__l.__data_, __str.__r_.__value_.__l.__size_);
else
__a = __str;
v14 = (cocos2d::CCString *)sub_100268F4C("%c%s%s%c%c%s", 111, "C36", "fpYa", 80, 116, "dg");
v15 = cocos2d::CCString::getCString(v14);
p_a = &__a;
std::string::append(&__a, v15);
if ( (__a.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
p_a = (std::string *)__a.__r_.__value_.__r.__words[0];
v17 = strlen((const char *)p_a);
sub_1000F7448(p_a, v17, v82);
sub_1000F78E0(v82, &v81);
sub_100009900(v75, (char *)&v81);
v18 = sub_1000045BC(v75, v78);
v19 = v18;
if ( (v76 & 0x80000000) == 0 )
{
if ( v18 )
goto LABEL_23;
LABEL_29:
v22 = a1->m_GJChallengeDelegate;
if ( v22 )
((void (__fastcall *)(GJChallengeDelegate *))v22->challengeStatusFailed)(v22);
goto LABEL_92;
}
operator delete(v75[0]);
if ( !v19 )
goto LABEL_29;
LABEL_23:
sub_100009900(__p, "19847");
cocos2d::ZipUtils::base64DecodeEnc(v75, &__str, __p);
if ( v74 < 0 )
operator delete(__p[0]);
v20 = (cocos2d::CCArray *)sub_100093338(v75, ":");
if ( (unsigned int)sub_10024A36C(v20) <= 8 )
{
m_GJRewardDelegate = a1->m_GJChallengeDelegate;
if ( !m_GJRewardDelegate )
goto LABEL_90;
LABEL_38:
(*(void (__fastcall **)(void *))(*(_QWORD *)m_GJRewardDelegate + 8LL))(m_GJRewardDelegate);
goto LABEL_90;
}
v23 = cocos2d::CCArray::stringAtIndex(v20, 1u);
v24 = cocos2d::CCString::intValue(v23);
if ( v24 < 1 )
{
m_GJRewardDelegate = a1->m_GJRewardDelegate;
if ( !m_GJRewardDelegate )
goto LABEL_90;
goto LABEL_38;
}
v25 = GameManager::sharedState();
v25->m_playerUserID.value = v24;
v26 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
v25->m_playerUserID.seed = (int)v26;
v25->m_playerUserID.random = v24 + (int)v26;
v27 = cocos2d::CCArray::stringAtIndex(v20, 2u);
v28 = cocos2d::CCString::intValue(v27);
v29 = GameManager::sharedState();
if ( v28 != v29->m_chk.random - v29->m_chk.seed )
{
m_GJRewardDelegate = a1->m_GJRewardDelegate;
if ( !m_GJRewardDelegate )
goto LABEL_90;
goto LABEL_38;
}
v30 = cocos2d::CCArray::stringAtIndex(v20, 3u);
v31 = (char *)cocos2d::CCString::getCString(v30);
sub_100009900(v71, v31);
v32 = GameManager::sharedState();
if ( v32->m_playerUDID.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__dst, (void *)v32->m_playerUDID.m_data.m_long.capacitym1, v32->m_playerUDID.m_data.m_long.size);
}
else
{
*(_OWORD *)__dst = *(_OWORD *)&v32->m_playerUDID.m_data.m_short.sizex2;
longStorage = v32->m_playerUDID.m_data.m_long.longStorage;
}
v33 = sub_1000045BC(v71, __dst);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__dst[0]);
if ( !v33 )
{
v62 = a1->m_GJRewardDelegate;
if ( !v62 )
goto LABEL_88;
LABEL_87:
((void (__fastcall *)(GJRewardDelegate *))v62->rewardsStatusFailed)(v62);
goto LABEL_88;
}
v34 = cocos2d::CCArray::stringAtIndex(v20, 4u);
v35 = cocos2d::CCString::intValue(v34);
v36 = GJAccountManager::sharedState();
if ( v35 != v36->m_accountID - v36->m_unkInt1 )
{
v62 = a1->m_GJRewardDelegate;
if ( !v62 )
goto LABEL_88;
goto LABEL_87;
}
v37 = cocos2d::CCArray::stringAtIndex(v20, 5u);
v38 = cocos2d::CCString::intValue(v37);
v39 = cocos2d::CCArray::stringAtIndex(v20, 6u);
v40 = (char *)cocos2d::CCString::getCString(v39);
sub_100009900(__dst, v40);
v41 = cocos2d::CCArray::stringAtIndex(v20, 7u);
v42 = (char *)cocos2d::CCString::getCString(v41);
sub_100009900(v67, v42);
v43 = cocos2d::CCArray::stringAtIndex(v20, 8u);
v44 = (char *)cocos2d::CCString::getCString(v43);
sub_100009900(v65, v44);
for ( i = 1; i != 4; ++i )
{
v46 = GameStatsManager::sharedState();
Challenge = GameStatsManager::getChallenge(v46, i);
v48 = GameStatsManager::sharedState();
QueuedChallenge = GameStatsManager::getQueuedChallenge(v48, i);
v50 = GameStatsManager::sharedState();
SecondaryQueuedChallenge = GameStatsManager::getSecondaryQueuedChallenge(v50, i);
if ( i == 2 )
v52 = v67;
else
v52 = v65;
v53 = &v68;
if ( i != 2 )
v53 = &v66;
if ( i == 1 )
{
v52 = __dst;
v53 = (char *)&longStorage + 7;
}
if ( *v53 < 0 )
{
v54 = *v52;
if ( i == 2 )
v55 = v67;
else
v55 = v65;
if ( i == 1 )
v55 = __dst;
sub_1000097D0(v63, v54, (unsigned __int64)v55[1]);
}
else
{
*(_OWORD *)v63 = *(_OWORD *)v52;
v64 = v52[2];
}
v56 = (GJChallengeItem *)GJChallengeItem::createFromString(v63);
if ( SHIBYTE(v64) < 0 )
operator delete(v63[0]);
v56->m_position = i;
v57 = GameStatsManager::sharedState();
if ( !GameStatsManager::hasCompletedChallenge(v57, v56)
&& (!Challenge || Challenge->m_timeLeft < v56->m_timeLeft)
&& (!QueuedChallenge || QueuedChallenge->m_timeLeft < v56->m_timeLeft)
&& (!SecondaryQueuedChallenge || SecondaryQueuedChallenge->m_timeLeft < v56->m_timeLeft) )
{
if ( Challenge )
{
if ( QueuedChallenge && Challenge->m_canClaim )
{
LABEL_72:
v58 = GameStatsManager::sharedState();
GameStatsManager::storeSecondaryQueuedChallenge(v58, i, v56);
continue;
}
}
else if ( QueuedChallenge )
{
goto LABEL_72;
}
v59 = GameStatsManager::sharedState();
GameStatsManager::storeQueuedChallenge(v59, i, v56);
}
}
v60 = GameStatsManager::sharedState();
GameStatsManager::storeChallengeTime(v60, v38);
v61 = a1->m_GJChallengeDelegate;
if ( v61 )
((void (__fastcall *)(GJChallengeDelegate *))v61->challengeStatusFinished)(v61);
if ( v66 < 0 )
operator delete(v65[0]);
if ( v68 < 0 )
operator delete(v67[0]);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__dst[0]);
LABEL_88:
if ( v72 < 0 )
operator delete(v71[0]);
LABEL_90:
if ( v76 < 0 )
operator delete(v75[0]);
LABEL_92:
if ( SHIBYTE(__a.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__a.__r_.__value_.__l.__data_);
LABEL_94:
if ( v79 < 0 )
operator delete(v78[0]);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
}