//
// LevelTools::sortSpeedObjects from 0x140468480 to 0x140468822 (930 bytes)
//
// 6 xrefs:
// > EditorUI::onPlayback @ 0x1401b4318
// > LevelEditorLayer::updateGameObjects @ 0x1403fae95
// > PlayLayer::createObjectsFromSetupFinished @ 0x14050c536
// > ??> @ 0x1408cdc14
// > ??> @ 0x1408cdc4c
// > ??> @ 0x140927f68
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:32:35 +0000
//
void __fastcall LevelTools::sortSpeedObjects(cocos2d::CCArray *a1, __int64 a2)
{
unsigned int *v4; // rdi
__int64 v5; // rax
unsigned int **v6; // rdi
unsigned int **i; // r14
unsigned int *v8; // rbx
__int64 v9; // rax
struct cocos2d::CCObject *Group; // rax
cocos2d::CCArray *v11; // rsi
struct cocos2d::CCObject *v12; // rax
const struct cocos2d::CCPoint *v13; // rax
__int64 v14; // rax
bool v15; // di
bool v16; // r14
unsigned int *v17; // rax
__int64 v18; // rcx
_QWORD *v19; // rsi
_QWORD *v20; // r15
__int64 v21; // rbx
int v22; // ecx
int v23; // ecx
int v24; // ecx
int v25; // ecx
int v26; // ecx
int v27; // ecx
bool v28; // zf
int v29; // ecx
int v30; // ecx
int v31; // ecx
int v32; // ecx
const struct cocos2d::CCRect *v33; // rax
float v34; // xmm0_4
float v35; // xmm0_4
__int64 v36; // rax
int v37; // eax
int v38; // eax
int v39; // eax
char v40[8]; // [rsp+20h] [rbp-50h] BYREF
float v41[2]; // [rsp+28h] [rbp-48h] BYREF
float v42; // [rsp+30h] [rbp-40h]
float v43; // [rsp+34h] [rbp-3Ch]
float v44; // [rsp+A0h] [rbp+30h] BYREF
float v45; // [rsp+A4h] [rbp+34h]
char v46; // [rsp+A8h] [rbp+38h] BYREF
if ( cocos2d::CCArray::count(a1) )
{
if ( a1 )
{
v4 = *((unsigned int **)a1 + 7);
v5 = *v4;
if ( (_DWORD)v5 )
{
v6 = *((unsigned int ***)v4 + 2);
for ( i = &v6[v5 - 1]; v6 <= i; ++v6 )
{
v8 = *v6;
if ( !*v6 )
break;
v9 = (*(__int64 (__fastcall **)(unsigned int *, float *))(*(_QWORD *)v8 + 1664LL))(*v6, &v44);
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 )
v13 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(struct cocos2d::CCObject *, char *))(*(_QWORD *)v12 + 1664LL))(
v12,
&v46);
else
v13 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(unsigned int *, char *))(*(_QWORD *)v8 + 1664LL))(
v8,
v40);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v41, v13);
cocos2d::CCPoint::operator=(v8 + 479, v14);
}
}
}
}
LevelTools::sortChannelOrderObjects(a1, nullptr, 1);
v15 = 0;
v16 = 0;
if ( a1 )
{
v17 = *((unsigned int **)a1 + 7);
v18 = *v17;
if ( (_DWORD)v18 )
{
v19 = *((_QWORD **)v17 + 2);
v20 = &v19[v18 - 1];
if ( v19 <= v20 )
{
while ( 1 )
{
v21 = *v19;
if ( !*v19 )
goto LABEL_62;
v22 = *(_DWORD *)(v21 + 1036);
if ( v22 > 1330 )
break;
if ( v22 == 1330 )
goto LABEL_49;
if ( v22 > 201 )
{
v26 = v22 - 202;
if ( !v26 || (v27 = v26 - 1) == 0 )
{
LABEL_40:
if ( !*(_BYTE *)(v21 + 1490) )
{
v33 = (const struct cocos2d::CCRect *)(*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)v21 + 1184LL))(*v19);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v41, v33);
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v44,
(float)(v42 * 0.5) + v41[0],
(float)(v43 * 0.5) + v41[1]);
if ( v16 )
{
v35 = v43 * 0.5;
if ( v15 )
v45 = (float)(v45 - v35) - 15.0;
else
v45 = (float)(v35 + v45) + 15.0;
}
else
{
v34 = v42 * 0.5;
if ( v15 )
v44 = (float)(v34 + v44) + 15.0;
else
v44 = (float)(v44 - v34) - 15.0;
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v46, (const struct cocos2d::CCPoint *)&v44);
cocos2d::CCPoint::operator=(v21 + 1800, v36);
}
goto LABEL_49;
}
v28 = v27 == 819;
LABEL_38:
if ( v28 )
goto LABEL_49;
goto LABEL_39;
}
if ( v22 == 201 )
goto LABEL_40;
v23 = v22 - 36;
if ( !v23 )
goto LABEL_49;
v24 = v23 - 48;
if ( !v24 )
goto LABEL_49;
v25 = v24 - 57;
if ( !v25 )
goto LABEL_49;
if ( v25 == 59 )
goto LABEL_40;
LABEL_39:
if ( *(_BYTE *)(v21 + 1488) )
goto LABEL_40;
LABEL_49:
v37 = *(__int16 *)(v21 + 1798);
if ( v37 == -4 )
{
if ( !*(_BYTE *)(v21 + 1877) )
{
v38 = *(_DWORD *)(v21 + 1856);
v16 = v38 == 3 || v38 == 4;
v39 = *(_DWORD *)(v21 + 1860);
v15 = v39 == 1 || v39 == 3;
}
}
else if ( v37 == -1 )
{
v15 = !v15;
}
if ( ++v19 > v20 )
goto LABEL_62;
}
if ( v22 > 1704 )
{
v31 = v22 - 1751;
if ( !v31 )
goto LABEL_49;
v32 = v31 - 1151;
if ( !v32 )
goto LABEL_40;
v28 = v32 == 125;
}
else
{
if ( v22 == 1704 )
goto LABEL_49;
v29 = v22 - 1333;
if ( !v29 )
goto LABEL_49;
v30 = v29 - 1;
if ( !v30 )
goto LABEL_40;
v28 = v30 == 260;
}
goto LABEL_38;
}
}
}
LABEL_62:
LevelTools::sortChannelOrderObjects(a1, nullptr, 1);
}
}