//
// GameLevelManager::onGetGJChallengesCompleted from 0x4c9d1c to 0x4ca204 (1256 bytes)
//
// 1 xrefs:
// > GameLevelManager::handleIt @ 0x4daeba
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:50:36 +0000
//
int __fastcall GameLevelManager::onGetGJChallengesCompleted(GameLevelManager *a1, unsigned __int8 *a2)
{
_BOOL4 v4; // r4
cocos2d::CCArray *v5; // r7
int result; // r0
cocos2d::CCString *v7; // r0
const char *CString; // r8
size_t v9; // r0
cocos2d::CCString *v10; // r0
const char *v11; // r4
size_t v12; // r0
unsigned int v13; // r3
int v14; // r0
int v15; // r0
unsigned int v16; // r1
_BYTE *v17; // r2
cocos2d::CCString *v18; // r0
char *v19; // r0
char *v20; // r4
const void *v21; // r0
unsigned __int8 *v22; // r3
char *v23; // r2
size_t v24; // r0
_BOOL4 v25; // r7
int v26; // r0
cocos2d::CCArray *v27; // r4
int v28; // r0
cocos2d::CCString *v29; // r0
GameManager *v30; // r0
int v31; // r7
GameManager *v32; // r0
cocos2d::CCString *v33; // r0
GameManager *v34; // r7
int v35; // r0
cocos2d::CCString *v36; // r0
const char *v37; // r10
size_t v38; // r0
GameManager *v39; // r0
int v40; // r0
_BOOL4 v41; // r11
cocos2d::CCString *v42; // r0
GJAccountManager *v43; // r10
int v44; // r0
int v45; // r0
cocos2d::CCString *v46; // r0
cocos2d::CCString *v47; // r0
const char *v48; // r7
size_t v49; // r0
cocos2d::CCString *v50; // r0
const char *v51; // r7
size_t v52; // r0
cocos2d::CCString *v53; // r0
const char *v54; // r4
size_t v55; // r0
GameStatsManager *hasCompletedChallenge; // r0
int i; // r4
GameStatsManager *v58; // r0
int Challenge; // r11
GameStatsManager *v60; // r0
GameStatsManager *v61; // r0
int *v62; // r1
GJChallengeItem *v63; // r7
GameStatsManager *v64; // r0
GameStatsManager *v65; // r0
GameStatsManager *v66; // r0
void (__fastcall ***v67)(_DWORD); // r0
GameStatsManager *v68; // r0
GameStatsManager *v69; // r0
GameStatsManager *QueuedChallenge; // [sp+18h] [bp-A8h]
int SecondaryQueuedChallenge; // [sp+1Ch] [bp-A4h]
int v72; // [sp+28h] [bp-98h]
int v73; // [sp+30h] [bp-90h] BYREF
unsigned int v74; // [sp+34h] [bp-8Ch]
_BYTE *v75; // [sp+38h] [bp-88h]
int v76[3]; // [sp+3Ch] [bp-84h] BYREF
int v77; // [sp+48h] [bp-78h] BYREF
unsigned int v78; // [sp+4Ch] [bp-74h]
_BYTE *v79; // [sp+50h] [bp-70h]
int v80[3]; // [sp+54h] [bp-6Ch] BYREF
int v81[3]; // [sp+60h] [bp-60h] BYREF
_DWORD v82[3]; // [sp+6Ch] [bp-54h] BYREF
int v83[3]; // [sp+78h] [bp-48h] BYREF
int v84[3]; // [sp+84h] [bp-3Ch] BYREF
int v85[3]; // [sp+90h] [bp-30h] BYREF
int v86[3]; // [sp+9Ch] [bp-24h] BYREF
int v87[3]; // [sp+A8h] [bp-18h] BYREF
int v88[3]; // [sp+B4h] [bp-Ch] BYREF
int v89[3]; // [sp+C0h] [bp+0h] BYREF
_BYTE v90[20]; // [sp+CCh] [bp+Ch] BYREF
unsigned __int8 v91[44]; // [sp+E0h] [bp+20h] BYREF
GameLevelManager::removeDLFromActive(a1, "get_chal");
memset(v89, 0, sizeof(v89));
std::string::__init(v89, "-1", 2u);
v4 = sub_4A9CC4(a2, (unsigned __int8 *)v89);
std::string::~string((int)v89);
if ( !v4 )
{
v5 = sub_4C1A88(a2, "|");
if ( cocos2d::CCArray::count(v5) > 1u )
{
v7 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v5, 0);
v73 = 0;
v74 = 0;
v75 = nullptr;
CString = (const char *)cocos2d::CCString::getCString(v7);
v9 = strlen(CString);
std::string::__init(&v73, CString, v9);
v10 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v5, 1u);
v11 = (const char *)cocos2d::CCString::getCString(v10);
memset(v76, 0, sizeof(v76));
v12 = strlen(v11);
std::string::__init(v76, v11, v12);
if ( (v73 & 1) != 0 )
v13 = v74;
else
v13 = (int)(unsigned __int8)v73 >> 1;
if ( v13 <= 4 )
{
v14 = *((_DWORD *)a1 + 230);
if ( v14 )
(*(void (__fastcall **)(int, int))(*(_DWORD *)v14 + 4))(v14, (unsigned __int8)v73 << 31);
goto LABEL_45;
}
std::string::basic_string(&v77, (unsigned __int8 *)&v73, 5u, 0xFFFFFFFF);
if ( (v73 & 1) != 0 )
{
*v75 = 0;
v74 = 0;
}
else
{
LOWORD(v73) = 0;
}
std::string::reserve(&v73, 0);
v15 = v77;
v16 = v78;
v17 = v79;
v77 = 0;
v78 = 0;
v79 = nullptr;
v73 = v15;
v74 = v16;
v75 = v17;
std::string::~string((int)&v77);
std::string::basic_string(v80, (int)&v73);
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%c%s%s%c%c%s",
(const char *)&dword_6C + 3,
"C36",
"fpYa",
80,
116,
"dg");
v19 = (char *)cocos2d::CCString::getCString(v18);
std::string::append(v80, v19);
if ( (v80[0] & 1) != 0 )
v20 = (char *)v80[2];
else
v20 = (char *)v80 + 1;
v21 = (const void *)strlen(v20);
rtsha1::calc((rtsha1 *)v20, v21, (int)v90, v22);
rtsha1::toHexString((rtsha1 *)v90, v91, v23);
memset(v81, 0, sizeof(v81));
v24 = strlen((const char *)v91);
std::string::__init(v81, v91, v24);
v25 = sub_4A9CC4((unsigned __int8 *)v81, (unsigned __int8 *)v76);
std::string::~string((int)v81);
if ( !v25 )
{
v26 = *((_DWORD *)a1 + 230);
if ( v26 )
(*(void (__fastcall **)(int))(*(_DWORD *)v26 + 4))(v26);
goto LABEL_44;
}
memset(v83, 0, sizeof(v83));
std::string::__init(v83, "19847", 5u);
cocos2d::ZipUtils::base64DecodeEnc(v82, &v73, v83);
std::string::~string((int)v83);
v27 = sub_4C1A88(v82, ":");
if ( cocos2d::CCArray::count(v27) > 8u )
{
v29 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 1u);
v30 = (GameManager *)cocos2d::CCString::intValue(v29);
v31 = (int)v30;
if ( (int)v30 > 0 )
{
v32 = (GameManager *)GameManager::sharedState(v30);
GameManager::setPlayerUserID(v32, v31);
v33 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 2u);
v34 = (GameManager *)cocos2d::CCString::intValue(v33);
v35 = GameManager::sharedState(v34);
if ( v34 == (GameManager *)(*(_DWORD *)(v35 + 696) - *(_DWORD *)(v35 + 700)) )
{
v36 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 3u);
v37 = (const char *)cocos2d::CCString::getCString(v36);
memset(v84, 0, sizeof(v84));
v38 = strlen(v37);
v39 = (GameManager *)std::string::__init(v84, v37, v38);
v40 = GameManager::sharedState(v39);
std::string::basic_string(v85, v40 + 436);
v41 = sub_4A9CC4((unsigned __int8 *)v84, (unsigned __int8 *)v85);
std::string::~string((int)v85);
if ( v41 )
{
v42 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 4u);
v43 = (GJAccountManager *)cocos2d::CCString::intValue(v42);
v44 = GJAccountManager::sharedState(v43);
if ( v43 == (GJAccountManager *)(*(_DWORD *)(v44 + 280) - *(_DWORD *)(v44 + 284)) )
{
v46 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 5u);
v72 = cocos2d::CCString::intValue(v46);
v47 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 6u);
v48 = (const char *)cocos2d::CCString::getCString(v47);
memset(v86, 0, sizeof(v86));
v49 = strlen(v48);
std::string::__init(v86, v48, v49);
v50 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 7u);
v51 = (const char *)cocos2d::CCString::getCString(v50);
memset(v87, 0, sizeof(v87));
v52 = strlen(v51);
std::string::__init(v87, v51, v52);
v53 = (cocos2d::CCString *)cocos2d::CCArray::stringAtIndex(v27, 8u);
v54 = (const char *)cocos2d::CCString::getCString(v53);
memset(v88, 0, sizeof(v88));
v55 = strlen(v54);
hasCompletedChallenge = (GameStatsManager *)std::string::__init(v88, v54, v55);
for ( i = 1; i != 4; ++i )
{
v58 = (GameStatsManager *)GameStatsManager::sharedState(hasCompletedChallenge);
Challenge = GameStatsManager::getChallenge(v58, i);
v60 = (GameStatsManager *)GameStatsManager::sharedState((GameStatsManager *)Challenge);
QueuedChallenge = (GameStatsManager *)GameStatsManager::getQueuedChallenge(v60, i);
v61 = (GameStatsManager *)GameStatsManager::sharedState(QueuedChallenge);
SecondaryQueuedChallenge = GameStatsManager::getSecondaryQueuedChallenge(v61, i);
if ( i == 1 )
{
v62 = v86;
}
else if ( i == 2 )
{
v62 = v87;
}
else
{
v62 = v88;
}
std::string::basic_string(v89, (int)v62);
v63 = (GJChallengeItem *)GJChallengeItem::createFromString(v89);
v64 = (GameStatsManager *)std::string::~string((int)v89);
*((_DWORD *)v63 + 25) = i;
v65 = (GameStatsManager *)GameStatsManager::sharedState(v64);
hasCompletedChallenge = (GameStatsManager *)GameStatsManager::hasCompletedChallenge(v65, v63);
if ( !hasCompletedChallenge
&& (!Challenge || *(_DWORD *)(Challenge + 92) < *((_DWORD *)v63 + 23))
&& (!QueuedChallenge || *((_DWORD *)QueuedChallenge + 23) < *((_DWORD *)v63 + 23))
&& (!SecondaryQueuedChallenge || *(_DWORD *)(SecondaryQueuedChallenge + 92) < *((_DWORD *)v63 + 23)) )
{
if ( (!Challenge || *(_BYTE *)(Challenge + 96)) && QueuedChallenge )
{
v68 = (GameStatsManager *)GameStatsManager::sharedState(nullptr);
hasCompletedChallenge = (GameStatsManager *)GameStatsManager::storeSecondaryQueuedChallenge(
v68,
i,
v63);
}
else
{
v69 = (GameStatsManager *)GameStatsManager::sharedState(nullptr);
hasCompletedChallenge = (GameStatsManager *)GameStatsManager::storeQueuedChallenge(v69, i, v63);
}
}
}
v66 = (GameStatsManager *)GameStatsManager::sharedState(hasCompletedChallenge);
GameStatsManager::storeChallengeTime(v66, v72);
v67 = *((void (__fastcall ****)(_DWORD))a1 + 230);
if ( v67 )
(**v67)(v67);
std::string::~string((int)v88);
std::string::~string((int)v87);
std::string::~string((int)v86);
std::string::~string((int)v84);
std::string::~string((int)v82);
std::string::~string((int)v80);
std::string::~string((int)v76);
return std::string::~string((int)&v73);
}
}
v45 = *((_DWORD *)a1 + 228);
if ( v45 )
(*(void (__fastcall **)(int))(*(_DWORD *)v45 + 4))(v45);
std::string::~string((int)v84);
goto LABEL_43;
}
}
v28 = *((_DWORD *)a1 + 228);
}
else
{
v28 = *((_DWORD *)a1 + 230);
}
if ( v28 )
(*(void (__fastcall **)(int))(*(_DWORD *)v28 + 4))(v28);
LABEL_43:
std::string::~string((int)v82);
LABEL_44:
std::string::~string((int)v80);
LABEL_45:
std::string::~string((int)v76);
return std::string::~string((int)&v73);
}
}
result = *((_DWORD *)a1 + 230);
if ( result )
return (*(int (__fastcall **)(int))(*(_DWORD *)result + 4))(result);
return result;
}