//
// LevelEditorLayer::getNextFreeOrderChannel from 0x1402daab0 to 0x1402dabef (319 bytes)
//
// 3 xrefs:
// > SetGroupIDLayer::onNextFreeOrderChannel @ 0x1403fd8f8
// > SetupRotateGameplayPopup::onPlusButton @ 0x140441f8e
// > ??> @ 0x1406d3278
//
// 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::getNextFreeOrderChannel(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; // rdi
__int64 num; // rax
cocos2d::CCObject **arr; // rdi
cocos2d::CCObject **j; // rsi
cocos2d::CCObject *v12; // rbx
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_uIndexInArray; // [rsp+90h] [rbp+8h] BYREF
m_uIndexInArray = 0;
sub_14005E660((__int64)&v17, &m_uIndexInArray, 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;
if ( v12[22].m_uAutoReleaseCount == 1 )
{
m_uIndexInArray = (int)v12[32].__vftable;
sub_140060D70((__int64)&v17, (__int64)v15, (unsigned __int8 *)&m_uIndexInArray);
if ( v12[18].m_eObjType == 2900 )
{
m_uIndexInArray = v12[33].m_uIndexInArray;
sub_140060D70((__int64)&v17, (__int64)v16, (unsigned __int8 *)&m_uIndexInArray);
}
}
}
}
}
v13 = sub_1402D1460(1, 1000, &v17);
sub_14005D100((__int64)v19);
sub_14005D870(&v18);
return v13;
}