//
// GameLevelManager::purgeUnusedLevels from 0x4ae01c to 0x4ae1a8 (396 bytes)
//
// 2 xrefs:
// > GameLevelManager::encodeDataTo @ 0x4ae308
// > GameLevelManager::dataLoaded @ 0x4dd6f0
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:50:00 +0000
//
unsigned int __fastcall GameLevelManager::purgeUnusedLevels(cocos2d::CCDictionary **this)
{
unsigned int v2; // r8
cocos2d::CCArray *v3; // r10
unsigned int result; // r0
int v5; // r0
cocos2d::CCString *v6; // r0
const char *CString; // r0
int v8; // r4
const char *v9; // r11
size_t v10; // r0
int v11; // r4
int v12; // r3
int v13; // r3
size_t v14; // r0
cocos2d::CCDictionary *v15; // r4
int v16; // [sp+0h] [bp-14h] BYREF
int v17; // [sp+4h] [bp-10h]
int v18; // [sp+8h] [bp-Ch]
v2 = 0;
v3 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(*(this + 136));
while ( 1 )
{
result = cocos2d::CCArray::count(v3);
if ( v2 >= result )
break;
v5 = cocos2d::CCArray::count(v3);
v6 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v3, ~v2 + v5);
CString = (const char *)cocos2d::CCString::getCString(v6);
v16 = 0;
v17 = 0;
v18 = 0;
v8 = (int)*(this + 136);
v9 = CString;
v10 = strlen(CString);
std::string::__init(&v16, v9, v10);
v11 = cocos2d::CCDictionary::objectForKey(v8, &v16);
std::string::~string((int)&v16);
if ( *(_BYTE *)(v11 + 917) && *(int *)(v11 + 740) <= 0 )
{
v12 = *(unsigned __int8 *)(v11 + 1148);
v13 = (v12 & 1) != 0 ? *(_DWORD *)(v11 + 1152) : v12 >> 1;
if ( !v13
&& (!*(_BYTE *)(v11 + 1300)
|| !GameLevelManager::dtShouldUploadLevel((GameLevelManager *)this, (GJGameLevel *)v11))
&& (GJGameLevel::getNormalPercent((GJGameLevel *)v11) <= 0
&& *(int *)(v11 + 712) <= 0
&& !*(_DWORD *)(v11 + 1040)
&& !*(_DWORD *)(v11 + 1068)
&& !*(_BYTE *)(v11 + 673)
|| *(_DWORD *)(v11 + 772) - *(_DWORD *)(v11 + 776) <= 0
&& GJGameLevel::getNormalPercent((GJGameLevel *)v11) <= 9
&& *(_DWORD *)(v11 + 620) - *(_DWORD *)(v11 + 624) <= 4
&& !*(_DWORD *)(v11 + 1040)
&& !*(_DWORD *)(v11 + 1068)
|| *(_DWORD *)(v11 + 772) - *(_DWORD *)(v11 + 776) <= 0
&& *(int *)(v11 + 724) <= 1
&& GJGameLevel::getNormalPercent((GJGameLevel *)v11) <= 99
&& *(_DWORD *)(v11 + 620) - *(_DWORD *)(v11 + 624) <= 9
&& !*(_DWORD *)(v11 + 1040)
&& !*(_DWORD *)(v11 + 1068)) )
{
v16 = 0;
v17 = 0;
v18 = 0;
v14 = strlen(v9);
v15 = *(this + 136);
std::string::__init(&v16, v9, v14);
cocos2d::CCDictionary::removeObjectForKey(v15);
std::string::~string((int)&v16);
}
}
++v2;
}
return result;
}