//
// LevelEditorLayer::getNextFreeEditorLayer from 0x10035fc38 to 0x10035fd34 (252 bytes)
//
// 2 xrefs:
// > SetGroupIDLayer::onNextFreeEditorLayer1 @ 0x10003cdcc
// > SetGroupIDLayer::onNextFreeEditorLayer2 @ 0x10003ce40
//
// 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
//
int __fastcall LevelEditorLayer::getNextFreeEditorLayer(LevelEditorLayer *a1, std::unordered_set *const a2)
{
std::__hash_node_base *>::__next_pointer i; // x20
cocos2d::CCArray *m_objects; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x19
unsigned __int64 v8; // x20
cocos2d::CCObject *v9; // x21
int v10; // w8
int v11; // w19
int v12; // w9
_QWORD v14[4]; // [xsp+0h] [xbp-50h] BYREF
int v15; // [xsp+20h] [xbp-30h]
int m_uAutoReleaseCount_high; // [xsp+2Ch] [xbp-24h] BYREF
memset(v14, 0, sizeof(v14));
v15 = 1065353216;
for ( i = a2->__table_.__p1_.__value_.__next_; i; i = i->__next_ )
sub_10001C1B0((unsigned __int64)v14, (int *)&i[2], &i[2]);
m_objects = a1->m_objects;
if ( m_objects )
{
data = m_objects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v8 = (unsigned __int64)&arr[num - 1];
do
{
v9 = *arr;
if ( !*arr )
break;
m_uAutoReleaseCount_high = SHIWORD(v9[21].m_uAutoReleaseCount);
sub_10001C1B0((unsigned __int64)v14, &m_uAutoReleaseCount_high, &m_uAutoReleaseCount_high);
m_uAutoReleaseCount_high = SLOWORD(v9[21].m_eObjType);
sub_10001C1B0((unsigned __int64)v14, &m_uAutoReleaseCount_high, &m_uAutoReleaseCount_high);
++arr;
}
while ( (unsigned __int64)arr <= v8 );
}
}
v10 = 1;
m_uAutoReleaseCount_high = 1;
do
{
v11 = v10;
if ( !sub_100018814(v14, &m_uAutoReleaseCount_high) )
break;
v12 = m_uAutoReleaseCount_high;
v10 = ++m_uAutoReleaseCount_high;
}
while ( v12 < 1000 );
sub_100017A98((__int64)v14);
return v11;
}