//
// LevelEditorLayer::objectsInRect from 0x366cac to 0x367026 (890 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::rotationForSlopeNearObject @ 0x367068
// > EditorUI::addObjectsToSmartTemplate @ 0x39c220
// > EditorUI::selectObjectsInRect @ 0x3a4672
// > EditorUI::createSmartObjectsFromTemplate @ 0x3a4fa8
//
// 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::objectsInRect(LevelEditorLayer *a1, cocos2d::CCRect a2, bool a3)
{
float v3; // s12
float v4; // s13
float x; // r7
cocos2d::CCArray *v7; // r0
cocos2d::CCArray *v8; // r0
float v9; // s14
float *p_m_sectionXFactor; // r3
float m_sectionXFactor; // s12
float v12; // s11
int v13; // r4
float v14; // s13
float v15; // s13
float v16; // s16
float v17; // s14
float *v18; // r3
float v19; // s13
std::vector *, std::allocator *>> *, std::allocator *, std::allocator *>> *>> *p_m_sections; // r8
std::vector *, std::allocator *>> **m_start; // r1
std::vector *, std::allocator *>> **m_finish; // r2
int v23; // s13
float v24; // s17
float v25; // s14
float *v26; // r3
int v27; // s17
float v28; // s14
float *p_m_sectionYFactor; // r6
float m_sectionYFactor; // s12
float v31; // s11
int v32; // r3
float v33; // s13
float v34; // s12
float v35; // s13
float v36; // s14
float v37; // s13
float *v38; // r3
unsigned int v39; // s16
int v41; // r6
bool *p_m_nonSquareRotation; // r9
std::vector *, std::allocator *>> *v43; // r2
unsigned int v44; // r3
int v45; // r11
int v46; // r10
float v47; // r2
float v48; // r3
float v49; // [sp+0h] [bp-54h]
int v50; // [sp+8h] [bp-4Ch]
GameObject *v51; // [sp+Ch] [bp-48h]
int i; // [sp+10h] [bp-44h]
cocos2d::CCArray *v53; // [sp+14h] [bp-40h]
signed int v54; // [sp+1Ch] [bp-38h]
std::vector *v55; // [sp+20h] [bp-34h]
int v56; // [sp+24h] [bp-30h]
float y; // [sp+2Ch] [bp-28h]
cocos2d::CCRect v58; // [sp+3Ch] [bp-18h] BYREF
cocos2d::CCRect v59; // 0:kr00_16.16
x = a2.origin.x;
y = a2.origin.y;
cocos2d::CCRect::CCRect(&v58, (const cocos2d::CCRect *)LODWORD(a2.origin.x));
LODWORD(v59.origin.x) = &v58;
v59.origin.y = v47;
v59.size.width = v48;
v59.size.height = v49;
GJBaseGameLayer::updateOBB2(a1, v59);
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
v9 = *(float *)LODWORD(x);
v53 = v8;
if ( *(float *)LODWORD(x) <= 0.0 )
{
v13 = 0;
}
else
{
v4 = 10000000.0;
p_m_sectionXFactor = &a1->m_sectionXFactor;
m_sectionXFactor = a1->m_sectionXFactor;
if ( v9 < 10000000.0 )
v12 = (float)(v9 * m_sectionXFactor) - 1.0;
else
v12 = (float)(m_sectionXFactor * 10000000.0) - 1.0;
v13 = v12 > 0.0;
v3 = v12;
if ( v12 > 0.0 )
{
if ( v9 <= 0.0 )
{
v13 = -1;
}
else
{
if ( v9 < 10000000.0 )
v14 = *p_m_sectionXFactor;
else
v14 = 10000000.0;
if ( v9 < 10000000.0 )
{
v3 = 1.0;
}
else
{
v12 = 1.0;
v3 = *p_m_sectionXFactor;
}
if ( v9 < 10000000.0 )
v3 = (float)(v9 * v14) - v3;
else
v12 = (float)(v3 * v14) - v12;
if ( v9 < 10000000.0 )
v15 = v3;
else
v15 = v12;
LODWORD(v4) = (int)v15;
v13 = LODWORD(v4);
}
}
}
v16 = v9 + *(float *)(LODWORD(x) + 8);
if ( v16 <= 0.0 )
{
v17 = 1.0;
}
else
{
v17 = 10000000.0;
v18 = &a1->m_sectionXFactor;
if ( v16 < 10000000.0 )
{
v17 = *v18;
v4 = 1.0;
}
else
{
v3 = 1.0;
}
if ( v16 < 10000000.0 )
v19 = v4 + (float)(v16 * v17);
else
v19 = *v18;
if ( v16 < 10000000.0 )
v17 = v19;
else
v3 = v3 + (float)(v19 * v17);
if ( v16 >= 10000000.0 )
v17 = v3;
}
p_m_sections = &a1->m_sections;
m_start = a1->m_sections.m_start;
m_finish = a1->m_sections.m_finish;
v23 = m_finish - m_start - 1;
v24 = (float)(unsigned int)v23;
if ( v17 > (float)(unsigned int)v23 )
goto LABEL_44;
if ( v16 > 0.0 )
{
v25 = 10000000.0;
v26 = &a1->m_sectionXFactor;
if ( v16 < 10000000.0 )
v25 = *v26;
else
v23 = *(int *)v26;
if ( v16 < 10000000.0 )
v24 = (float)(v16 * v25) + 1.0;
else
v24 = (float)(*(float *)&v23 * v25) + 1.0;
LABEL_44:
v27 = (int)v24;
goto LABEL_46;
}
v27 = 1;
LABEL_46:
v28 = *(float *)(LODWORD(x) + 4);
if ( v28 <= 0.0 )
{
v32 = 0;
}
else
{
p_m_sectionYFactor = &a1->m_sectionYFactor;
m_sectionYFactor = a1->m_sectionYFactor;
if ( v28 < 10000000.0 )
v31 = (float)(v28 * m_sectionYFactor) - 1.0;
else
v31 = (float)(m_sectionYFactor * 10000000.0) - 1.0;
v32 = v31 > 0.0;
if ( v31 > 0.0 )
{
if ( v28 > 0.0 )
{
if ( v28 < 10000000.0 )
v33 = *p_m_sectionYFactor;
else
v33 = 10000000.0;
if ( v28 < 10000000.0 )
{
v34 = 1.0;
}
else
{
v31 = 1.0;
v34 = *p_m_sectionYFactor;
}
if ( v28 < 10000000.0 )
v34 = (float)(v28 * v33) - v34;
else
v31 = (float)(v34 * v33) - v31;
if ( v28 < 10000000.0 )
v35 = v34;
else
v35 = v31;
v50 = (int)v35;
goto LABEL_68;
}
v32 = -1;
}
}
v50 = v32;
LABEL_68:
v36 = v28 + *(float *)(LODWORD(x) + 12);
if ( v36 <= 0.0 )
{
v39 = 1;
}
else
{
v37 = 10000000.0;
v38 = &a1->m_sectionYFactor;
if ( v36 < 10000000.0 )
v37 = *v38;
else
v36 = *v38;
v39 = (int)(float)((float)(v36 * v37) + 1.0);
}
if ( m_start != m_finish )
{
v41 = v13;
p_m_nonSquareRotation = &a1->m_nonSquareRotation;
while ( v13 <= v27 )
{
v43 = p_m_sections->m_start[v41];
if ( v43 )
{
v44 = v43->m_finish - v43->m_start - 1;
if ( v44 >= v39 )
v44 = v39;
}
else
{
v44 = -1;
}
v54 = v44;
v45 = v50;
for ( i = v50; i <= v54; ++i )
{
v55 = p_m_sections->m_start[v41]->m_start[v45];
if ( v55 )
{
v46 = 0;
v56 = a1->m_sectionSizes.m_start[v41]->m_start[v45];
while ( v46 < v56 )
{
v51 = v55->m_start[v46];
if ( y != 0.0 || LevelEditorLayer::validGroup(a1, v51, 1) )
{
if ( (LevelEditorLayer::getObjectRect(&v58, a1, v51, 0, 0), !*p_m_nonSquareRotation)
&& cocos2d::CCRect::intersectsRect((cocos2d::CCRect *)LODWORD(x), &v58)
|| *p_m_nonSquareRotation && OBB2D::overlaps(a1->m_currentOBB2D) )
{
cocos2d::CCArray::addObject(v53, v51);
}
}
++v46;
}
}
++v45;
}
++v13;
++v41;
}
}
return v53;
}