//
// LevelListLayer::onClaimReward from 0xa737c8 to 0xa73c6c (1188 bytes)
//
// 3 xrefs:
// > ??> @ 0x49638
// > LevelListLayer::updateStatsArt @ 0xa75400
// > ??> @ 0x122a568
//
// 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
//
void LevelListLayer::onClaimReward(LevelListLayer *a1, cocos2d::CCObject *a2)
{
int m_levelsToClaim; // w19
int v5; // w19
char *v6; // x1
cocos2d::CCString *v7; // x0
char *CString; // x0
DialogObject *v9; // x0
DialogLayer *v10; // x22
void *v11; // x0
void *v12; // x0
void *v13; // x0
void *v14; // x0
GameStatsManager *v15; // x0
FMODAudioEngine *v16; // x19
void *v17; // x0
float v18; // s2
float v19; // s3
CurrencyRewardLayer *v20; // x0
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
unsigned int *v27; // x1
int v28; // w2
unsigned int *v29; // x2
int v30; // w1
int m_diamonds; // [xsp+58h] [xbp+48h]
__int64 v32; // [xsp+78h] [xbp+68h] BYREF
__int64 v33; // [xsp+80h] [xbp+70h] BYREF
__int64 v34; // [xsp+88h] [xbp+78h] BYREF
cocos2d::CCPoint v35; // [xsp+90h] [xbp+80h] BYREF
cocos2d::CCPoint v36; // 0:s0.4,4:s1.4
m_levelsToClaim = a1->m_levelList->m_levelsToClaim;
v5 = m_levelsToClaim - GJLevelList::completedLevels(a1->m_levelList);
if ( v5 <= 0 )
{
v15 = GameStatsManager::sharedState();
if ( GameStatsManager::claimListReward(v15, a1->m_levelList) )
{
v16 = FMODAudioEngine::sharedEngine();
sub_D153B8((int)&v35, "gold02.ogg");
FMODAudioEngine::playEffect((__int64)v16, (__int64)&v35);
v17 = (void *)(*(_QWORD *)&v35 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v35 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v29 = (unsigned int *)(*(_QWORD *)&v35 - 8LL);
do
v30 = __ldaxr(v29);
while ( __stlxr(v30 - 1, v29) );
}
else
{
v30 = *(_DWORD *)(*(_QWORD *)&v35 - 8LL);
*(_DWORD *)(*(_QWORD *)&v35 - 8LL) = v30 - 1;
}
if ( v30 <= 0 )
operator delete(v17);
}
m_diamonds = a1->m_levelList->m_diamonds;
cocos2d::CCPoint::CCPoint(&v35, &a1->m_rewardPosition);
v36.x = 0.0;
v36.y = 1.0;
v20 = CurrencyRewardLayer::create(0, 0, 0, m_diamonds, Icon, 0, Icon, 0, v36, (CurrencyRewardType)&v35, v18, v19);
a1->addChild_0(a1, v20, 14);
}
a2->__vftable[13].copyWithZone(a2, nullptr);
((void (__fastcall *)(cocos2d::CCObject *, _QWORD))a2->__vftable[4].~CCObject)(a2, 0);
}
else
{
if ( v5 == 1 )
v6 = "level";
else
v6 = "levels";
sub_D153B8((int)&v32, v6);
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Complete %i more %s from this list to claim"
" the reward!",
(const char *)(unsigned int)v5,
v32);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_D153B8((int)&v33, CString);
sub_D153B8((int)&v34, "The Mechanic");
sub_D18D28(&v35);
v9 = (DialogObject *)DialogObject::create(1.0, (__int64)&v34, (__int64)&v35, 37, 0, (int)&unk_FFFFFF);
v10 = DialogLayer::create(v9, (int)&byte_4);
v11 = (void *)(*(_QWORD *)&v35 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v35 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(*(_QWORD *)&v35 - 8LL);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(*(_QWORD *)&v35 - 8LL);
*(_DWORD *)(*(_QWORD *)&v35 - 8LL) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v11);
}
v12 = (void *)(v34 - 24);
if ( (__int64 *)(v34 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v34 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v34 - 8);
*(_DWORD *)(v34 - 8) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v12);
}
DialogLayer::addToMainScene(v10);
DialogLayer::updateChatPlacement(v10, Center);
DialogLayer::animateIn(v10, FromCenter);
v13 = (void *)(v33 - 24);
if ( (__int64 *)(v33 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(v33 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(_DWORD *)(v33 - 8);
*(_DWORD *)(v33 - 8) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v13);
}
v14 = (void *)(v32 - 24);
if ( (__int64 *)(v32 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v27 = (unsigned int *)(v32 - 8);
do
v28 = __ldaxr(v27);
while ( __stlxr(v28 - 1, v27) );
}
else
{
v28 = *(_DWORD *)(v32 - 8);
*(_DWORD *)(v32 - 8) = v28 - 1;
}
if ( v28 <= 0 )
operator delete(v14);
}
}
}