//
// SecretRewardsLayer::onSelectItem from 0x100711450 to 0x10071173d (749 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::generateChestItems @ 0x10071109b
//
// 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::onSelectItem(_QWORD *a1, __int64 a2, __m128 a3, double a4, __m128 a5)
{
__int64 v6; // rax
int Stat; // ebx
unsigned int v8; // r12d
__int64 v9; // rax
int v10; // r13d
__int64 v11; // rax
int v12; // eax
int v13; // r15d
__int64 v14; // rax
__int64 v15; // rax
_DWORD *v16; // rbx
__int64 v17; // rax
unsigned int *v18; // rax
_QWORD *v19; // r13
_QWORD *v20; // r15
__int64 v21; // r12
char *v22; // rbx
__int64 v23; // rbx
__int64 v24; // rax
__int64 v25; // rax
__int64 CString; // rax
__int64 v27; // rax
const std::string::value_type *v28; // rax
int v29; // ebx
char *v30; // rax
__int64 v31; // rbx
__int64 v32; // [rsp+8h] [rbp-78h]
std::string v33; // [rsp+10h] [rbp-70h] BYREF
std::string v34; // [rsp+28h] [rbp-58h] BYREF
std::string v35; // [rsp+40h] [rbp-40h] BYREF
v6 = GameStatsManager::sharedState();
Stat = GameStatsManager::getStat(v6, "21", a3);
v8 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 64LL))(a2);
v9 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a2 + 1072LL))(a2);
v10 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v9 + 64LL))(v9);
v11 = GameStatsManager::sharedState();
v12 = GameStatsManager::keyCostForSecretChest(v11, v8);
v13 = v12 - Stat;
if ( v12 <= Stat )
{
v14 = GameStatsManager::sharedState();
v15 = GameStatsManager::unlockSecretChest(v14, a3);
if ( v15 )
{
v32 = v15;
*(_DWORD *)(v15 + 56) = v10;
v16 = (_DWORD *)(*(__int64 (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a2 + 1072LL))(a2, v8);
GJChestSprite::switchToState(v16, 4, 1, *(double *)a3.i64, a4, a5);
v17 = (*(__int64 (__fastcall **)(_DWORD *))(*(_QWORD *)v16 + 488LL))(v16);
if ( v17 )
{
v18 = *(unsigned int **)(v17 + 56);
if ( *v18 )
{
v19 = *((_QWORD **)v18 + 2);
v20 = &v19[*v18 - 1];
do
{
v21 = *v19;
if ( !*v19 )
break;
(*(void (__fastcall **)(_QWORD, __int64))(*(_QWORD *)v21 + 912LL))(*v19, 100);
v35.__r_.__value_.__s.__data_[1] = -106;
*(_WORD *)&v35.__r_.__value_.__l.0 = -26986;
(*(void (__fastcall **)(__int64, std::string *))(*(_QWORD *)v21 + 960LL))(v21, &v35);
++v19;
}
while ( v19 <= v20 );
}
}
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)a2 + 1056LL))(a2, 0);
v22 = RewardUnlockLayer::create(*(_DWORD *)(v32 + 64), 0);
(*(void (__fastcall **)(_QWORD *, char *, __int64))(*a1 + 464LL))(a1, v22, 100);
RewardUnlockLayer::showCollectReward((__int64)v22, v32);
v23 = a1[59];
v24 = GameStatsManager::sharedState();
GameStatsManager::getStat(v24, "21", a3);
v25 = sub_10088E820("%i", (char)a1);
CString = cocos2d::CCString::getCString(v25);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v23 + 928LL))(v23, CString);
SecretRewardsLayer::updateUnlockedLabel((__int64)a1);
}
}
else
{
*(_WORD *)&v35.__r_.__value_.__l.0 = 0;
if ( v12 == 1 )
{
std::string::assign(&v35, "You need a key to unlock this chest.");
}
else
{
v27 = sub_10088E820("You need %i more keys to unlock this chest", (char)a1);
v28 = (const std::string::value_type *)cocos2d::CCString::getCString(v27);
std::string::assign(&v35, v28);
}
v29 = 18;
if ( v13 <= 50 )
{
v29 = 17;
if ( v13 <= 25 )
v29 = 2 * (v13 >= 11) + 2;
}
v34.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)26;
strcpy(v34.__r_.__value_.__s.__data_, "The Keymaster");
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
sub_10001AD30(&v33, v35.__r_.__value_.__l.__data_, v35.__r_.__value_.__l.__size_);
else
v33 = v35;
v30 = DialogObject::create(&v34, &v33, v29, 0, 0xFFFFFF, 1.0);
v31 = DialogLayer::create((__int64)v30, 2u);
if ( (*(_BYTE *)&v33.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v33.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v34.__r_.__value_.__l.__data_);
DialogLayer::addToMainScene(v31, 2);
DialogLayer::updateChatPlacement(v31, 0);
DialogLayer::animateInRandomSide(v31);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v35.__r_.__value_.__l.__data_);
}
}