//
// GameStatsManager::completedStarLevel from 0x7ba474 to 0x7ba648 (468 bytes)
//
// 5 xrefs:
// > GameManager::verifyStarUnlocks @ 0x5e9f64
// > LevelInfoLayer::init @ 0x6dd224
// > GameLevelManager::updateLevelRewards @ 0x704f2c
// > GameStatsManager::completedLevel @ 0x7ba6c0
// > ??> @ 0x72a50
//
// 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
//
void GameStatsManager::completedStarLevel(GameStatsManager *a1, GJGameLevel *a2)
{
char *StarLevelKey; // x0
cocos2d::CCDictionary *m_completedLevels; // x24
cocos2d::CCString *m_trueString; // x23
void *v7; // x0
int v8; // w2
unsigned int *v9; // x2
int v10; // w1
__int64 v11; // [xsp+50h] [xbp+50h] BYREF
if ( !GameStatsManager::hasCompletedStarLevel(a1, a2) && a2->m_stars.random - a2->m_stars.seed > 0 )
{
StarLevelKey = (char *)GameStatsManager::getStarLevelKey(a1, a2);
m_completedLevels = a1->m_completedLevels;
m_trueString = a1->m_trueString;
sub_D153B8((int)&v11, StarLevelKey);
cocos2d::CCDictionary::setObject((int)m_completedLevels, m_trueString);
v7 = (void *)(v11 - 24);
if ( (__int64 *)(v11 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)(v11 - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *(_DWORD *)(v11 - 8);
*(_DWORD *)(v11 - 8) = v10 - 1;
}
if ( v10 <= 0 )
operator delete(v7);
}
v8 = a2->m_stars.random - a2->m_stars.seed;
if ( v8 > 10 )
{
if ( a2->m_levelType != Main )
v8 = 0;
if ( a2->m_levelLength != 5 )
{
LABEL_6:
GameStatsManager::incrementStat(a1, "6", v8);
if ( (unsigned int)(a2->m_stars.random - a2->m_stars.seed - 8) > 1 )
return;
LABEL_12:
GameStatsManager::incrementStat(a1, "42");
return;
}
}
else if ( a2->m_levelLength != 5 )
{
goto LABEL_6;
}
GameStatsManager::incrementStat(a1, "28", v8);
if ( (unsigned int)(a2->m_stars.random - a2->m_stars.seed - 8) <= 1 )
goto LABEL_12;
}
}