//
// LevelEditorLayer::objectsInRect from 0x65e6fc to 0x65ec00 (1284 bytes)
//
// 5 xrefs:
// > LevelEditorLayer::rotationForSlopeNearObject @ 0x65ec7c
// > EditorUI::addObjectsToSmartTemplate @ 0x6b3ffc
// > EditorUI::selectObjectsInRect @ 0x6c0ffc
// > EditorUI::createSmartObjectsFromTemplate @ 0x6c22cc
// > ??> @ 0x6ffc0
//
// 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
//
// local variable allocation has failed, the output may be wrong!
cocos2d::CCArray *LevelEditorLayer::objectsInRect(LevelEditorLayer *a1, cocos2d::CCRect a2, bool a3)
{
unsigned __int8 v3; // w2
int v4; // w23
float *v6; // x20
cocos2d::CCArray *v7; // x0
float v8; // s2
float m_sectionXFactor; // s0
_BOOL4 v10; // w0
float v11; // s2
std::vector *, std::allocator *>> **m_start; // x20
std::vector *, std::allocator *>> **m_finish; // x26
float v14; // s1
float y; // s0
float v16; // s0
float v18; // s0
float m_sectionYFactor; // s1
_BOOL4 v20; // w0
bool *p_m_nonSquareRotation; // x25
std::vector *, std::allocator *>> *v22; // x20
__int64 v23; // x0
unsigned __int64 v24; // x1
int v25; // w0
int v26; // w26
__int64 v27; // x27
std::vector *v28; // x22
int v29; // w21
unsigned __int64 v30; // x28
__int64 v31; // x21
GameObject *v32; // x20
int v33; // [xsp+7Ch] [xbp+7Ch]
int v34; // [xsp+80h] [xbp+80h]
int v35; // [xsp+84h] [xbp+84h]
cocos2d::CCRect *v36; // [xsp+88h] [xbp+88h]
int v37; // [xsp+90h] [xbp+90h]
int i; // [xsp+94h] [xbp+94h]
cocos2d::CCArray *v39; // [xsp+98h] [xbp+98h]
__int64 v40; // [xsp+A0h] [xbp+A0h]
__int64 v41; // [xsp+A8h] [xbp+A8h]
cocos2d::CCRect v42; // [xsp+B8h] [xbp+B8h] BYREF
cocos2d::CCRect v43; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
v4 = v3;
v36 = (cocos2d::CCRect *)a3;
v6 = (float *)a3;
cocos2d::CCRect::CCRect(&v42, (const cocos2d::CCRect *)a3);
GJBaseGameLayer::updateOBB2(a1, v43);
v39 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
v8 = *v6;
if ( *v6 > 0.0
&& ((m_sectionXFactor = a1->m_sectionXFactor, v8 < 10000000.0)
? (v10 = (float)((float)(v8 * m_sectionXFactor) + -1.0) > 0.0)
: (v10 = (float)((float)(m_sectionXFactor * 10000000.0) + -1.0) > 0.0),
v10) )
{
if ( v8 <= 0.0 )
{
v37 = -1;
}
else
{
if ( v8 >= 10000000.0 )
{
v37 = (int)(float)((float)(m_sectionXFactor * 10000000.0) + -1.0);
v11 = v8 + v36->size.width;
if ( v11 <= 0.0 )
goto LABEL_8;
goto LABEL_15;
}
v37 = (int)(float)((float)(v8 * m_sectionXFactor) + -1.0);
}
}
else
{
v37 = 0;
}
v11 = v8 + v36->size.width;
if ( v11 <= 0.0 )
{
LABEL_8:
m_start = a1->m_sections.m_start;
m_finish = a1->m_sections.m_finish;
v14 = (float)(unsigned __int64)(m_finish - m_start - 1);
if ( v14 >= 1.0 )
goto LABEL_9;
goto LABEL_17;
}
LABEL_15:
v18 = a1->m_sectionXFactor;
if ( v11 >= 10000000.0 )
{
m_start = a1->m_sections.m_start;
m_finish = a1->m_sections.m_finish;
v14 = (float)(unsigned __int64)(m_finish - m_start - 1);
if ( (float)((float)(v18 * 10000000.0) + 1.0) > v14 )
goto LABEL_17;
}
else
{
m_start = a1->m_sections.m_start;
m_finish = a1->m_sections.m_finish;
v14 = (float)(unsigned __int64)(m_finish - m_start - 1);
if ( (float)((float)(v11 * v18) + 1.0) > v14 )
{
LABEL_17:
v35 = (int)v14;
goto LABEL_18;
}
}
if ( v11 <= 0.0 )
{
LABEL_9:
v35 = 1;
y = v36->origin.y;
if ( y <= 0.0 )
goto LABEL_10;
goto LABEL_19;
}
if ( v11 < 10000000.0 )
v35 = (int)(float)((float)(v11 * v18) + 1.0);
else
v35 = (int)(float)((float)(v18 * 10000000.0) + 1.0);
LABEL_18:
y = v36->origin.y;
if ( y <= 0.0 )
goto LABEL_10;
LABEL_19:
m_sectionYFactor = a1->m_sectionYFactor;
if ( y < 10000000.0 )
v20 = (float)((float)(y * m_sectionYFactor) + -1.0) > 0.0;
else
v20 = (float)((float)(m_sectionYFactor * 10000000.0) + -1.0) > 0.0;
if ( !v20 )
{
LABEL_10:
v34 = 0;
v16 = y + v36->size.height;
if ( v16 <= 0.0 )
goto LABEL_11;
goto LABEL_26;
}
if ( y <= 0.0 )
{
v34 = -1;
}
else if ( y < 10000000.0 )
{
v34 = (int)(float)((float)(y * m_sectionYFactor) + -1.0);
}
else
{
v34 = (int)(float)((float)(m_sectionYFactor * 10000000.0) + -1.0);
}
v16 = y + v36->size.height;
if ( v16 <= 0.0 )
{
LABEL_11:
v33 = 1;
if ( m_start == m_finish )
return v39;
goto LABEL_29;
}
LABEL_26:
if ( v16 < 10000000.0 )
v33 = (int)(float)((float)(v16 * a1->m_sectionYFactor) + 1.0);
else
v33 = (int)(float)((float)(a1->m_sectionYFactor * 10000000.0) + 1.0);
if ( m_start != m_finish )
{
LABEL_29:
if ( v37 > v35 )
return v39;
v40 = v37;
p_m_nonSquareRotation = &a1->m_nonSquareRotation;
v22 = m_start[v40];
if ( !v22 )
goto LABEL_58;
LABEL_31:
v23 = v22->m_finish - v22->m_start;
v24 = v23 - 1;
v25 = v23 - 1;
if ( v33 <= v24 )
v25 = v33;
for ( i = v25; v34 > i; i = -1 )
{
LABEL_56:
++v40;
if ( v35 < ++v37 )
return v39;
v22 = a1->m_sections.m_start[v40];
if ( v22 )
goto LABEL_31;
LABEL_58:
;
}
v26 = v34;
v27 = v34;
v41 = v34;
while ( 1 )
{
v28 = v22->m_start[v27];
if ( v28 )
{
v29 = a1->m_sectionSizes.m_start[v40]->m_start[v41];
if ( v29 > 0 )
break;
}
LABEL_54:
++v26;
++v27;
++v41;
if ( i < v26 )
goto LABEL_56;
v22 = a1->m_sections.m_start[v40];
}
v30 = 0;
v31 = 8 * ((unsigned int)(v29 - 1) + 1LL);
while ( 1 )
{
v32 = v28->m_start[v30 / 8];
if ( v4 )
{
LevelEditorLayer::getObjectRect(a1, v28->m_start[v30 / 8], 0, 0);
if ( *p_m_nonSquareRotation )
goto LABEL_40;
}
else
{
if ( !LevelEditorLayer::validGroup(a1, v28->m_start[v30 / 8], 1) )
goto LABEL_42;
LevelEditorLayer::getObjectRect(a1, v32, 0, 0);
if ( *p_m_nonSquareRotation )
goto LABEL_40;
}
if ( (unsigned __int8)cocos2d::CCRect::intersectsRect(v36, &v42) )
{
LABEL_41:
cocos2d::CCArray::addObject(v39, v32);
goto LABEL_42;
}
if ( !*p_m_nonSquareRotation )
goto LABEL_42;
LABEL_40:
if ( OBB2D::overlaps(a1->m_currentOBB2D) )
goto LABEL_41;
LABEL_42:
v30 += 8LL;
if ( v30 == v31 )
goto LABEL_54;
}
}
return v39;
}