//
// LevelEditorLayer::getNextFreeEnterChannel from 0x1402dad20 to 0x1402dae47 (295 bytes)
//
// 3 xrefs:
// > SetupObjectOptions2Popup::onPlusButton @ 0x14040102e
// > SetupEnterEffectPopup::onNextFreeEnterChannel @ 0x1404205de
// > ??> @ 0x1406d3290
//
// 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=1
int LevelEditorLayer::getNextFreeEnterChannel(LevelEditorLayer *a1, std::unordered_set *const a2)
{
__int64 v2; // r8
std::_List_val>::_Nodeptr Myhead; // rdi
unsigned __int8 *i; // rbx
cocos2d::CCArray *m_objects; // rax
cocos2d::ccArray *data; // rbx
__int64 num; // rax
cocos2d::CCObject **arr; // rbx
cocos2d::CCObject **j; // rsi
cocos2d::CCObject *v12; // rdi
int v13; // ebx
_BYTE v15[16]; // [rsp+20h] [rbp-68h] BYREF
char v16[16]; // [rsp+30h] [rbp-58h] BYREF
__int64 v17; // [rsp+40h] [rbp-48h] BYREF
void *v18; // [rsp+48h] [rbp-40h] BYREF
char v19[40]; // [rsp+58h] [rbp-30h] BYREF
int m_nLuaID_low; // [rsp+90h] [rbp+8h] BYREF
m_nLuaID_low = 0;
sub_14005E660((__int64)&v17, &m_nLuaID_low, v2);
Myhead = a2->_List._Mypair._Myval2._Myhead;
for ( i = *(unsigned __int8 **)Myhead; i != (unsigned __int8 *)Myhead; i = *(unsigned __int8 **)i )
sub_140060D70((__int64)&v17, (__int64)v15, i + 16);
m_objects = a1->m_objects;
if ( m_objects )
{
data = m_objects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
for ( j = &arr[num - 1]; arr <= j; ++arr )
{
v12 = *arr;
if ( !*arr )
break;
m_nLuaID_low = SLOWORD(v12[18].m_nLuaID);
sub_140060D70((__int64)&v17, (__int64)v15, (unsigned __int8 *)&m_nLuaID_low);
if ( v12[16].m_unknown2 == 45 )
{
m_nLuaID_low = v12[36].m_uIndexInArray;
sub_140060D70((__int64)&v17, (__int64)v16, (unsigned __int8 *)&m_nLuaID_low);
}
}
}
}
v13 = sub_1402D1460(1, 100, &v17);
sub_14005D100((__int64)v19);
sub_14005D870(&v18);
return v13;
}