//
// GameStatsManager::unlockSpecialChest from 0x100336874 to 0x100336974 (256 bytes)
//
// 10 xrefs:
// > GJShopLayer::dialogClosed @ 0x10014d6dc
// > SupportLayer::onGetReward @ 0x100192d10
// > SecretRewardsLayer::onSpecialItem @ 0x1002ea52c
// > SecretLayer3::onChest01 @ 0x10030fbf4
// > SecretLayer3::onChest02 @ 0x10030fce0
// > GameStatsManager::unlockOnlineChest @ 0x1003348dc
// > GameStatsManager::unlockGauntletChest @ 0x1003369fc
// > GameStatsManager::unlockPathChest @ 0x100336b94
// > SecretLayer4::onChest01 @ 0x100355a38
// > FollowRewardPage::onSpecialItem @ 0x100425890
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
GJRewardItem *__fastcall GameStatsManager::unlockSpecialChest(GameStatsManager *a1, __int64 a2)
{
bool isSpecialChestUnlocked; // w0
bool v5; // w21
GJRewardItem *v6; // x21
void *v8[2]; // [xsp+0h] [xbp-60h] BYREF
__int64 v9; // [xsp+10h] [xbp-50h]
void *__p[2]; // [xsp+20h] [xbp-40h] BYREF
__int64 v11; // [xsp+30h] [xbp-30h]
if ( *(char *)(a2 + 23) < 0 )
{
sub_1000097D0(__p, *(void **)a2, *(_QWORD *)(a2 + 8));
}
else
{
*(_OWORD *)__p = *(_OWORD *)a2;
v11 = *(_QWORD *)(a2 + 16);
}
isSpecialChestUnlocked = GameStatsManager::isSpecialChestUnlocked((__int64)a1, (char *)__p);
v5 = isSpecialChestUnlocked;
if ( SHIBYTE(v11) < 0 )
{
operator delete(__p[0]);
if ( v5 )
return nullptr;
}
else if ( isSpecialChestUnlocked )
{
return nullptr;
}
if ( *(char *)(a2 + 23) < 0 )
{
sub_1000097D0(v8, *(void **)a2, *(_QWORD *)(a2 + 8));
}
else
{
*(_OWORD *)v8 = *(_OWORD *)a2;
v9 = *(_QWORD *)(a2 + 16);
}
v6 = (GJRewardItem *)cocos2d::CCDictionary::objectForKey_1(a1->m_allSpecialChests, v8);
if ( SHIBYTE(v9) < 0 )
operator delete(v8[0]);
if ( v6 )
{
GameStatsManager::preProcessReward(a1, v6);
GameStatsManager::registerRewardsFromItem(a1, v6);
cocos2d::CCDictionary::setObject_1(a1->m_miscChests, v6, a2);
}
return v6;
}