//
// GameLevelManager::createNewLevel from 0x83c024 to 0x83c2d4 (688 bytes)
//
// 5 xrefs:
// > LevelInfoLayer::onClone @ 0x7e7708
// > EditLevelLayer::onClone @ 0x7f1a10
// > LevelBrowserLayer::createNewLevel @ 0x7f5da4
// > MapSelectLayer::init @ 0xac458c
// > ??> @ 0x87790
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:55:14 +0000
//
__int64 __fastcall GameLevelManager::createNewLevel(GameLevelManager *this)
{
__int64 v1; // x26
__int64 v2; // x2
size_t v3; // x1
__int64 *v4; // x0
LocalLevelManager *v5; // x0
LocalLevelManager *v6; // x0
int v7; // w21
__int64 AllLevelsInDict; // x25
cocos2d::CCString *v9; // x0
const char *CString; // x0
char *v11; // x23
size_t v12; // x0
size_t v13; // x20
char *v14; // x3
size_t v15; // x0
char *v16; // x1
size_t v17; // x2
LocalLevelManager *v18; // x0
__int64 v19; // x0
unsigned __int64 v21; // x0
LocalLevelManager *v22; // x22
char *v23; // x0
LocalLevelManager *v24; // [xsp+60h] [xbp+60h] BYREF
size_t v25; // [xsp+68h] [xbp+68h]
void *v26; // [xsp+70h] [xbp+70h]
v1 = GJGameLevel::create(_stack_chk_guard);
*(_DWORD *)(v1 + 1140) = 2;
*(_BYTE *)(v1 + 648) = (unsigned __int8)&dword_0 + 1;
v24 = nullptr;
v25 = 0;
v2 = GameManager::sharedState((GameManager *)((char *)&dword_0 + 1)) + 632;
v26 = nullptr;
if ( (*(_BYTE *)v2 & 1) != 0 )
{
std::string::__init((__int64 *)&v24, *(void **)(v2 + 16), *(_QWORD *)(v2 + 8));
}
else
{
v3 = *(_QWORD *)(v2 + 8);
v24 = *(LocalLevelManager **)v2;
v25 = v3;
v26 = *(void **)(v2 + 16);
}
v4 = (__int64 *)(v1 + 416);
if ( (LocalLevelManager **)(v1 + 416) != &v24 )
{
if ( ((unsigned __int8)v24 & 1) != 0 )
std::string::assign(v4, v26, v25);
else
std::string::assign(v4, (char *)&v24 + 1, (unsigned __int8)v24 >> 1);
}
if ( ((unsigned __int8)v24 & 1) != 0 )
operator delete(v26);
GJGameLevel::generateAutoSaveUID((__int64 *)&v24, (GJGameLevel *)v1);
v5 = (LocalLevelManager *)(unsigned __int8)v24;
if ( ((unsigned __int8)v24 & 1) != 0 )
operator delete(v26);
v6 = (LocalLevelManager *)LocalLevelManager::sharedState(v5);
v7 = 0;
AllLevelsInDict = LocalLevelManager::getAllLevelsInDict(v6);
while ( 1 )
{
v9 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"Unnamed %i",
(const char *)(unsigned int)v7);
CString = (const char *)cocos2d::CCString::getCString(v9);
v24 = nullptr;
v25 = 0;
v11 = (char *)CString;
v26 = nullptr;
v12 = strlen(CString);
v13 = v12;
if ( v12 > 0xFFFFFFFFFFFFFFEFLL )
sub_62C79C();
if ( v12 > 0x16 )
{
v21 = (v12 + 16) & 0xFFFFFFFFFFFFFFF0LL;
v22 = (LocalLevelManager *)(v21 | 1);
v23 = (char *)operator new(v21);
v24 = v22;
v14 = v23;
v26 = v23;
v25 = v13;
LABEL_28:
v14 = (char *)memcpy(v14, v11, v13);
goto LABEL_14;
}
LOBYTE(v24) = 2 * v12;
v14 = (char *)&v24 + 1;
if ( v12 )
goto LABEL_28;
LABEL_14:
v14[v13] = 0;
if ( !cocos2d::CCDictionary::objectForKey(AllLevelsInDict, &v24) || v7 > 998 )
break;
++v7;
if ( ((unsigned __int8)v24 & 1) != 0 )
operator delete(v26);
}
if ( ((unsigned __int8)v24 & 1) != 0 )
operator delete(v26);
v24 = nullptr;
v25 = 0;
v26 = nullptr;
v15 = strlen(v11);
std::string::__init((__int64 *)&v24, v11, v15);
if ( (LocalLevelManager **)(v1 + 1152) != &v24 )
{
if ( ((unsigned __int8)v24 & 1) != 0 )
{
v16 = (char *)v26;
v17 = v25;
}
else
{
v17 = (unsigned __int8)v24 >> 1;
v16 = (char *)&v24 + 1;
}
std::string::assign((__int64 *)(v1 + 1152), v16, v17);
}
v18 = (LocalLevelManager *)(unsigned __int8)v24;
if ( ((unsigned __int8)v24 & 1) != 0 )
operator delete(v26);
v19 = LocalLevelManager::sharedState(v18);
cocos2d::CCArray::insertObject(*(cocos2d::CCArray **)(v19 + 360), (cocos2d::CCObject *)v1, 0);
return v1;
}