//
// SetGroupIDLayer::onNextFreeEditorLayer1 from 0x1002ff2f0 to 0x1002ff3e2 (242 bytes)
//
// 1 xrefs:
// > SetGroupIDLayer::init @ 0x1002fd52f
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:28:32 +0000
//
__int64 __fastcall SetGroupIDLayer::onNextFreeEditorLayer1(__int64 a1, __int64 a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rdi
_QWORD *v6; // rdi
_QWORD *v7; // r14
void *v8; // rdi
__int64 v9; // rax
unsigned int v10; // r14d
void *v12[2]; // [rsp+0h] [rbp-40h] BYREF
void *__p[2]; // [rsp+10h] [rbp-30h]
int v14; // [rsp+20h] [rbp-20h]
GameManager::sharedState(a1, a2, a3);
v5 = *(_QWORD *)(v4 + 552);
*(_OWORD *)__p = 0;
*(_OWORD *)v12 = 0;
v14 = 1065353216;
*(_DWORD *)(a1 + 768) = LevelEditorLayer::getNextFreeEditorLayer(v5, (__int64)v12);
v6 = __p[0];
if ( __p[0] )
{
do
{
v7 = (_QWORD *)*v6;
operator delete(v6);
v6 = v7;
}
while ( v7 );
}
v8 = v12[0];
v12[0] = nullptr;
if ( v8 )
operator delete(v8);
v9 = *(_QWORD *)(a1 + 672);
if ( v9 )
{
*(_WORD *)(v9 + 1202) = *(_WORD *)(a1 + 768);
}
else if ( (unsigned int)sub_1007FEF90(*(_QWORD *)(a1 + 680)) )
{
v10 = 0;
do
*(_WORD *)(sub_1007FEFE0(*(_QWORD *)(a1 + 680), v10++) + 1202) = *(_WORD *)(a1 + 768);
while ( v10 < (unsigned int)sub_1007FEF90(*(_QWORD *)(a1 + 680)) );
}
return sub_1003006D0(a1);
}