//
// GameStatsManager::isItemUnlocked from 0x10006b9a0 to 0x10006bb7b (475 bytes)
//
// 30 xrefs:
// > GameStatsManager::isPathUnlocked @ 0x10006b99b
// > GameStatsManager::trySelectActivePath @ 0x10006bc10
// > GameStatsManager::trySelectActivePath @ 0x10006bc7c
// > GameStatsManager::trySelectActivePath @ 0x10006bcdb
// > GameStatsManager::trySelectActivePath @ 0x10006bd3a
// > GameStatsManager::trySelectActivePath @ 0x10006bd99
// > GameStatsManager::trySelectActivePath @ 0x10006bdf8
// > GameStatsManager::trySelectActivePath @ 0x10006be57
// > GameStatsManager::trySelectActivePath @ 0x10006beb6
// > GameStatsManager::trySelectActivePath @ 0x10006bf15
// > GameStatsManager::trySelectActivePath @ 0x10006bf74
// > GameStatsManager::trySelectActivePath @ 0x10006bfcf
// > GameStatsManager::recountSpecialStats @ 0x100076b47
// > GameStatsManager::isItemEnabled @ 0x1000778a8
// > GameOptionsLayer::setupOptions @ 0x1002b143c
// > GameOptionsLayer::onPracticeMusicSync @ 0x1002b181c
// > GJPathSprite::updateState @ 0x1002fe9d0
// > GJPathPage::init @ 0x1002ff186
// > GameManager::isIconUnlocked @ 0x100377fbb
// > GameManager::isColorUnlocked @ 0x10037862c
// > GameManager::dataLoaded @ 0x1003899ca
// > LevelSelectLayer::init @ 0x100431c39
// > LevelPage::onSecretDoor @ 0x100436d75
// > SecretLayer3::onClick @ 0x1004a4e10
// > SecretLayer3::onClick @ 0x1004a4e3d
// > SecretLayer3::onClick @ 0x1004a4e6a
// > GauntletSelectLayer::onPlay @ 0x1005729c5
// > SongInfoLayer::init @ 0x100601939
// > SongInfoLayer::onMenuMusic @ 0x100601caf
// > SongInfoLayer::onPracticeMusic @ 0x100601d3f
//
// 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
//
// local variable allocation has failed, the output may be wrong!
bool __fastcall GameStatsManager::isItemUnlocked(GameStatsManager *a1, UnlockType a2, int a3)
{
double v3; // xmm0_8
cocos2d::CCDictionary *m_allStoreItems; // r15
__int64 v7; // rsi
__int64 v8; // r15
GameStatsManager *v9; // rax
char isSecretChestUnlocked; // r15
cocos2d::CCDictionary *m_allTreasureRoomChestItems; // r15
__int64 v12; // rsi
cocos2d::CCString *v13; // rax
int v14; // r15d
GameStatsManager *v15; // rax
cocos2d::CCDictionary *m_allSpecialChestItems; // r12
cocos2d::CCString *v17; // r14
GameStatsManager *v18; // rbx
const char *CString; // r15
size_t v20; // rax
size_t v21; // r14
char *v22; // r12
size_t v23; // r13
_QWORD __dst[2]; // [rsp+8h] [rbp-58h] BYREF
void *v26; // [rsp+18h] [rbp-48h]
size_t v27[2]; // [rsp+20h] [rbp-40h] BYREF
void *__p; // [rsp+30h] [rbp-30h]
m_allStoreItems = GameStatsManager::sharedState()->m_allStoreItems;
GameStatsManager::getItemKey(v27, v3, *(__int64 *)&a2, a3, a2);
v7 = (__int64)v27;
v8 = cocos2d::CCDictionary::objectForKey_1(m_allStoreItems, v27);
if ( (v27[0] & 1) != 0 )
operator delete(__p);
if ( !v8
|| (v9 = GameStatsManager::sharedState(),
v7 = (unsigned int)(*(_DWORD *)(v8 + 316) - *(_DWORD *)(v8 + 320)),
isSecretChestUnlocked = 1,
!GameStatsManager::isStoreItemUnlocked(v9, v7)) )
{
m_allTreasureRoomChestItems = GameStatsManager::sharedState()->m_allTreasureRoomChestItems;
GameStatsManager::getItemKey(v27, v3, v7, a3, a2);
v12 = (__int64)v27;
v13 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(m_allTreasureRoomChestItems, v27);
v14 = cocos2d::CCString::intValue(v13);
if ( (v27[0] & 1) != 0 )
operator delete(__p);
if ( v14 <= 0 )
{
isSecretChestUnlocked = 0;
}
else
{
v15 = GameStatsManager::sharedState();
v12 = (unsigned int)v14;
isSecretChestUnlocked = GameStatsManager::isSecretChestUnlocked(v15, v14);
if ( isSecretChestUnlocked )
return isSecretChestUnlocked;
}
m_allSpecialChestItems = GameStatsManager::sharedState()->m_allSpecialChestItems;
GameStatsManager::getItemKey(v27, v3, v12, a3, a2);
v17 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey_1(m_allSpecialChestItems, v27);
if ( (v27[0] & 1) != 0 )
operator delete(__p);
if ( v17 )
{
v18 = GameStatsManager::sharedState();
CString = cocos2d::CCString::getCString(v17);
v20 = strlen(CString);
if ( v20 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v3);
v21 = v20;
if ( v20 >= 0x17 )
{
v23 = 26;
if ( (v20 | 7) != 0x17 )
v23 = (v20 | 7) + 1;
v22 = (char *)operator new(v23);
v26 = v22;
__dst[0] = v23 + 1;
__dst[1] = v21;
}
else
{
LOBYTE(__dst[0]) = 2 * v20;
v22 = (char *)__dst + 1;
if ( !v20 )
{
LABEL_22:
v22[v21] = 0;
isSecretChestUnlocked = GameStatsManager::isSpecialChestUnlocked(v18, __dst);
if ( (__dst[0] & 1) != 0 )
operator delete(v26);
return isSecretChestUnlocked;
}
}
memmove(v22, CString, v21);
goto LABEL_22;
}
}
return isSecretChestUnlocked;
}