//
// ChallengesPage::createChallengeNode from 0x1400860e0 to 0x140086403 (803 bytes)
//
// 4 xrefs:
// > ChallengesPage::init @ 0x140085830
// > ChallengesPage::challengeStatusFinished @ 0x140085ee5
// > ChallengesPage::claimItem @ 0x140086cc8
// > ??> @ 0x1406c6c3c
//
// 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=5
ChallengeNode *ChallengesPage::createChallengeNode(ChallengesPage *a1, int a2, bool a3, float a4, bool a5)
{
__int64 v6; // rsi
__int64 v8; // rcx
cocos2d::CCDirector *v10; // rax
GameStatsManager *v12; // rcx
GameStatsManager *v13; // rcx
GameStatsManager *v14; // rcx
GJChallengeItem *Challenge; // rbx
ChallengeNode *v16; // rdi
const struct cocos2d::CCPoint *v17; // rax
ChallengeNode_vtbl *v18; // rbx
__int64 v19; // rcx
cocos2d::CCDirector *v20; // rax
float v21; // xmm0_4
const cocos2d::CCPoint *v22; // rax
struct cocos2d::CCDelayTime *v23; // rbx
struct cocos2d::CCMoveTo *v24; // rax
struct cocos2d::CCEaseElasticOut *v25; // rax
struct cocos2d::CCSequence *v26; // rax
cocos2d::ccColor3B *v27; // r8
ChallengeNode *v28; // [rsp+20h] [rbp-58h] BYREF
cocos2d::CCPoint v29; // [rsp+28h] [rbp-50h] BYREF
cocos2d::CCPoint v30[2]; // [rsp+30h] [rbp-48h] BYREF
float v31; // [rsp+80h] [rbp+8h]
float v32; // [rsp+84h] [rbp+Ch]
v6 = a2;
if ( cocos2d::CCDictionary::objectForKey(a1->m_challengeNodes, a2) )
return nullptr;
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::getWinSize(v10);
cocos2d::CCPoint::CCPoint(&v29, v31 * 0.5, (float)((float)(v32 * 0.5) + 80.0) + 5.0);
v12 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v28 = (ChallengeNode *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v12 = (GameStatsManager *)qword_1406C2EE8;
}
if ( !GameStatsManager::getChallenge(v12, v6) )
{
v13 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v28 = (ChallengeNode *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v13 = (GameStatsManager *)qword_1406C2EE8;
}
GameStatsManager::processChallengeQueue(v13, v6);
a5 = 1;
}
v14 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v28 = (ChallengeNode *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0(v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v14 = (GameStatsManager *)qword_1406C2EE8;
}
Challenge = GameStatsManager::getChallenge(v14, v6);
v16 = (ChallengeNode *)operator new(0x168u);
v28 = v16;
cocos2d::CCNode::CCNode(v16);
v16->__vftable = (ChallengeNode_vtbl *)&ChallengeNode::`vftable';
v16->m_challengeItem = nullptr;
cocos2d::CCPoint::CCPoint(&v16->m_unkPoint);
v16->m_countdownLabel = nullptr;
v16->m_unloaded = 0;
if ( ChallengeNode::init(v16, Challenge, a1, a5) )
{
cocos2d::CCObject::autorelease(v16);
}
else
{
((void (__fastcall *)(ChallengeNode *, __int64))v16->~ChallengeNode)(v16, 1);
v16 = nullptr;
}
a1->m_mainLayer->addChild_1(a1->m_mainLayer, v16);
cocos2d::CCPoint::CCPoint(v30, 0.0, (float)(v6 - 1) * -80.0);
cocos2d::CCPoint::operator+(&v29, &v28);
v16->setPosition_0(v16, (const cocos2d::CCPoint *)&v28);
cocos2d::CCDictionary::setObject(a1->m_challengeNodes, v16, v6);
if ( !a3 )
{
v17 = v16->getPosition_0(v16);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v28, v17);
v18 = v16->__vftable;
v20 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v19);
v21 = cocos2d::CCDirector::getScreenRight(v20) + 160.0;
cocos2d::CCPoint::CCPoint(v30, v21, *((float *)&v28 + 1));
v18->setPosition_0(v16, v22);
v23 = cocos2d::CCDelayTime::create(a4);
v24 = cocos2d::CCMoveTo::create(0.5, (const struct cocos2d::CCPoint *)&v28);
v25 = cocos2d::CCEaseElasticOut::create(v24, 0.60000002);
v26 = cocos2d::CCSequence::create(v23, v25, 0);
cocos2d::CCNode::runAction((CCLightFlash *)v16, (cocos2d::CCPoint)v26, v27, a4, *(float *)&v28);
}
return v16;
}