//
// SecretRewardsLayer::onSpecialItem from 0xb9e688 to 0xb9e9c0 (824 bytes)
//
// 2 xrefs:
// > SecretRewardsLayer::onChestType @ 0xba1e28
// > ??> @ 0xce638
//
// This function is hookable on this platform (idp: arm, 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 13:02:45 +0000
//
__int64 __fastcall SecretRewardsLayer::onSpecialItem(SecretRewardsLayer *this, cocos2d::CCObject *a2)
{
int v4; // w0
__int64 *v6; // x0
int v7; // w21
__int64 v8; // x0
GameStatsManager *v9; // x0
int v10; // w24
cocos2d::CCArray *v11; // x20
unsigned int v12; // w21
char *v13; // x2
cocos2d::CCString *v14; // x0
size_t v15; // x0
cocos2d::CCObject *v16; // x0
DialogLayer *v17; // x20
GameStatsManager *v18; // x24
unsigned int *v19; // x21
RewardsPage *v20; // x2
RewardUnlockLayer *v21; // x20
char *CString; // [xsp+48h] [xbp+48h]
__int64 v23; // [xsp+58h] [xbp+58h] BYREF
size_t v24; // [xsp+60h] [xbp+60h]
void *v25; // [xsp+68h] [xbp+68h]
__int64 v26[2]; // [xsp+70h] [xbp+70h] BYREF
void *v27; // [xsp+80h] [xbp+80h]
__int64 v28[2]; // [xsp+88h] [xbp+88h] BYREF
void *v29; // [xsp+98h] [xbp+98h]
__int64 v30; // [xsp+A0h] [xbp+A0h] BYREF
size_t v31; // [xsp+A8h] [xbp+A8h]
void *v32; // [xsp+B0h] [xbp+B0h]
v4 = (*(__int64 (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2) - 5;
v23 = 0;
v24 = 0;
v25 = nullptr;
switch ( v4 )
{
case 2:
v6 = std::string::assign(&v23, "0005");
v7 = 100;
break;
case 3:
v6 = std::string::assign(&v23, "0006");
v7 = 200;
break;
case 1:
v6 = std::string::assign(&v23, "0004");
v7 = 50;
break;
default:
goto LABEL_4;
}
v8 = GameStatsManager::sharedState((GameStatsManager *)v6);
v9 = (GameStatsManager *)cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v8 + 760));
v10 = (int)v9;
if ( v7 <= (int)v9 )
{
v18 = (GameStatsManager *)GameStatsManager::sharedState(v9);
v30 = 0;
v31 = 0;
v32 = nullptr;
if ( (v23 & 1) != 0 )
{
std::string::__init(&v30, v25, v24);
}
else
{
v32 = v25;
v30 = v23;
v31 = v24;
}
v19 = (unsigned int *)GameStatsManager::unlockSpecialChest(v18, (char *)&v30);
if ( (v30 & 1) != 0 )
operator delete(v32);
if ( v19 )
{
SecretRewardsLayer::switchToOpenedState(this, a2);
v21 = (RewardUnlockLayer *)RewardUnlockLayer::create((RewardUnlockLayer *)v19[16], nullptr, v20);
(*(void (__fastcall **)(SecretRewardsLayer *, RewardUnlockLayer *, __int64))(*(_QWORD *)this + 464LL))(
this,
v21,
100);
RewardUnlockLayer::showCollectReward(v21, (GJRewardItem *)v19);
}
LABEL_4:
if ( (v23 & 1) == 0 )
return _stack_chk_guard;
LABEL_15:
operator delete(v25);
return _stack_chk_guard;
}
v11 = (cocos2d::CCArray *)cocos2d::CCArray::create(v9);
v12 = v7 - v10;
v26[0] = 0;
v26[1] = 0;
v27 = nullptr;
std::string::__init(v26, "The Keymaster", 0xDu);
if ( v12 == 1 )
v13 = "Chest";
else
v13 = "Chests";
v14 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Unlock %i more %s, and you can collect this bonus.",
(const char *)v12,
v13);
CString = (char *)cocos2d::CCString::getCString(v14);
v28[0] = 0;
v28[1] = 0;
v29 = nullptr;
v15 = strlen(CString);
std::string::__init(v28, CString, v15);
v16 = (cocos2d::CCObject *)DialogObject::create((char *)v26, (char *)v28, 2, 0, 0xFFFFFF, 1.0);
cocos2d::CCArray::addObject(v11, v16);
if ( (v28[0] & 1) != 0 )
operator delete(v29);
if ( (v26[0] & 1) != 0 )
operator delete(v27);
v17 = (DialogLayer *)DialogLayer::createWithObjects(v11, (cocos2d::CCArray *)((char *)&dword_0 + 2));
(*(void (__fastcall **)(SecretRewardsLayer *, DialogLayer *, __int64))(*(_QWORD *)this + 464LL))(this, v17, 100);
DialogLayer::updateChatPlacement((__int64)v17, 0);
DialogLayer::animateInRandomSide(v17);
if ( (v23 & 1) != 0 )
goto LABEL_15;
return _stack_chk_guard;
}