//
// GameLevelManager::createNewLevelList from 0x71adbc to 0x71b2b4 (1272 bytes)
//
// 4 xrefs:
// > LevelBrowserLayer::createNewList @ 0x6e951c
// > LevelBrowserLayer::shareCommentClosed @ 0x6ecf44
// > LevelListLayer::cloneList @ 0xa77cb0
// > ??> @ 0x8dc18
//
// 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
//
GJLevelList *GameLevelManager::createNewLevelList(GameLevelManager *a1)
{
__int64 v1; // x19
void *v2; // x0
GJAccountManager *v3; // x0
cocos2d::CCArray *m_localLists; // x0
cocos2d::ccArray *data; // x1
int v6; // w20
unsigned int *p_m_uAutoReleaseCount; // x27
void *v8; // x0
__int64 v9; // x3
void *v10; // x0
char *v11; // x0
LocalLevelManager *v12; // x0
__int64 v13; // x19
void *v14; // x0
__int64 v15; // x21
__int64 v16; // x1
void *v17; // x0
unsigned int *v18; // x1
int v19; // w2
void *v20; // x0
unsigned int *v22; // x1
int v23; // w2
unsigned int *v24; // x1
int v25; // w2
unsigned int *v26; // x1
int v27; // w2
cocos2d::CCObject **arr; // x19
cocos2d::CCObject **i; // x20
cocos2d::CCObject *v30; // x1
__int64 v31; // x0
const void **p_m_nTag; // x1
unsigned int *v33; // x1
int v34; // w2
__int64 v35; // [xsp+0h] [xbp+0h] BYREF
__int64 v36; // [xsp+60h] [xbp+60h]
cocos2d::CCObject *v37; // [xsp+68h] [xbp+68h]
_DWORD *v38; // [xsp+80h] [xbp+80h] BYREF
__int64 v39; // [xsp+88h] [xbp+88h] BYREF
__int64 v40; // [xsp+90h] [xbp+90h] BYREF
__int64 v41; // [xsp+98h] [xbp+98h] BYREF
int v42; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v43; // [xsp+A8h] [xbp+A8h]
int *v44; // [xsp+B0h] [xbp+B0h]
int *v45; // [xsp+B8h] [xbp+B8h]
__int64 v46; // [xsp+C0h] [xbp+C0h]
v1 = GJLevelList::create(_stack_chk_guard);
v37 = (cocos2d::CCObject *)v1;
*(_DWORD *)(v1 + 456) = 2;
*(_BYTE *)(v1 + 392) = (unsigned __int8)&dword_0 + 1;
GameManager::sharedState();
sub_D18D28(&v41);
sub_D18EA8(v1 + 400, &v41);
v2 = (void *)(v41 - 24);
if ( (__int64 *)(v41 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v33 = (unsigned int *)(v41 - 8);
do
v34 = __ldaxr(v33);
while ( __stlxr(v34 - 1, v33) );
}
else
{
v34 = *(_DWORD *)(v41 - 8);
*(_DWORD *)(v41 - 8) = v34 - 1;
}
if ( v34 <= 0 )
operator delete(v2);
}
v3 = GJAccountManager::sharedState();
v37[6].m_eObjType = v3->m_accountID - v3->m_unkInt1;
v42 = 0;
v43 = 0;
v46 = 0;
v44 = &v42;
v45 = &v42;
m_localLists = LocalLevelManager::sharedState()->m_localLists;
if ( m_localLists )
{
data = m_localLists->data;
if ( data->num )
{
arr = data->arr;
for ( i = &arr[data->num - 1]; i >= arr; ++arr )
{
v30 = *arr;
if ( !*arr )
break;
v31 = *(_QWORD *)&v30[7].m_nTag;
p_m_nTag = (const void **)&v30[7].m_nTag;
if ( *(_QWORD *)(v31 - 24) )
std::_Rb_tree,std::less,std::allocator>::_M_insert_unique(
&v41,
p_m_nTag);
}
}
}
v6 = 0;
p_m_uAutoReleaseCount = &v37[7].m_uAutoReleaseCount;
do
{
while ( 1 )
{
sub_D153B8((unsigned int)&v35 + 128, "Unnamed ");
GameToolbox::intToString(&v39, (GameToolbox *)(unsigned int)v6);
sub_D15E14(&v38, &v39);
v8 = (void *)(v39 - 24);
if ( (__int64 *)(v39 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v26 = (unsigned int *)(v39 - 8);
do
v27 = __ldaxr(v26);
while ( __stlxr(v27 - 1, v26) );
}
else
{
v27 = *(_DWORD *)(v39 - 8);
*(_DWORD *)(v39 - 8) = v27 - 1;
}
if ( v27 <= 0 )
operator delete(v8);
}
if ( &v42 == (int *)std::_Rb_tree,std::less,std::allocator>::find(
(__int64)&v41,
(const void **)&v38)
|| (v9 = 1, v6 > 998) )
{
sub_D18D28(&v40);
sub_D18EA8(p_m_uAutoReleaseCount, &v40);
v10 = (void *)(v40 - 24);
if ( (__int64 *)(v40 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)(v40 - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *(_DWORD *)(v40 - 8);
*(_DWORD *)(v40 - 8) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v10);
}
v9 = 0;
}
++v6;
v11 = (char *)(v38 - 6);
if ( v38 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v22 = v38 - 2;
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(v38 - 2);
*(v38 - 2) = v23 - 1;
}
if ( v23 <= 0 )
break;
}
if ( !(_DWORD)v9 )
goto LABEL_12;
}
v36 = v9;
operator delete(v11);
}
while ( (_DWORD)v36 );
LABEL_12:
v12 = LocalLevelManager::sharedState();
cocos2d::CCArray::insertObject(v12->m_localLists, v37, 0);
v13 = v43;
if ( v43 )
{
do
{
while ( 1 )
{
std::_Rb_tree,std::less,std::allocator>::_M_erase(
(__int64)&v41,
*(_QWORD **)(v13 + 24));
v15 = *(_QWORD *)(v13 + 16);
v16 = *(_QWORD *)(v13 + 32);
v17 = (void *)(v16 - 24);
if ( (__int64 *)(v16 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(v16 - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v19 - 1;
}
if ( v19 <= 0 )
break;
}
v14 = (void *)v13;
v13 = v15;
operator delete(v14);
if ( !v15 )
return (GJLevelList *)v37;
}
operator delete(v17);
v20 = (void *)v13;
v13 = v15;
operator delete(v20);
}
while ( v15 );
}
return (GJLevelList *)v37;
}