//
// GameLevelManager::markLevelAsDownloaded from 0x6f5d74 to 0x6f5f2c (440 bytes)
//
// 3 xrefs:
// > GameLevelManager::markListAsDownloaded @ 0x6f6034
// > GameLevelManager::processOnDownloadLevelCompleted @ 0x707f44
// > ??> @ 0x98e08
//
// 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::markLevelAsDownloaded(GameLevelManager *a1, int a2)
{
char *v4; // x0
int v5; // w1
GameLevelManager *v6; // x0
cocos2d::CCDictionary *m_downloadedLevels; // x23
cocos2d::CCString *m_trueString; // x19
char *LevelKey; // x0
char *v10; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x19
int v14; // w1
std::string v15; // [xsp+50h] [xbp+50h] BYREF
if ( cocos2d::CCDictionary::count(a1->m_downloadedLevels) > 0x63 )
{
cocos2d::CCDictionary::getFirstKey((__int64 *)&v15, a1->m_downloadedLevels);
cocos2d::CCDictionary::removeObjectForKey(a1->m_downloadedLevels, &v15);
v4 = (char *)v15.m_data.m_data - 24;
if ( (__int64 *)v15.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)((char *)v15.m_data.m_data - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v15.m_data.m_data - 2);
*((_DWORD *)v15.m_data.m_data - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v4);
}
}
v5 = a2;
v6 = a1;
m_downloadedLevels = a1->m_downloadedLevels;
m_trueString = a1->m_trueString;
LevelKey = (char *)GameLevelManager::getLevelKey(v6, v5);
sub_D153B8((int)&v15, LevelKey);
cocos2d::CCDictionary::setObject((int)m_downloadedLevels, m_trueString);
v10 = (char *)v15.m_data.m_data - 24;
if ( (__int64 *)v15.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)((char *)v15.m_data.m_data - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v15.m_data.m_data - 2);
*((_DWORD *)v15.m_data.m_data - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v10);
}
}