//
// GameStatsManager::isItemUnlocked from 0x1401e5820 to 0x1401e5af4 (724 bytes)
//
// 29 xrefs:
// > GameManager::isIconUnlocked @ 0x14017c5ad
// > GameManager::isColorUnlocked @ 0x14017c97b
// > GameManager::dataLoaded @ 0x1401874aa
// > GameStatsManager::trySelectActivePath @ 0x1401d46d6
// > GameStatsManager::trySelectActivePath @ 0x1401d4770
// > GameStatsManager::recountSpecialStats @ 0x1401e4fc9
// > GauntletSelectLayer::onPlay @ 0x1401fa813
// > GJGarageLayer::setupSpecialPage @ 0x140276f36
// > GJGarageLayer::onToggleItem @ 0x140277929
// > GJPathPage::init @ 0x1402856ce
// > GJPathSprite::updateState @ 0x140289283
// > GameOptionsLayer::setupOptions @ 0x14029f462
// > GameOptionsLayer::setupOptions @ 0x14029f590
// > GameOptionsLayer::onPracticeMusicSync @ 0x1402a02c7
// > GameOptionsLayer::onPracticeMusicSync @ 0x1402a0321
// > LevelSelectLayer::init @ 0x14031847a
// > LevelPage::onSecretDoor @ 0x14031d08d
// > PlayerObject::init @ 0x140386ae2
// > PlayerObject::init @ 0x140386b76
// > PlayerObject::init @ 0x140386c07
// > PlayLayer::toggleMusicInPractice @ 0x1403b2960
// > SecretLayer3::onClick @ 0x1403ec4f5
// > SecretLayer3::onClick @ 0x1403ec89c
// > SecretLayer3::onClick @ 0x1403ecc0c
// > SongInfoLayer::init @ 0x140493a37
// > SongInfoLayer::onMenuMusic @ 0x1404942f4
// > SongInfoLayer::onPracticeMusic @ 0x1404943c4
// > ??> @ 0x1406cc5e8
// > ??> @ 0x1406cc5f4
//
// 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
//
// Hidden C++ exception states: #wind=10
bool GameStatsManager::isItemUnlocked(GameStatsManager *a1, UnlockType a2, int a3)
{
bool v5; // bl
__int64 v6; // rdi
_QWORD *ItemKey; // rax
__int64 v8; // rdi
__int64 v9; // rcx
int v10; // ebx
GameStatsManager *v11; // rcx
bool result; // al
__int64 v13; // rdi
_QWORD *v14; // rax
cocos2d::CCString *v15; // rax
int v16; // edi
__int64 v17; // rcx
GameStatsManager *v18; // rcx
__int64 v19; // rdi
_QWORD *v20; // rax
cocos2d::CCString *v21; // rdi
const char *CString; // rax
size_t v23; // r8
__int64 v24; // rcx
void *v25; // [rsp+20h] [rbp-98h]
void *v26; // [rsp+20h] [rbp-98h]
void *v27; // [rsp+20h] [rbp-98h]
void *v28; // [rsp+20h] [rbp-98h]
void *v29; // [rsp+20h] [rbp-98h]
void *v30; // [rsp+28h] [rbp-90h]
__int128 v31; // [rsp+30h] [rbp-88h] BYREF
__int64 v32; // [rsp+40h] [rbp-78h]
__int64 v33; // [rsp+48h] [rbp-70h]
_QWORD v34[4]; // [rsp+50h] [rbp-68h] BYREF
_QWORD v35[4]; // [rsp+70h] [rbp-48h] BYREF
v5 = 0;
v6 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v25 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v6 = qword_1406C2EE8;
}
ItemKey = GameStatsManager::getItemKey((__int64)a1, &v31, a3, a2);
v8 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v6 + 336), ItemKey);
sub_14003A830((__int64)&v31);
if ( !v8 )
goto LABEL_7;
v10 = *(_DWORD *)(v8 + 320) - *(_DWORD *)(v8 + 324);
v11 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v26 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v11 = (GameStatsManager *)qword_1406C2EE8;
}
result = GameStatsManager::isStoreItemUnlocked(v11, v10);
v5 = result;
if ( !result )
{
LABEL_7:
v13 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v27 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v13 = qword_1406C2EE8;
}
v14 = GameStatsManager::getItemKey(v9, v34, a3, a2);
v15 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(*(_QWORD *)(v13 + 360), v14);
v16 = cocos2d::CCString::intValue(v15);
sub_14003A830((__int64)v34);
if ( v16 <= 0 )
goto LABEL_13;
v18 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v28 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v18 = (GameStatsManager *)qword_1406C2EE8;
}
result = GameStatsManager::isSecretChestUnlocked(v18, v16);
v5 = result;
if ( !result )
{
LABEL_13:
v19 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v29 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v19 = qword_1406C2EE8;
}
v20 = GameStatsManager::getItemKey(v17, v35, a3, a2);
v21 = (cocos2d::CCString *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v19 + 376), v20);
sub_14003A830((__int64)v35);
if ( v21 )
{
CString = cocos2d::CCString::getCString(v21);
v31 = 0;
v32 = 0;
v33 = 0;
v23 = -1;
do
++v23;
while ( CString[v23] );
sub_14003A930(&v31, CString, v23);
v24 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v30 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v24 = qword_1406C2EE8;
}
return GameStatsManager::isSpecialChestUnlocked(v24, &v31);
}
else
{
return v5;
}
}
}
return result;
}