//
// GameStatsManager::getItemUnlockStateLite from 0x7bc5e8 to 0x7bc8c4 (732 bytes)
//
// 1 xrefs:
// > ??> @ 0x4d2c8
//
// 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
//
int GameStatsManager::getItemUnlockStateLite(GameStatsManager *a1, int a2, UnlockType a3)
{
AchievementManager *v6; // x0
AchievementManager *v7; // x26
int isAchievementAvailable; // w26
char *v9; // x0
unsigned int ItemUnlockState; // w0
cocos2d::CCString *SpecialChestKeyForItem; // x0
char *CString; // x0
_BOOL4 isSpecialChestLiteUnlockable; // w21
char *v14; // x0
__int64 v15; // x1
int v16; // w21
void *v17; // x0
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
__int64 v25; // [xsp+60h] [xbp+60h] BYREF
const char *v26; // [xsp+68h] [xbp+68h] BYREF
std::string v27; // [xsp+70h] [xbp+70h] BYREF
v6 = AchievementManager::sharedState();
AchievementManager::achievementForUnlock((__int64)v6, a2, a3, (__int64)&v25);
v7 = AchievementManager::sharedState();
sub_D18D28(&v26);
isAchievementAvailable = (unsigned __int8)AchievementManager::isAchievementAvailable(v7, &v26);
v9 = (char *)(v26 - 24);
if ( v26 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v26 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *((_DWORD *)v26 - 2);
*((_DWORD *)v26 - 2) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v9);
}
if ( !isAchievementAvailable )
sub_D1798C(&v25, &byte_F288A0, 0);
ItemUnlockState = GameStatsManager::getItemUnlockState(a1, a2, a3);
if ( ItemUnlockState == 1 )
{
v15 = v25;
v17 = (void *)(v25 - 24);
v16 = *(_QWORD *)(v25 - 24) != 0;
if ( (__int64 *)(v25 - 24) == &qword_124B6B0 )
return v16;
goto LABEL_13;
}
if ( ItemUnlockState > 1
&& (SpecialChestKeyForItem = GameStatsManager::getSpecialChestKeyForItem(a1, a2, a3)) != nullptr )
{
CString = (char *)cocos2d::CCString::getCString(SpecialChestKeyForItem);
sub_D153B8((int)&v27, CString);
isSpecialChestLiteUnlockable = GameStatsManager::isSpecialChestLiteUnlockable((__int64)a1, &v27);
v14 = (char *)v27.m_data.m_data - 24;
if ( (__int64 *)v27.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)((char *)v27.m_data.m_data - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v27.m_data.m_data - 2);
*((_DWORD *)v27.m_data.m_data - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v14);
}
v15 = v25;
if ( isSpecialChestLiteUnlockable )
v16 = 3;
else
v16 = 0;
}
else
{
v15 = v25;
v16 = 0;
}
v17 = (void *)(v15 - 24);
if ( (__int64 *)(v15 - 24) != &qword_124B6B0 )
{
LABEL_13:
if ( &pthread_create )
{
v19 = (unsigned int *)(v15 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(v15 - 8);
*(_DWORD *)(v15 - 8) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v17);
}
return v16;
}