//
// GameStatsManager::unlockSecretChest from 0x1402eed40 to 0x1402eef0a (458 bytes)
//
// 2 xrefs:
// > SecretRewardsLayer::onSelectItem @ 0x14056bfb0
// > ??> @ 0x14091e140
//
// 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:29:56 +0000
//
// Hidden C++ exception states: #wind=1
struct cocos2d::CCObject *__fastcall GameStatsManager::unlockSecretChest(__int64 a1, int a2)
{
__int64 v2; // rsi
struct cocos2d::CCObject *v4; // rbx
int Stat; // eax
int v6; // edx
int v7; // ecx
cocos2d::CCString *v8; // rax
const char *CString; // rax
size_t v10; // r8
void *v11; // rcx
void *Block[2]; // [rsp+30h] [rbp-38h] BYREF
__int128 v14; // [rsp+40h] [rbp-28h]
v2 = a2;
if ( GameStatsManager::isSecretChestUnlocked(a1) )
return nullptr;
v4 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(a1 + 352), v2);
if ( !v4 )
return nullptr;
Stat = GameStatsManager::getStat(a1, &word_140737620);
v6 = *((_DWORD *)v4 + 14);
if ( v6 <= 6000 )
{
if ( v6 <= 5000 )
{
if ( v6 <= 4000 )
{
if ( v6 <= 3000 )
{
if ( v6 <= 2000 )
{
v7 = 1;
if ( v6 > 1000 )
v7 = 5;
}
else
{
v7 = 10;
}
}
else
{
v7 = 25;
}
}
else
{
v7 = 50;
}
}
else
{
v7 = 100;
}
}
else
{
v7 = 1;
}
if ( Stat < v7 )
return nullptr;
GameStatsManager::setStat(a1, &word_140737620, Stat - v7);
GameStatsManager::preProcessReward(a1, (__int64)v4);
GameStatsManager::registerRewardsFromItem(a1, v4);
v8 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)v2);
CString = cocos2d::CCString::getCString(v8);
*(_OWORD *)Block = 0;
v14 = 0;
v10 = -1;
do
++v10;
while ( CString[v10] );
sub_14003D230(Block, CString, v10);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 864), v4, Block);
if ( *((_QWORD *)&v14 + 1) > 0xFu )
{
v11 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v14 + 1) + 1LL) >= 0x1000 )
{
v11 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v11 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v11);
}
return v4;
}