//
// GameLevelManager::createNewLevelList from 0x100092d50 to 0x100092f64 (532 bytes)
//
// 3 xrefs:
// > LevelListLayer::cloneList @ 0x100246bec
// > LevelBrowserLayer::createNewList @ 0x1004191b8
// > LevelBrowserLayer::shareCommentClosed @ 0x1004192d0
//
// 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 *__fastcall GameLevelManager::createNewLevelList(GameLevelManager *a1)
{
GJLevelList *v1; // x19
GameManager *v2; // x0
GJAccountManager *v3; // x0
cocos2d::CCArray *m_localLists; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x20
unsigned __int64 v8; // x21
cocos2d::CCObject *v9; // x8
__int64 v10; // x20
void **v11; // x1
std::string::size_type v12; // x2
bool v13; // cf
char v14; // w24
LocalLevelManager *v15; // x0
std::string v17; // [xsp+0h] [xbp-B0h] BYREF
void *__p[2]; // [xsp+18h] [xbp-98h] BYREF
unsigned __int8 v19; // [xsp+2Fh] [xbp-81h]
std::string v20; // [xsp+30h] [xbp-80h] BYREF
_QWORD *v21; // [xsp+48h] [xbp-68h] BYREF
_QWORD v22[2]; // [xsp+50h] [xbp-60h] BYREF
std::string __str; // [xsp+60h] [xbp-50h] BYREF
v1 = GJLevelList::create_1();
v1->m_listType = Editor;
v1->m_isEditable = 1;
v2 = GameManager::sharedState();
if ( v2->m_playerName.m_data.m_short.shortStorage.__elems_[22] < 0 )
sub_1000097D0(&__str, (void *)v2->m_playerName.m_data.m_long.capacitym1, v2->m_playerName.m_data.m_long.size);
else
__str = (std::string)v2->m_playerName;
std::string::operator=((std::string *)&v1->m_creatorName, &__str);
if ( SHIBYTE(__str.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__str.__r_.__value_.__l.__data_);
v3 = GJAccountManager::sharedState();
v1->m_accountID = v3->m_accountID - v3->m_unkInt1;
v22[0] = 0;
v22[1] = 0;
v21 = v22;
m_localLists = LocalLevelManager::sharedState()->m_localLists;
if ( m_localLists )
{
data = m_localLists->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v8 = (unsigned __int64)&arr[num - 1];
while ( 1 )
{
v9 = *arr;
if ( !*arr )
goto LABEL_16;
if ( (SHIBYTE(v9[7].m_unknown5) & 0x8000000000000000LL) == 0 )
break;
if ( *(_QWORD *)&v9[7].m_unknown2 )
goto LABEL_14;
LABEL_15:
if ( (unsigned __int64)++arr > v8 )
goto LABEL_16;
}
if ( !HIBYTE(v9[7].m_unknown5) )
goto LABEL_15;
LABEL_14:
sub_1000B31B0(&v21, &v9[7].m_uIndexInArray, &v9[7].m_uIndexInArray);
goto LABEL_15;
}
}
LABEL_16:
v10 = 0;
do
{
sub_100009900(&v20, "Unnamed ");
GameToolbox::intToString(v10, __p);
if ( (v19 & 0x80u) == 0 )
v11 = __p;
else
v11 = (void **)__p[0];
if ( (v19 & 0x80u) == 0 )
v12 = v19;
else
v12 = (std::string::size_type)__p[1];
std::string::append(&v20, (const std::string::value_type *)v11, v12);
if ( (char)v19 < 0 )
operator delete(__p[0]);
if ( sub_1000B3318(&v21, &v20) )
v13 = (unsigned int)v10 >= 0x3E7;
else
v13 = 1;
v14 = !v13;
if ( v13 )
{
if ( SHIBYTE(v20.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&v17, v20.__r_.__value_.__l.__data_, v20.__r_.__value_.__l.__size_);
else
v17 = v20;
std::string::operator=((std::string *)&v1->m_unkString, &v17);
if ( SHIBYTE(v17.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v17.__r_.__value_.__l.__data_);
}
if ( SHIBYTE(v20.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v20.__r_.__value_.__l.__data_);
v10 = (unsigned int)(v10 + 1);
}
while ( (v14 & 1) != 0 );
v15 = LocalLevelManager::sharedState();
sub_10024A428(v15->m_localLists, v1, 0);
sub_1000B30E4(&v21, v22[0]);
return v1;
}