//
// LevelListLayer::onClaimReward from 0x1403060a0 to 0x14030670b (1643 bytes)
//
// 2 xrefs:
// > LevelListLayer::updateStatsArt @ 0x140305d3e
// > ??> @ 0x1406d4490
//
// 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=7
void LevelListLayer::onClaimReward(LevelListLayer *a1, cocos2d::CCObject *a2)
{
int v4; // edi
GameStatsManager *v5; // rdi
GJLevelList *m_levelList; // rbx
int v7; // eax
int m_levelsToClaim; // ecx
int m_diamonds; // r15d
cocos2d::CCString *v10; // rax
const char *v11; // rax
size_t v12; // rbx
struct cocos2d::CCString *v13; // rax
void *v14; // rcx
int v15; // ecx
int v16; // ebx
cocos2d::CCPoint v17; // rax
CurrencyRewardLayer *v18; // rax
const char *v19; // rdx
size_t v20; // rbx
size_t v21; // r8
void **v22; // r8
cocos2d::CCString *v23; // rax
const char *CString; // rax
__int64 v25; // rdx
__int64 v26; // rcx
__int64 v27; // r8
__int64 v28; // r9
void **v29; // r14
unsigned __int64 v30; // r15
bool v31; // r12
char *v32; // rsi
__int64 v33; // rbx
unsigned __int64 v34; // rdi
char *v35; // rax
DialogLayer *DialogLayer; // rdi
__int64 v37; // rcx
cocos2d::CCDirector *v38; // rax
cocos2d::CCLayer_vtbl *v39; // rbx
const cocos2d::CCPoint *v40; // rax
_BOOL8 v41; // rdx
float v42; // xmm2_4
struct cocos2d::CCScaleTo *v43; // rax
struct cocos2d::CCEaseElasticOut *v44; // rax
cocos2d::ccColor3B *v45; // r8
float v46; // xmm6_4
struct cocos2d::CCFadeTo *v47; // rax
cocos2d::ccColor3B *v48; // r8
char *v49; // rax
void *v50; // rcx
float v51; // [rsp+28h] [rbp-E0h]
float v52; // [rsp+28h] [rbp-E0h]
void **v53; // [rsp+68h] [rbp-A0h] BYREF
_BYTE v54[21]; // [rsp+78h] [rbp-90h] BYREF
char v55; // [rsp+8Dh] [rbp-7Bh]
__int16 v56; // [rsp+8Eh] [rbp-7Ah]
__int64 v57; // [rsp+90h] [rbp-78h]
__int64 v58; // [rsp+98h] [rbp-70h]
void *Block[2]; // [rsp+A0h] [rbp-68h] BYREF
unsigned __int64 v60; // [rsp+B0h] [rbp-58h]
unsigned __int64 v61; // [rsp+B8h] [rbp-50h]
void *v62[2]; // [rsp+C0h] [rbp-48h] BYREF
__int64 v63; // [rsp+D0h] [rbp-38h]
unsigned __int64 v64; // [rsp+D8h] [rbp-30h]
void *Src[2]; // [rsp+E0h] [rbp-28h] BYREF
unsigned __int64 v66; // [rsp+F0h] [rbp-18h]
unsigned __int64 v67; // [rsp+F8h] [rbp-10h]
v4 = a1->m_levelList->m_levelsToClaim - GJLevelList::completedLevels(a1->m_levelList);
if ( v4 > 0 )
{
v19 = "levels";
if ( v4 == 1 )
v19 = "level";
*(_OWORD *)v62 = 0;
v63 = 0;
v64 = 0;
v20 = -1;
v21 = -1;
do
++v21;
while ( v19[v21] );
sub_14003A930(v62, v19, v21);
v22 = v62;
if ( v64 > 0xF )
v22 = (void **)v62[0];
v23 = cocos2d::CCString::createWithFormat(
"Complete %i more %s from this list to claim the reward!",
v4,
(const char *)v22);
CString = cocos2d::CCString::getCString(v23);
*(_OWORD *)Src = 0;
v66 = 0;
v67 = 0;
do
++v20;
while ( CString[v20] );
sub_14003A930(Src, CString, v20);
*(_QWORD *)v54 = Block;
LOWORD(v53) = -1;
BYTE2(v53) = -1;
*(_OWORD *)Block = 0;
v60 = 0;
v61 = 0;
v29 = Src;
v30 = v67;
v31 = v67 > 0xF;
v32 = (char *)Src[0];
if ( v67 > 0xF )
v29 = (void **)Src[0];
v33 = 0x7FFFFFFFFFFFFFFFLL;
v34 = v66;
if ( v66 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v26, v25, v27, v28);
v61 = 15;
if ( v66 > 0xF )
{
if ( (v66 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v33 = v66 | 0xF;
if ( (v66 | 0xF) < 0x16 )
v33 = 22;
}
Block[0] = sub_14003AA10(v33 + 1);
v60 = v34;
v61 = v33;
memcpy(Block[0], v29, v34 + 1);
}
else
{
v60 = v66;
*(_OWORD *)Block = *(_OWORD *)v29;
}
v55 = 0;
v56 = 0;
v57 = 12;
v58 = 15;
strcpy(&v54[8], "The Mechanic");
v35 = DialogObject::create((__int64)&v54[8], (__int64)Block, 37, 1.0, 0, (__int64)&v53);
DialogLayer = DialogLayer::createDialogLayer((DialogObject *)v35, nullptr, 4);
DialogLayer::addToMainScene(DialogLayer);
v38 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v37);
cocos2d::CCDirector::getWinSize(v38);
v39 = DialogLayer->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint(1.9431574e-19, *(float *)&v53 * 0.5);
v39->setPosition_0(DialogLayer->m_mainLayer, v40);
LOBYTE(v41) = 1;
DialogLayer->setVisible(DialogLayer, v41);
v42 = sub_14003CF30();
DialogLayer->m_animateTime = v42;
((void (__fastcall *)(cocos2d::CCLayer *))DialogLayer->m_mainLayer->setScale_0)(DialogLayer->m_mainLayer);
v43 = cocos2d::CCScaleTo::create(0.5, 1.0);
v44 = cocos2d::CCEaseElasticOut::create(v43, 0.60000002);
cocos2d::CCNode::runAction((CCLightFlash *)DialogLayer->m_mainLayer, (cocos2d::CCPoint)v44, v45, 1.0, v51);
v46 = (float)DialogLayer->getOpacity(&DialogLayer->cocos2d::CCRGBAProtocol);
if ( v46 > 0.0 )
{
DialogLayer->setOpacity(&DialogLayer->cocos2d::CCRGBAProtocol, 0);
v47 = cocos2d::CCFadeTo::create(0.14, (int)v46);
cocos2d::CCNode::runAction((CCLightFlash *)DialogLayer, (cocos2d::CCPoint)v47, v48, 1.0, v52);
}
if ( v31 )
{
v49 = v32;
if ( v30 + 1 >= 0x1000 )
{
v32 = *((char **)v32 - 1);
if ( (unsigned __int64)(v49 - v32 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v32);
}
if ( v64 > 0xF )
{
v50 = v62[0];
if ( v64 + 1 >= 0x1000 )
{
v50 = *((void **)v62[0] - 1);
if ( (unsigned __int64)((char *)v62[0] - (char *)v50 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v50);
}
}
else
{
v5 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v53 = (void **)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v53);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v5 = (GameStatsManager *)qword_1406C2EE8;
}
m_levelList = a1->m_levelList;
v7 = GJLevelList::completedLevels(m_levelList);
m_levelsToClaim = m_levelList->m_levelsToClaim;
m_diamonds = m_levelList->m_diamonds;
if ( m_diamonds > 0
&& m_levelsToClaim > 0
&& v7 >= m_levelsToClaim
&& !GameStatsManager::hasClaimedListReward(v5, m_levelList) )
{
v10 = cocos2d::CCString::createWithFormat("lr_%i", m_levelList->m_listID);
v11 = cocos2d::CCString::getCString(v10);
*(_OWORD *)Block = 0;
v60 = 0;
v61 = 0;
v12 = -1;
do
++v12;
while ( v11[v12] );
sub_14003A930(Block, v11, v12);
v13 = cocos2d::CCString::createWithFormat("%i", m_diamonds);
cocos2d::CCDictionary::setObject(v5->m_completedLists, v13, Block);
if ( v61 > 0xF )
{
v14 = Block[0];
if ( v61 + 1 >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
v60 = 0;
v61 = 15;
LOBYTE(Block[0]) = 0;
GameStatsManager::incrementStat(v5, "13", m_diamonds);
GameStatsManager::incrementStat(v5, "41", 1);
v53 = v62;
v62[1] = (void *)26471;
v63 = 10;
v64 = 15;
v62[0] = (void *)0x6F2E3230646C6F67LL;
v15 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
*(_QWORD *)v54 = operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(*(FMODAudioEngine **)v54);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v15 = qword_1406C2E88;
}
FMODAudioEngine::playEffect_1(v15, (__int64)v62);
v16 = a1->m_levelList->m_diamonds;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v54);
v18 = CurrencyRewardLayer::create(0, 0, 0, v16, Icon, 0, Icon, 0, v17, (CurrencyRewardType)0, 0.0, 1.0);
a1->addChild_0(a1, v18, 14);
}
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[12].getTag)(a2, 0);
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[4].update)(a2, 0);
}
}