//
// GameLevelManager::limitSavedLevels from 0x6f3184 to 0x6f33a4 (544 bytes)
//
// 3 xrefs:
// > GameLevelManager::encodeDataTo @ 0x708aa4
// > GameLevelManager::dataLoaded @ 0x73a550
// > ??> @ 0xc2130
//
// 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::limitSavedLevels(GameLevelManager *a1)
{
unsigned int v1; // w19
cocos2d::CCArray *SavedLevels; // x20
GameManager *v4; // x0
char *v5; // x24
GameManager *v6; // x0
__int64 v7; // x0
bool v9; // w1
GameManager *v10; // x0
unsigned int v11; // w20
cocos2d::CCArray *v12; // x22
unsigned int v13; // w21
int v14; // w0
cocos2d::CCString *v15; // x0
char *CString; // x0
cocos2d::CCDictionary *m_gauntletLevels; // x28
__int64 v18; // x2
char *v19; // x0
unsigned int *v20; // x1
int v21; // w3
__int64 v22; // [xsp+60h] [xbp+60h]
std::string v23; // [xsp+80h] [xbp+80h] BYREF
v1 = 0;
SavedLevels = GameLevelManager::getSavedLevels(a1, 0, 0);
v4 = GameManager::sharedState();
if ( GameManager::getGameVariable(v4, "0042") )
LODWORD(v5) = 100;
else
v5 = &byte_9[1];
v6 = GameManager::sharedState();
if ( GameManager::getGameVariable(v6, "0119") )
LODWORD(v5) = -1;
while ( v1 < (unsigned int)cocos2d::CCArray::count(SavedLevels) )
{
v7 = cocos2d::CCArray::objectAtIndex(SavedLevels, v1);
v9 = (int)v1++ > (int)v5;
*(_BYTE *)(v7 + 832) = v9;
}
v10 = GameManager::sharedState();
if ( !GameManager::getGameVariable(v10, "0127") )
{
v11 = 0;
v12 = cocos2d::CCDictionary::allKeys(a1->m_gauntletLevels);
while ( 1 )
{
v13 = v11;
if ( (unsigned int)cocos2d::CCArray::count(v12) <= v11 )
break;
v14 = cocos2d::CCArray::count(v12);
v15 = (cocos2d::CCString *)cocos2d::CCArray::objectAtIndex(v12, v14 + ~v11);
CString = (char *)cocos2d::CCString::getCString(v15);
m_gauntletLevels = a1->m_gauntletLevels;
sub_D153B8((int)&v23, CString);
v18 = cocos2d::CCDictionary::objectForKey(m_gauntletLevels, &v23);
v19 = (char *)v23.m_data.m_data - 24;
if ( (__int64 *)v23.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)((char *)v23.m_data.m_data - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *((_DWORD *)v23.m_data.m_data - 2);
*((_DWORD *)v23.m_data.m_data - 2) = v21 - 1;
}
if ( v21 <= 0 )
{
v22 = v18;
operator delete(v19);
v18 = v22;
}
}
++v11;
*(_BYTE *)(v18 + 832) = (int)(v13 + v1) > (int)v5;
}
}
}