//
// LevelListLayer::cloneList from 0x1403081e0 to 0x140308468 (648 bytes)
//
// 2 xrefs:
// > LevelListLayer::FLAlert_Clicked @ 0x1403075c4
// > ??> @ 0x1406d4580
//
// 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
//
// Hidden C++ exception states: #wind=5
void LevelListLayer::cloneList(LevelListLayer *a1)
{
unsigned int v2; // ebx
GameLevelManager *v3; // rcx
__int64 v4; // rax
GJLevelList *NewLevelList; // rsi
__int64 v6; // rax
std::string *p_m_listDesc; // r8
std::string *m_bigStorage; // rdx
cocos2d::CCArray *ListLevelsArray; // rbp
GJGameLevel *v10; // rax
__int64 v11; // rax
__int64 v12; // rbx
void *v13; // rdx
GJLevelList *m_levelList; // rcx
int m_original; // eax
struct cocos2d::CCScene *v16; // rax
struct cocos2d::CCTransitionFade *v17; // rbx
__int64 v18; // rcx
cocos2d::CCDirector *v19; // rax
void *v20; // [rsp+20h] [rbp-58h]
void *v21; // [rsp+20h] [rbp-58h]
void *v22; // [rsp+20h] [rbp-58h]
_BYTE v23[32]; // [rsp+28h] [rbp-50h] BYREF
_QWORD Src[4]; // [rsp+48h] [rbp-30h] BYREF
v2 = 0;
if ( !a1->m_exiting )
{
a1->setKeypadEnabled(a1, 0);
a1->m_exiting = 1;
v4 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v20 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v20);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v4 = qword_1406C2ED8;
}
*(_DWORD *)(v4 + 700) = 14;
if ( !qword_1406C2EC0 )
{
v21 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v21);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
NewLevelList = GameLevelManager::createNewLevelList(v3);
v6 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v22 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v22);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v6 = qword_1406C2EC0;
}
*(_BYTE *)(v6 + 712) = 1;
NewLevelList->m_difficulty = a1->m_levelList->m_difficulty;
p_m_listDesc = &a1->m_levelList->m_listDesc;
if ( &NewLevelList->m_listDesc != p_m_listDesc )
{
m_bigStorage = &a1->m_levelList->m_listDesc;
if ( a1->m_levelList->m_listDesc.m_data.m_capacity > 0xF )
m_bigStorage = (std::string *)p_m_listDesc->m_data.m_bigStorage;
sub_14003CCE0((void **)&NewLevelList->m_listDesc, m_bigStorage, a1->m_levelList->m_listDesc.m_data.m_size);
}
ListLevelsArray = GJLevelList::getListLevelsArray(a1->m_levelList, nullptr);
if ( cocos2d::CCArray::count(ListLevelsArray) )
{
do
{
v10 = (GJGameLevel *)cocos2d::CCArray::objectAtIndex(ListLevelsArray, v2);
GJLevelList::addLevelToList(NewLevelList, v10);
++v2;
}
while ( v2 < cocos2d::CCArray::count(ListLevelsArray) );
}
sub_14003BDB0((__int64)Src, (__int64)&a1->m_levelList->m_listName);
if ( Src[2] <= 0x17u )
sub_140041270(Src, &unk_140588814, 2u);
v11 = sub_14003BDB0((__int64)v23, (__int64)Src);
v12 = v11;
if ( &NewLevelList->m_listName != (std::string *)v11 )
{
v13 = (void *)v11;
if ( *(_QWORD *)(v11 + 24) > 0xFu )
v13 = *(void **)v11;
sub_14003CCE0((void **)&NewLevelList->m_listName, v13, *(_QWORD *)(v11 + 16));
}
sub_14003A830(v12);
m_levelList = a1->m_levelList;
m_original = m_levelList->m_original;
if ( !m_original )
m_original = m_levelList->m_listID;
NewLevelList->m_original = m_original;
v16 = LevelListLayer::scene(NewLevelList);
v17 = cocos2d::CCTransitionFade::create(0.5, v16);
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v18);
cocos2d::CCDirector::replaceScene(v19, v17);
sub_14003A830((__int64)Src);
}
}