//
// GameLevelManager::deleteLevel from 0x705f54 to 0x706218 (708 bytes)
//
// 5 xrefs:
// > LevelInfoLayer::onDelete @ 0x6d9438
// > EditLevelLayer::onDelete @ 0x6e2e28
// > LevelBrowserLayer::deleteSelected @ 0x6ed350
// > LevelBrowserLayer::FLAlert_Clicked @ 0x6ed6e8
// > ??> @ 0xa6a58
//
// 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::deleteLevel(GameLevelManager *a1, GJGameLevel *a2)
{
cocos2d::CCDictionary *m_onlineLevels; // x22
char *LevelKey; // x0
GJGameLevel *v6; // x23
char *v7; // x0
char *v8; // x21
int random; // w2
int seed; // w1
cocos2d::CCDictionary *v11; // x20
char *v12; // x0
char *v13; // x21
unsigned int *v14; // x20
int v15; // w0
unsigned int *v16; // x1
int v17; // w2
LocalLevelManager *v18; // x0
unsigned int *v19; // x20
int v20; // w0
_QWORD v21[2]; // [xsp+0h] [xbp+0h] BYREF
std::string v22; // [xsp+60h] [xbp+60h] BYREF
if ( a2->m_levelType == Editor )
{
v18 = LocalLevelManager::sharedState();
cocos2d::CCArray::removeObject(v18->m_localLevels, a2, 1);
}
else
{
m_onlineLevels = a1->m_onlineLevels;
LevelKey = (char *)GameLevelManager::getLevelKey(a1, a2->m_levelID.random - a2->m_levelID.seed);
sub_D153B8((unsigned int)v21 + 96, LevelKey);
v6 = (GJGameLevel *)cocos2d::CCDictionary::objectForKey(m_onlineLevels, &v22);
v7 = (char *)v22.m_data.m_data - 24;
if ( (__int64 *)v22.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v22.m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v22.m_data.m_data - 2);
*((_DWORD *)v22.m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v7);
}
if ( v6
&& (GJGameLevel::getNormalPercent(v6) > 0
|| v6->m_practicePercent > 0
|| v6->m_bestTime > 0
|| v6->m_bestPoints
|| v6->m_levelFavorited) )
{
sub_D153B8((unsigned int)v21 + 96, &byte_F288A0);
sub_D18EA8(&v6->m_levelString, &v22);
v8 = (char *)v22.m_data.m_data - 24;
if ( (__int64 *)v22.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)((char *)v22.m_data.m_data - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v22.m_data.m_data - 2);
*((_DWORD *)v22.m_data.m_data - 2) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v8);
}
v6->m_levelNotDownloaded = 1;
}
else
{
random = a2->m_levelID.random;
seed = a2->m_levelID.seed;
v11 = a1->m_onlineLevels;
v12 = (char *)GameLevelManager::getLevelKey(a1, random - seed);
sub_D153B8((unsigned int)v21 + 96, v12);
cocos2d::CCDictionary::removeObjectForKey(v11, &v22);
v13 = (char *)v22.m_data.m_data - 24;
if ( (__int64 *)v22.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)((char *)v22.m_data.m_data - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v22.m_data.m_data - 2);
*((_DWORD *)v22.m_data.m_data - 2) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v13);
}
}
}
}