//
// ChallengesPage::claimItem from 0x14009f0f0 to 0x14009f406 (790 bytes)
//
// 2 xrefs:
// > ChallengeNode::onClaimReward @ 0x1400a0587
// > ??> @ 0x140913064
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:26:06 +0000
//
// Hidden C++ exception states: #wind=3
__int64 __fastcall ChallengesPage::claimItem(_QWORD *a1, __int64 a2, __int64 a3, const struct cocos2d::CCPoint *a4)
{
unsigned int v7; // r15d
__int64 v8; // rdi
unsigned int v9; // ebp
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
__int64 v13; // rbx
struct cocos2d::CCString *v14; // rax
void *v15; // rcx
int v16; // edi
__int64 v17; // rbx
const struct cocos2d::CCPoint *v18; // rax
__int64 v19; // rax
int v20; // ebx
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rcx
void *v25; // [rsp+60h] [rbp-88h] BYREF
void *v26; // [rsp+68h] [rbp-80h] BYREF
void *Block[2]; // [rsp+70h] [rbp-78h] BYREF
__int64 v28; // [rsp+80h] [rbp-68h]
unsigned __int64 v29; // [rsp+88h] [rbp-60h]
v7 = *(_DWORD *)(a3 + 104);
v8 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v25 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480(v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v8 = qword_14090BFE0;
}
if ( *(_BYTE *)(a3 + 100) && !(unsigned __int8)GameStatsManager::hasCompletedChallenge(v8, a3) )
{
v9 = *(_DWORD *)(a3 + 72) - *(_DWORD *)(a3 + 76);
v10 = cocos2d::CCString::createWithFormat("c%i%i", *(_DWORD *)(a3 + 104), *(_DWORD *)(a3 + 96));
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)Block = 0;
v28 = 0;
v29 = 0;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003D230(Block, CString, v12);
v13 = *(_QWORD *)(v8 + 816);
v14 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, v9);
cocos2d::CCDictionary::setObject(v13, v14, Block);
if ( v29 > 0xF )
{
v15 = Block[0];
if ( v29 + 1 >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v15);
}
GameStatsManager::incrementStat(v8, "13", v9);
}
if ( a1[90] )
{
v16 = *(_DWORD *)(a3 + 72) - *(_DWORD *)(a3 + 76);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v25, a4);
v17 = a1[90];
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v26, v18);
CurrencyRewardLayer::createObjectsFull(v17, 3, v16, 0, v19, 0);
}
else
{
v20 = *(_DWORD *)(a3 + 72) - *(_DWORD *)(a3 + 76);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v26, a4);
v22 = CurrencyRewardLayer::create(0, 0, 0, v20, 0, 0, 0, 0, v21, 0, 0, 1065353216);
a1[90] = v22;
*(_QWORD *)(v22 + 408) = a1 + 85;
(*(void (__fastcall **)(_QWORD *, _QWORD, __int64))(*a1 + 456LL))(a1, a1[90], 14);
}
ChallengesPage::exitNodeAtSlot((__int64)a1, v7, 0.0);
v23 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v26 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480(v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v23 = qword_14090BFE0;
}
GameStatsManager::processChallengeQueue(v23, v7);
ChallengesPage::createChallengeNode((__int64)a1, v7, 0, 0.5, 1u);
ChallengesPage::updateTimers((__int64)a1);
return ChallengesPage::updateDots((__int64)a1);
}