//
// GameLevelManager::purgeUnusedLevels from 0x3c79a8 to 0x3c7afa (338 bytes)
//
// 2 xrefs:
// > GameLevelManager::encodeDataTo @ 0x3c7b1c
// > GameLevelManager::dataLoaded @ 0x3d8f76
//
// 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 GameLevelManager::purgeUnusedLevels(GameLevelManager *a1)
{
unsigned int v2; // r7
cocos2d::CCArray *v3; // r8
int v4; // r0
cocos2d::CCString *v5; // r0
char *CString; // r0
cocos2d::CCDictionary *m_onlineLevels; // r4
char *v8; // r11
GJGameLevel *v9; // r4
cocos2d::CCDictionary *v10; // r4
std::string v11; // [sp+8h] [bp-Ch] BYREF
v2 = 0;
v3 = cocos2d::CCDictionary::allKeys(a1->m_onlineLevels);
while ( v2 < cocos2d::CCArray::count(v3) )
{
v4 = cocos2d::CCArray::count(v3);
v5 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v3, ~v2 + v4);
CString = (char *)cocos2d::CCString::getCString(v5);
m_onlineLevels = a1->m_onlineLevels;
v8 = CString;
sub_776584((int)&v11, CString);
v9 = (GJGameLevel *)cocos2d::CCDictionary::objectForKey(m_onlineLevels, &v11);
sub_774008(&v11);
if ( v9->m_levelNotDownloaded
&& v9->m_levelFolder <= 0
&& (GJGameLevel::getNormalPercent(v9) <= 0
&& v9->m_practicePercent <= 0
&& !v9->m_bestTime
&& !v9->m_bestPoints
&& !v9->m_isCompletionLegitimate
|| v9->m_stars.random - v9->m_stars.seed <= 0
&& GJGameLevel::getNormalPercent(v9) <= 9
&& v9->m_attempts.random - v9->m_attempts.seed <= 4
&& !v9->m_bestTime
&& !v9->m_bestPoints
|| v9->m_stars.random - v9->m_stars.seed <= 0
&& v9->m_levelLength <= 1
&& GJGameLevel::getNormalPercent(v9) <= 99
&& v9->m_attempts.random - v9->m_attempts.seed <= 9
&& !v9->m_bestTime
&& !v9->m_bestPoints) )
{
v10 = a1->m_onlineLevels;
sub_776584((int)&v11, v8);
cocos2d::CCDictionary::removeObjectForKey(v10);
sub_774008(&v11);
}
++v2;
}
}