//
// GameStatsManager::unlockGoldChest from 0x100052d40 to 0x100052e96 (342 bytes)
//
// 1 xrefs:
// > SecretRewardsLayer::onGoldChest @ 0x10070f1a6
//
// 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::unlockGoldChest(__int64 a1, __m128 a2)
{
__int64 v2; // rax
__int64 v3; // rbx
int Stat; // eax
__int64 v5; // r14
__int64 v6; // rax
const char *CString; // r12
size_t v8; // rax
size_t v9; // r15
char *v10; // r13
size_t v12; // r14
char v13; // [rsp+0h] [rbp-50h]
__int64 v14; // [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, "43", a2);
if ( Stat <= 0 )
return 0;
GameStatsManager::setStat(a1, "43", Stat - 1, a2);
GameStatsManager::preProcessReward(a1, v3, a2);
GameStatsManager::registerRewardsFromItem(a1, v3, a2);
v5 = *(_QWORD *)(a1 + 760);
v6 = sub_10088E820("%i", v13);
CString = (const char *)cocos2d::CCString::getCString(v6);
v8 = strlen(CString);
if ( v8 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100003630();
v9 = v8;
if ( v8 >= 0x17 )
{
v14 = v5;
v12 = 26;
if ( (v8 | 7) != 0x17 )
v12 = (v8 | 7) + 1;
v10 = (char *)operator new(v12);
__p = v10;
__dst[0] = v12 + 1;
v5 = v14;
__dst[1] = v9;
goto LABEL_13;
}
LOBYTE(__dst[0]) = 2 * v8;
v10 = (char *)__dst + 1;
if ( v8 )
LABEL_13:
memmove(v10, CString, v9);
v10[v9] = 0;
cocos2d::CCDictionary::setObject(v5, v3, __dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
return v3;
}