//
// GameStatsManager::unlockSecretChest from 0x100052b50 to 0x100052cfa (426 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onSelectItem @ 0x1007114e9
//
// 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:19:35 +0000
//
__int64 __fastcall GameStatsManager::unlockSecretChest(__int64 a1, __m128 a2)
{
__int64 v2; // rax
__int64 v3; // rbx
int Stat; // eax
int v5; // ecx
int v6; // edx
bool v7; // cc
int v8; // eax
__int64 v10; // r15
__int64 v11; // rax
const char *CString; // r12
size_t v13; // rax
size_t v14; // r14
char *v15; // r13
size_t v16; // r15
char v17; // [rsp+0h] [rbp-50h]
__int64 v18; // [rsp+8h] [rbp-48h]
_QWORD __dst[2]; // [rsp+10h] [rbp-40h] BYREF
void *__p; // [rsp+20h] [rbp-30h]
if ( GameStatsManager::isSecretChestUnlocked(a1) )
return 0;
v2 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(a1 + 344));
if ( !v2 )
return 0;
v3 = v2;
Stat = GameStatsManager::getStat(a1, "21", a2);
v5 = *(_DWORD *)(v3 + 56);
v6 = 1;
if ( v5 <= 6000 )
{
v6 = 100;
if ( v5 <= 5000 )
{
v6 = 50;
if ( v5 <= 4000 )
{
v6 = 25;
if ( v5 <= 3000 )
{
v6 = 10;
if ( v5 <= 2000 )
v6 = 4 * (v5 >= 1001) + 1;
}
}
}
}
v7 = Stat < v6;
v8 = Stat - v6;
if ( v7 )
return 0;
GameStatsManager::setStat(a1, "21", v8, a2);
GameStatsManager::preProcessReward(a1, v3, a2);
GameStatsManager::registerRewardsFromItem(a1, v3, a2);
v10 = *(_QWORD *)(a1 + 760);
v11 = sub_10088E820("%i", v17);
CString = (const char *)cocos2d::CCString::getCString(v11);
v13 = strlen(CString);
if ( v13 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v14 = v13;
if ( v13 >= 0x17 )
{
v18 = v10;
v16 = 26;
if ( (v13 | 7) != 0x17 )
v16 = (v13 | 7) + 1;
v15 = (char *)operator new(v16);
__p = v15;
__dst[0] = v16 + 1;
v10 = v18;
__dst[1] = v14;
goto LABEL_19;
}
LOBYTE(__dst[0]) = 2 * v13;
v15 = (char *)__dst + 1;
if ( v13 )
LABEL_19:
memmove(v15, CString, v14);
v15[v14] = 0;
cocos2d::CCDictionary::setObject(v10, v3, __dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
return v3;
}