//
// SecretRewardsLayer::onSpecialItem from 0x14056c540 to 0x14056c95f (1055 bytes)
//
// 3 xrefs:
// > SecretRewardsLayer::onChestType @ 0x14056aaae
// > ??> @ 0x14092c66c
// > ??> @ 0x14092c678
//
// 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:34:20 +0000
//
// Hidden C++ exception states: #wind=5
__int64 __fastcall SecretRewardsLayer::onSpecialItem(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v5; // eax
int v6; // edi
__int64 v7; // rcx
__int64 v8; // rcx
signed int v9; // esi
cocos2d::CCArray *v10; // rbx
int v11; // edi
const char *v12; // r8
cocos2d::CCString *v13; // rax
const char *CString; // rax
size_t v15; // r8
void **v16; // rax
cocos2d::CCLayerColor *DialogLayer; // rsi
__int64 v18; // rcx
__int64 v19; // rax
__int64 v20; // rdi
__int64 v21; // rbx
__int64 v22; // rax
__int64 v23; // rcx
__int64 v24; // rcx
__int64 v25; // rdi
_QWORD *v26; // rbx
cocos2d::CCObject *v27; // rcx
__int16 v28; // [rsp+30h] [rbp-69h] BYREF
char v29; // [rsp+32h] [rbp-67h]
__int128 *v30; // [rsp+40h] [rbp-59h] BYREF
__int128 v31; // [rsp+48h] [rbp-51h] BYREF
__int64 v32; // [rsp+58h] [rbp-41h]
__int64 v33; // [rsp+60h] [rbp-39h]
__int128 *v34; // [rsp+68h] [rbp-31h] BYREF
__int128 v35; // [rsp+70h] [rbp-29h] BYREF
__int64 v36; // [rsp+80h] [rbp-19h]
__int64 v37; // [rsp+88h] [rbp-11h]
__int128 Src; // [rsp+90h] [rbp-9h]
__int64 v39; // [rsp+A0h] [rbp+7h]
__int64 v40; // [rsp+A8h] [rbp+Fh]
result = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
Src = 0;
v39 = 0;
v40 = 15;
LOBYTE(Src) = 0;
switch ( (_DWORD)result )
{
case 6:
v5 = *(_DWORD *)"0004";
v6 = 50;
break;
case 7:
v5 = *(_DWORD *)"0005";
v6 = 100;
break;
case 8:
v5 = *(_DWORD *)"0006";
v6 = 200;
break;
default:
return result;
}
v39 = 4;
LODWORD(Src) = v5;
BYTE4(Src) = 0;
v7 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v30 = (__int128 *)operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v7 = qword_14090BFE0;
}
v9 = cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v7 + 864));
if ( v9 >= v6 )
{
v34 = &v31;
v32 = 4;
v33 = 15;
v31 = Src;
v23 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v30 = (__int128 *)operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v23 = qword_14090BFE0;
}
result = GameStatsManager::unlockSpecialChest(v23, (__int64)&v31);
v25 = result;
if ( result )
{
SecretRewardsLayer::switchToOpenedState(v24, a2);
v26 = RewardUnlockLayer::create(*(_DWORD *)(v25 + 64), 0);
(*(void (__fastcall **)(__int64, _QWORD *, __int64))(*(_QWORD *)a1 + 456LL))(a1, v26, 100);
v27 = (cocos2d::CCObject *)v26[88];
if ( v27 )
cocos2d::CCObject::release(v27);
v26[88] = v25;
cocos2d::CCObject::retain((cocos2d::CCObject *)v25);
if ( !*(_BYTE *)(v25 + 80) || (result = *((unsigned int *)v26 + 174), *(_DWORD *)(v25 + 64) == (_DWORD)result) )
{
(*(void (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)v26[90] + 336LL))(v26[90], 0);
(*(void (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)v26[90] + 936LL))(v26[90], 0);
result = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)v26[89] + 336LL))(v26[89], 0);
*((_BYTE *)v26 + 700) = 1;
if ( *((_BYTE *)v26 + 701) )
return (__int64)RewardUnlockLayer::playRewardEffect((cocos2d::CCNode *)v26);
}
}
}
else
{
v10 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v11 = v6 - v9;
v30 = &v35;
v28 = -1;
v29 = -1;
v12 = "Chests";
if ( v11 == 1 )
v12 = "Chest";
v13 = cocos2d::CCString::createWithFormat(
"Unlock %i more %s, and you can collect this bonus.",
v11,
v12);
CString = cocos2d::CCString::getCString(v13);
v35 = 0;
v36 = 0;
v37 = 0;
v15 = -1;
do
++v15;
while ( CString[v15] );
sub_14003D230(&v35, CString, v15);
v32 = 13;
v33 = 15;
strcpy((char *)&v31, "The Keymaster");
HIWORD(v31) = 0;
v16 = DialogObject::create((__int64)&v31, (__int64)&v35, 2, 1.0, 0, (__int64)&v28);
cocos2d::CCArray::addObject(v10, (struct cocos2d::CCObject *)v16);
DialogLayer = DialogLayer::createDialogLayer(0, (__int64)v10, 2u);
(*(void (__fastcall **)(__int64, cocos2d::CCLayerColor *, __int64))(*(_QWORD *)a1 + 456LL))(a1, DialogLayer, 100);
v19 = cocos2d::CCDirector::sharedDirector(v18);
cocos2d::CCDirector::getWinSize(v19, &v30);
v20 = **((_QWORD **)DialogLayer + 70);
v21 = *((_QWORD *)DialogLayer + 70);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v34, *(float *)&v30 * 0.5, *((float *)&v30 + 1) * 0.5);
(*(void (__fastcall **)(__int64, __int64))(v20 + 184))(v21, v22);
return DialogLayer::animateInRandomSide(DialogLayer);
}
return result;
}