//
// GameStatsManager::processChallengeQueue from 0x1401e2920 to 0x1401e2bf9 (729 bytes)
//
// 3 xrefs:
// > ChallengesPage::createChallengeNode @ 0x140086205
// > ChallengesPage::claimItem @ 0x140086cae
// > ??> @ 0x1406cc594
//
// 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
//
// Hidden C++ exception states: #wind=1
void GameStatsManager::processChallengeQueue(GameStatsManager *a1, int a2)
{
GJChallengeItem *QueuedChallenge; // rsi
GJChallengeItem *SecondaryQueuedChallenge; // r15
cocos2d::CCString *v6; // rax
const char *CString; // rax
size_t v8; // rbx
size_t v9; // r8
void *v10; // rcx
cocos2d::CCString *v11; // rax
const char *v12; // rax
size_t v13; // r8
void *v14; // rcx
cocos2d::CCString *v15; // rax
const char *v16; // rax
size_t v17; // r8
void *v18; // rcx
cocos2d::CCString *v19; // rax
const char *v20; // rax
void *v21; // rcx
void *Block[2]; // [rsp+20h] [rbp-30h] BYREF
__int128 v23; // [rsp+30h] [rbp-20h]
QueuedChallenge = GameStatsManager::getQueuedChallenge(a1, a2);
SecondaryQueuedChallenge = GameStatsManager::getSecondaryQueuedChallenge(a1, a2);
v6 = cocos2d::CCString::createWithFormat("%i", a2);
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)Block = 0;
v23 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
sub_14003A930(Block, CString, v9);
cocos2d::CCDictionary::removeObjectForKey(a1->m_activeChallenges, Block);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v10 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v10);
}
if ( QueuedChallenge )
{
QueuedChallenge->m_position = a2;
v11 = cocos2d::CCString::createWithFormat("%i", a2);
v12 = cocos2d::CCString::getCString(v11);
*(_OWORD *)Block = 0;
v23 = 0;
v13 = -1;
do
++v13;
while ( v12[v13] );
sub_14003A930(Block, v12, v13);
cocos2d::CCDictionary::setObject(a1->m_activeChallenges, QueuedChallenge, Block);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v14 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
v15 = cocos2d::CCString::createWithFormat("%i", a2);
v16 = cocos2d::CCString::getCString(v15);
*(_OWORD *)Block = 0;
v23 = 0;
v17 = -1;
do
++v17;
while ( v16[v17] );
sub_14003A930(Block, v16, v17);
cocos2d::CCDictionary::removeObjectForKey(a1->m_upcomingChallenges, Block);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v18 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
}
if ( SecondaryQueuedChallenge )
{
GameStatsManager::storeQueuedChallenge(a1, a2, SecondaryQueuedChallenge);
v19 = cocos2d::CCString::createWithFormat("%i", a2 + 100);
v20 = cocos2d::CCString::getCString(v19);
*(_OWORD *)Block = 0;
v23 = 0;
do
++v8;
while ( v20[v8] );
sub_14003A930(Block, v20, v8);
cocos2d::CCDictionary::removeObjectForKey(a1->m_upcomingChallenges, Block);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v21 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v21 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v21 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v21);
}
}
}