//
// LevelTools::sortSpeedObjects from 0x14032d930 to 0x14032dcbf (911 bytes)
//
// 6 xrefs:
// > EditorUI::onPlayback @ 0x140111c48
// > LevelEditorLayer::updateGameObjects @ 0x1402dc608
// > PlayLayer::createObjectsFromSetupFinished @ 0x1403adc12
// > ??> @ 0x140693b4c
// > ??> @ 0x140693b84
// > ??> @ 0x1406d4f04
//
// 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
//
void LevelTools::sortSpeedObjects(cocos2d::CCArray *a1, GJBaseGameLayer *a2)
{
cocos2d::ccArray *data; // rdi
__int64 num; // rax
int **arr; // rdi
int **i; // r14
int *v8; // rbx
__int64 v9; // rax
cocos2d::CCArray *Group; // rax
cocos2d::CCArray *v11; // rsi
struct cocos2d::CCObject *v12; // rax
__int64 v13; // rax
bool v14; // di
bool v15; // r15
cocos2d::ccArray *v16; // rax
__int64 v17; // rcx
cocos2d::CCObject **v18; // rsi
cocos2d::CCObject **v19; // r14
cocos2d::CCObject *v20; // rbx
int m_eObjType; // ecx
int v22; // ecx
int v23; // ecx
int v24; // ecx
int v25; // ecx
int v26; // ecx
bool v27; // zf
int v28; // ecx
int v29; // ecx
int v30; // ecx
int v31; // ecx
const struct cocos2d::CCRect *v32; // rax
double v33; // xmm0_8
float v34; // xmm0_4
float v35; // xmm0_4
__int64 v36; // rax
int v37; // eax
bool v38; // zf
char v39[8]; // [rsp+20h] [rbp-50h] BYREF
cocos2d::CCRect v40; // [rsp+28h] [rbp-48h] BYREF
float v41; // [rsp+A0h] [rbp+30h] BYREF
float v42; // [rsp+A4h] [rbp+34h]
cocos2d::CCPoint v43; // [rsp+A8h] [rbp+38h] BYREF
if ( cocos2d::CCArray::count(a1) )
{
if ( a1 )
{
data = a1->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (int **)data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v8 = *arr;
if ( !*arr )
break;
v9 = (*(__int64 (__fastcall **)(int *, float *))(*(_QWORD *)v8 + 1648LL))(*arr, &v41);
cocos2d::CCPoint::operator=(v8 + 450, v9);
if ( *((_WORD *)v8 + 899) == 0xFFFB )
{
Group = GJBaseGameLayer::getGroup(a2, v8[370]);
v11 = Group;
if ( Group && cocos2d::CCArray::count(Group) && (v12 = cocos2d::CCArray::randomObject(v11)) != nullptr )
v12->__vftable[22].setTag(v12, (int)&v43);
else
(*(void (__fastcall **)(int *, char *))(*(_QWORD *)v8 + 1648LL))(v8, v39);
cocos2d::CCPoint::CCPoint(&v40.origin);
cocos2d::CCPoint::operator=(v8 + 479, v13);
}
}
}
}
LevelTools::sortChannelOrderObjects(a1, nullptr, 1);
v14 = 0;
v15 = 0;
if ( a1 )
{
v16 = a1->data;
v17 = v16->num;
if ( (_DWORD)v17 )
{
v18 = v16->arr;
v19 = &v18[v17 - 1];
while ( v18 <= v19 )
{
v20 = *v18;
if ( !*v18 )
break;
m_eObjType = v20[18].m_eObjType;
if ( m_eObjType > 1330 )
{
if ( m_eObjType > 1704 )
{
v30 = m_eObjType - 1751;
if ( !v30 )
goto LABEL_49;
v31 = v30 - 1151;
if ( v31 )
{
v27 = v31 == 125;
goto LABEL_38;
}
}
else
{
if ( m_eObjType == 1704 )
goto LABEL_49;
v28 = m_eObjType - 1333;
if ( !v28 )
goto LABEL_49;
v29 = v28 - 1;
if ( v29 )
{
v27 = v29 == 260;
goto LABEL_38;
}
}
}
else
{
if ( m_eObjType == 1330 )
goto LABEL_49;
if ( m_eObjType <= 201 )
{
if ( m_eObjType == 201 )
goto LABEL_40;
v22 = m_eObjType - 36;
if ( !v22 )
goto LABEL_49;
v23 = v22 - 48;
if ( !v23 )
goto LABEL_49;
v24 = v23 - 57;
if ( !v24 )
goto LABEL_49;
if ( v24 == 59 )
goto LABEL_40;
goto LABEL_39;
}
v25 = m_eObjType - 202;
if ( v25 )
{
v26 = v25 - 1;
if ( v26 )
{
v27 = v26 == 819;
LABEL_38:
if ( v27 )
goto LABEL_49;
LABEL_39:
if ( !LOBYTE(v20[26].m_uIndexInArray) )
goto LABEL_49;
}
}
}
LABEL_40:
if ( !BYTE2(v20[26].m_uIndexInArray) )
{
v32 = (const struct cocos2d::CCRect *)((__int64 (__fastcall *)(cocos2d::CCObject *))v20->__vftable[16].isEqual)(*v18);
v33 = cocos2d::CCRect::CCRect(&v40, v32);
cocos2d::CCPoint::CCPoint(*(float *)&v33, (float)(v40.size.width * 0.5) + v40.origin.x);
if ( v15 )
{
v35 = v40.size.height * 0.5;
if ( v14 )
v42 = (float)(v42 - v35) - 15.0;
else
v42 = (float)(v35 + v42) + 15.0;
}
else
{
v34 = v40.size.width * 0.5;
if ( v14 )
v41 = (float)(v34 + v41) + 15.0;
else
v41 = (float)(v41 - v34) - 15.0;
}
cocos2d::CCPoint::CCPoint(&v43);
cocos2d::CCPoint::operator=(&v20[32].m_uID, v36);
}
LABEL_49:
v37 = SHIWORD(v20[32].__vftable);
if ( v37 == -4 )
{
if ( !BYTE1(v20[33].m_eObjType) )
{
v15 = v20[33].m_uID - 3 <= 1;
v38 = ((v20[33].m_nLuaID - 1) & 0xFFFFFFFD) == 0;
goto LABEL_54;
}
}
else if ( v37 == -1 )
{
v38 = !v14;
LABEL_54:
v14 = v38;
}
++v18;
}
}
}
LevelTools::sortChannelOrderObjects(a1, nullptr, 1);
}
}