//
// LevelEditorLayer::removeAllObjectsOfType from 0x1402d62c0 to 0x1402d6547 (647 bytes)
//
// 3 xrefs:
// > EditorUI::onDeleteSelectedType @ 0x1400e69fd
// > EditorUI::onDeleteStartPos @ 0x1400e6a3f
// > ??> @ 0x1406d30c8
//
// 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=4
void LevelEditorLayer::removeAllObjectsOfType(LevelEditorLayer *a1, int a2)
{
cocos2d::CCArray *v4; // rbp
std::_Vector_val *, std::allocator *>> *>>::pointer Myfirst; // r8
std::_Vector_val *, std::allocator *>> *>>::pointer Mylast; // rax
unsigned int v7; // r12d
int v8; // r9d
__int64 v9; // rdx
_QWORD *v10; // rcx
__int64 v11; // rax
__int64 v12; // rsi
_QWORD *v13; // r14
__int64 v14; // rbx
__int64 v15; // rdi
__int64 v16; // rdx
void *v17; // rdi
__int64 v18; // rcx
cocos2d::CCArray *v19; // rax
unsigned int v20; // ebx
struct cocos2d::CCObject *v21; // rax
__int64 v22; // rdx
GameObject *v23; // rbx
int v24; // [rsp+68h] [rbp+10h]
__int64 v25; // [rsp+70h] [rbp+18h]
__int64 v26; // [rsp+78h] [rbp+20h]
if ( a2 != 749 )
{
v4 = (cocos2d::CCArray *)cocos2d::CCArray::create(a1);
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
Mylast = a1->m_sections._Mypair._Myval2._Mylast;
v7 = 0;
if ( Myfirst != Mylast )
{
v8 = 0;
v24 = 0;
if ( Mylast - Myfirst )
{
v9 = 0;
v25 = 0;
do
{
v10 = *(std::_Vector_val *, std::allocator *>> *>>::pointer)((char *)Myfirst + v9);
if ( v10 )
v11 = (__int64)(v10[1] - *v10) >> 3;
else
LODWORD(v11) = -1;
v12 = 0;
v26 = (int)v11;
if ( (int)v11 > 0 )
{
do
{
v13 = *(_QWORD **)(**(_QWORD **)((char *)a1->m_sections._Mypair._Myval2._Myfirst + v9) + 8 * v12);
if ( v13 )
{
v14 = 0;
v15 = *(int *)(**(_QWORD **)((char *)a1->m_sectionSizes._Mypair._Myval2._Myfirst + v9) + 4 * v12);
if ( v15 > 0 )
{
do
{
v16 = *(_QWORD *)(*v13 + 8 * v14);
if ( *(_DWORD *)(v16 + 1036) == a2 )
cocos2d::CCArray::addObject(v4, (struct cocos2d::CCObject *)v16);
++v14;
}
while ( v14 < v15 );
v9 = v25;
}
}
++v12;
}
while ( v12 < v26 );
v8 = v24;
}
v24 = ++v8;
v9 += 8;
v25 = v9;
Myfirst = a1->m_sections._Mypair._Myval2._Myfirst;
}
while ( v8 < (unsigned __int64)(a1->m_sections._Mypair._Myval2._Mylast - Myfirst) );
}
}
v17 = operator new(0xA0u);
cocos2d::CCObject::CCObject((cocos2d::CCObject *)v17);
*(_QWORD *)v17 = &UndoObject::`vftable';
*((_QWORD *)v17 + 7) = 0;
*((_DWORD *)v17 + 16) = 0;
*((_QWORD *)v17 + 9) = 0;
*((_WORD *)v17 + 40) = 0;
sub_1400DE960((__int64)v17 + 84);
if ( v4 )
{
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18);
*((_QWORD *)v17 + 9) = v19;
cocos2d::CCArray::addObjectsFromArray(v19, v4);
cocos2d::CCObject::retain(*((cocos2d::CCObject **)v17 + 9));
}
*((_DWORD *)v17 + 16) = 4;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v17);
cocos2d::CCArray::removeAllObjects(a1->m_redoObjects);
v20 = 1000;
if ( !a1->m_increaseMaxUndoRedo )
v20 = 200;
if ( cocos2d::CCArray::count(a1->m_undoObjects) >= v20 )
cocos2d::CCArray::removeObjectAtIndex(a1->m_undoObjects, 0, 1);
cocos2d::CCArray::addObject(a1->m_undoObjects, (struct cocos2d::CCObject *)v17);
if ( cocos2d::CCArray::count(v4) )
{
do
{
v21 = cocos2d::CCArray::objectAtIndex(v4, v7);
v23 = (GameObject *)v21;
if ( v21 )
{
LOBYTE(v22) = 1;
v21->__vftable[15].setTag(v21, v22);
GJBaseGameLayer::removeObjectFromSection(a1, v23);
LevelEditorLayer::removeSpecial(a1, v23);
a1->m_unk3b22 = 1;
}
++v7;
}
while ( v7 < cocos2d::CCArray::count(v4) );
}
}
}