//
// SecretRewardsLayer::onSpecialItem from 0x10070f880 to 0x10070fc10 (912 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onChestType @ 0x10070eda5
//
// 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 12:36:06 +0000
//
void __fastcall SecretRewardsLayer::onSpecialItem(__int64 a1, __int64 a2, double a3, double a4, __m128 a5)
{
int v6; // eax
__m128 v7; // xmm0
int v8; // r15d
__int64 v9; // rdi
__int64 v10; // r14
__int64 v11; // rax
const char *CString; // r15
size_t v13; // rax
std::string::size_type v14; // r12
char *data; // r13
__int64 v16; // r15
__int64 v17; // r15
_DWORD *v18; // r12
__int64 v19; // rax
unsigned int *v20; // rax
_QWORD *v21; // rbx
unsigned __int64 v22; // r15
__int64 v23; // r13
__int64 v24; // rbx
char *v25; // r14
size_t v26; // rbx
char *v27; // rax
__int64 v28; // rbx
char *v29; // r14
char v30; // [rsp+0h] [rbp-B0h]
__int64 v31; // [rsp+8h] [rbp-A8h]
__int128 v32; // [rsp+10h] [rbp-A0h] BYREF
void *__p; // [rsp+20h] [rbp-90h]
std::string v34; // [rsp+28h] [rbp-88h] BYREF
std::string __dst; // [rsp+40h] [rbp-70h] BYREF
__int64 v36; // [rsp+58h] [rbp-58h]
std::string v37; // [rsp+60h] [rbp-50h] BYREF
__int16 v38; // [rsp+84h] [rbp-2Ch] BYREF
char v39; // [rsp+86h] [rbp-2Ah]
v6 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 64LL))(a2);
v7 = 0;
memset(&v37, 0, sizeof(v37));
switch ( v6 )
{
case 8:
v8 = 200;
std::string::assign(&v37, "0006");
break;
case 7:
v8 = 100;
std::string::assign(&v37, "0005");
break;
case 6:
v8 = 50;
std::string::assign(&v37, "0004");
break;
default:
goto LABEL_33;
}
v9 = *(_QWORD *)(GameStatsManager::sharedState() + 760);
if ( v8 > (int)cocos2d::CCDictionary::count(v9) )
{
v36 = a1;
v10 = sub_1007FE900(v9);
v34.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)26;
strcpy(v34.__r_.__value_.__s.__data_, "The Keymaster");
v11 = sub_10088E820("Unlock %i more %s, and you can collect this bonus.", v30);
CString = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(CString);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v14 = v13;
if ( v13 >= 0x17 )
{
v26 = 26;
if ( (v13 | 7) != 0x17 )
v26 = (v13 | 7) + 1;
data = (char *)operator new(v26);
__dst.__r_.__value_.__r.__words[2] = (std::string::size_type)data;
__dst.__r_.__value_.__r.__words[0] = v26 | 1;
__dst.__r_.__value_.__l.__size_ = v14;
}
else
{
__dst.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)(2 * v13);
data = __dst.__r_.__value_.__s.__data_;
if ( !v13 )
goto LABEL_28;
}
memmove(data, CString, v14);
LABEL_28:
data[v14] = 0;
v27 = DialogObject::create(&v34, &__dst, 2, 0, 0xFFFFFF, 1.0);
sub_1007FEBF0(v10, v27);
v28 = v36;
if ( (*(_BYTE *)&__dst.__r_.__value_.__s.0 & 1) != 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v34.__r_.__value_.__l.__data_);
v29 = DialogLayer::createWithObjects(v10, 2u);
(*(void (__fastcall **)(__int64, char *, __int64))(*(_QWORD *)v28 + 464LL))(v28, v29, 100);
DialogLayer::updateChatPlacement((__int64)v29, 0);
DialogLayer::animateInRandomSide((__int64)v29);
goto LABEL_33;
}
v16 = GameStatsManager::sharedState();
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v32, v37.__r_.__value_.__l.__data_, v37.__r_.__value_.__l.__size_);
}
else
{
__p = v37.__r_.__value_.__l.__data_;
v7 = *(__m128 *)&v37.__r_.__value_.__l.0;
v32 = *(_OWORD *)&v37.__r_.__value_.__l.0;
}
v17 = GameStatsManager::unlockSpecialChest(v16, (__int64)&v32, v7);
if ( (v32 & 1) != 0 )
operator delete(__p);
if ( v17 )
{
v31 = v17;
v18 = (_DWORD *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 1072LL))(a2);
GJChestSprite::switchToState(v18, 4, 1, *(double *)v7.i64, a4, a5);
v19 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)v18 + 488LL))(v18);
v36 = a1;
if ( v19 )
{
v20 = *(unsigned int **)(v19 + 56);
if ( *v20 )
{
v21 = *((_QWORD **)v20 + 2);
v22 = (unsigned __int64)&v21[*v20 - 1];
do
{
v23 = *v21;
if ( !*v21 )
break;
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)v23 + 912LL))(*v21, 100);
v39 = -106;
v38 = -26986;
(*(void (__fastcall **)(__int64, __int16 *))(*(_QWORD *)v23 + 960LL))(v23, &v38);
++v21;
}
while ( (unsigned __int64)v21 <= v22 );
}
}
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a2 + 1056LL))(a2, 0);
v24 = v36;
v25 = RewardUnlockLayer::create(*(_DWORD *)(v31 + 64), 0);
(*(void (__fastcall **)(__int64, char *, __int64))(*(_QWORD *)v24 + 464LL))(v24, v25, 100);
RewardUnlockLayer::showCollectReward((__int64)v25, v31);
}
LABEL_33:
if ( (*(_BYTE *)&v37.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v37.__r_.__value_.__l.__data_);
}