//
// GameLevelManager::createNewLevel from 0x3c52dc to 0x3c53d0 (244 bytes)
//
// 4 xrefs:
// > LevelInfoLayer::onClone @ 0x3b28a0
// > EditLevelLayer::onClone @ 0x3b8038
// > LevelBrowserLayer::createNewLevel @ 0x3bb646
// > MapSelectLayer::init @ 0x50f9ec
//
// 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
//
GJGameLevel *GameLevelManager::createNewLevel(GameLevelManager *a1)
{
int *v1; // r0
GJGameLevel *v2; // r6
GameManager *v3; // r0
LocalLevelManager *v4; // r0
const char *v5; // r7
cocos2d::CCDictionary *AllLevelsInDict; // r10
cocos2d::CCString *v7; // r0
char *CString; // r9
_BOOL4 v9; // r3
int v10; // r9
LocalLevelManager *v11; // r0
_BOOL4 v13; // [sp+4h] [bp-18h]
std::string v14; // [sp+10h] [bp-Ch] BYREF
v1 = GJGameLevel::create((GJGameLevel *)a1);
v1[190] = 2;
*((_BYTE *)v1 + 396) = 1;
v2 = (GJGameLevel *)v1;
v3 = GameManager::sharedState();
sub_775C20(&v14, &v3->m_playerName);
sub_775D40(&v2->m_creatorName, &v14);
sub_774008(&v14);
v4 = LocalLevelManager::sharedState();
v5 = nullptr;
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v4);
do
{
v7 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"Unnamed %i", v5);
CString = (char *)cocos2d::CCString::getCString(v7);
sub_776584((int)&v14, CString);
if ( cocos2d::CCDictionary::objectForKey(AllLevelsInDict, &v14) )
v9 = (int)v5 > 998;
else
v9 = 1;
v13 = v9;
sub_774008(&v14);
if ( v13 )
{
sub_776584((int)&v14, CString);
sub_775D40(&v2->m_tempName, &v14);
v10 = 0;
sub_774008(&v14);
}
else
{
v10 = 1;
}
++v5;
}
while ( v10 );
v11 = LocalLevelManager::sharedState();
cocos2d::CCArray::insertObject(v11->m_localLevels, v2, 0);
return v2;
}