//
// LevelEditorLayer::objectsAtPosition from 0x366aa8 to 0x366ca4 (508 bytes)
//
// 4 xrefs:
// > EditorUI::onDelete @ 0x3a432e
// > EditorUI::ccTouchEnded @ 0x3a57bc
// > EditorUI::ccTouchEnded @ 0x3a5870
// > EditorUI::ccTouchBegan @ 0x3a6cc2
//
// 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
//
cocos2d::CCArray *LevelEditorLayer::objectsAtPosition(LevelEditorLayer *a1, cocos2d::CCPoint a2)
{
float x; // r7
int v4; // r5
cocos2d::CCArray *v5; // r0
cocos2d::CCArray *v6; // r0
float v7; // s15
float m_sectionXFactor; // s14
float v9; // s14
int v10; // r2
float v11; // s15
float v12; // s14
float *p_m_sectionYFactor; // r3
int v14; // r3
std::vector *, std::allocator *>> *, std::allocator *, std::allocator *>> *>> *p_m_sections; // r8
std::vector *, std::allocator *>> **m_finish; // r1
std::vector *, std::allocator *>> **m_start; // r0
int v18; // r6
int v19; // r2
char *v21; // r6
bool *p_m_nonSquareRotation; // r9
std::vector *, std::allocator *>> *v23; // r2
unsigned int v24; // r3
int v25; // r11
int v26; // r10
GameObject *v27; // [sp+Ch] [bp-50h]
signed int i; // [sp+10h] [bp-4Ch]
int v29; // [sp+14h] [bp-48h]
int v30; // [sp+18h] [bp-44h]
cocos2d::CCArray *v31; // [sp+1Ch] [bp-40h]
signed int v32; // [sp+24h] [bp-38h]
_DWORD *v33; // [sp+28h] [bp-34h]
int v34; // [sp+2Ch] [bp-30h]
unsigned int v35; // [sp+30h] [bp-2Ch]
int v36; // [sp+34h] [bp-28h]
cocos2d::CCRect v37; // [sp+44h] [bp-18h] BYREF
cocos2d::CCRect v38; // 0:r1.12,12:^0.4
x = a2.x;
v4 = (int)&_stack_chk_guard;
cocos2d::CCRect::CCRect(&v37, *(float *)LODWORD(a2.x), *(float *)(LODWORD(a2.x) + 4), 1.0, 1.0);
LODWORD(v38.origin.x) = &v37;
GJBaseGameLayer::updateOBB2(a1, v38);
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
v7 = *(float *)LODWORD(x);
v31 = v6;
if ( *(float *)LODWORD(x) <= 0.0 )
{
v10 = 0;
}
else
{
m_sectionXFactor = a1->m_sectionXFactor;
if ( v7 < 10000000.0 )
v9 = v7 * m_sectionXFactor;
else
v9 = m_sectionXFactor * 10000000.0;
v10 = (int)v9;
}
v11 = *(float *)(LODWORD(x) + 4);
if ( v11 <= 0.0 )
{
v14 = 0;
}
else
{
v12 = 10000000.0;
p_m_sectionYFactor = &a1->m_sectionYFactor;
if ( v11 < 10000000.0 )
v12 = *p_m_sectionYFactor;
else
v11 = *p_m_sectionYFactor;
v14 = (int)(float)(v11 * v12);
}
p_m_sections = &a1->m_sections;
if ( v10 > 1 )
v4 = v10 - 1;
m_finish = a1->m_sections.m_finish;
m_start = a1->m_sections.m_start;
if ( v10 <= 1 )
v4 = 0;
v18 = v10 + 1;
if ( v10 + 1 >= (unsigned int)(m_finish - m_start - 1) )
v18 = m_finish - m_start - 1;
if ( v14 <= 1 )
v19 = 0;
else
v19 = v14 - 1;
v29 = v18;
v30 = v19;
v35 = v14 + 1;
if ( m_start != m_finish )
{
v21 = (char *)(4 * v4);
p_m_nonSquareRotation = &a1->m_nonSquareRotation;
v34 = 4 * v19;
while ( v4 <= v29 )
{
v23 = *(std::vector *, std::allocator *>> **)((char *)p_m_sections->m_start + (unsigned int)v21);
if ( v23 )
{
v24 = v23->m_finish - v23->m_start - 1;
if ( v24 >= v35 )
v24 = v35;
}
else
{
v24 = -1;
}
v32 = v24;
v25 = v34;
for ( i = v30; i <= v32; ++i )
{
v33 = *(_DWORD **)(**(_DWORD **)((char *)p_m_sections->m_start + (unsigned int)v21) + v25);
if ( v33 )
{
v26 = 0;
v36 = *(_DWORD *)(**(_DWORD **)((char *)a1->m_sectionSizes.m_start + (unsigned int)v21) + v25);
while ( v26 < v36 )
{
v27 = *(GameObject **)(*v33 + 4 * v26);
if ( LevelEditorLayer::validGroup(a1, v27, 1) )
{
if ( (LevelEditorLayer::getObjectRect(&v37, a1, v27, 0, 0), !*p_m_nonSquareRotation)
&& cocos2d::CCRect::containsPoint(&v37, (const cocos2d::CCPoint *)LODWORD(x))
|| *p_m_nonSquareRotation && OBB2D::overlaps(a1->m_currentOBB2D) )
{
cocos2d::CCArray::addObject(v31, v27);
}
}
++v26;
}
}
v25 += 4;
}
++v4;
v21 += 4;
}
}
return v31;
}