//
// LevelTools::sortChannelOrderObjects from 0x1005010f0 to 0x1005013b1 (705 bytes)
//
// 5 xrefs:
// > LevelEditorLayer::updateGameObjects @ 0x1000acf8b
// > GJBaseGameLayer::orderSpawnObjects @ 0x100141c27
// > LevelTools::sortSpeedObjects @ 0x1005014de
// > LevelTools::sortSpeedObjects @ 0x100501789
// > LevelTools::sortSpeedObjects @ 0x100501798
//
// 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 12:31:30 +0000
//
void __fastcall LevelTools::sortChannelOrderObjects(__int64 a1, _QWORD *a2, char a3)
{
unsigned int *v3; // rax
__int64 *v4; // r12
unsigned __int64 v5; // rbx
__int64 v6; // r13
__int64 v7; // r15
_DWORD *v8; // r13
_QWORD *v9; // rax
unsigned int *v10; // rax
__int64 *v11; // r12
unsigned __int64 v12; // r14
__int64 v13; // r15
__int64 v14; // r13
__int64 v15; // rax
__int64 v16; // rbx
__int64 v17; // r13
unsigned int v18; // r15d
int (__cdecl *v19)(const void *, const void *); // rcx
__int64 v20; // rbx
__int64 v21; // rax
int v22; // r14d
__int64 v23; // rax
unsigned int v24; // r15d
__int64 v25; // rax
__int64 v26; // rax
_QWORD *v28; // [rsp+18h] [rbp-38h]
int ObjectDirection; // [rsp+20h] [rbp-30h]
__int64 v30; // [rsp+20h] [rbp-30h]
if ( a1 )
{
v28 = cocos2d::CCDictionary::create();
v3 = *(unsigned int **)(a1 + 56);
if ( *v3 )
{
v4 = *((__int64 **)v3 + 2);
v5 = (unsigned __int64)&v4[*v3 - 1];
do
{
v6 = *v4;
if ( !*v4 )
break;
if ( *(_DWORD *)(v6 + 1028) == 2900 && *(_BYTE *)(v6 + 1860) == 1 )
{
v7 = *(int *)(v6 + 1864);
if ( !cocos2d::CCDictionary::objectForKey_1((__int64)v28, v7) )
{
ObjectDirection = GameObject::getObjectDirection(v6);
v8 = operator new(0x40u);
cocos2d::CCObject::CCObject((__int64)v8);
*(_QWORD *)v8 = off_100ABB920;
v8[14] = ObjectDirection;
cocos2d::CCObject::autorelease((__int64)v8);
cocos2d::CCDictionary::setObject_1((__int64)v28, (__int64)v8, v7);
}
}
++v4;
}
while ( (unsigned __int64)v4 <= v5 );
}
v9 = a2;
if ( !a2 )
v9 = cocos2d::CCDictionary::create();
v30 = (__int64)v9;
v10 = *(unsigned int **)(a1 + 56);
if ( *v10 )
{
v11 = *((__int64 **)v10 + 2);
v12 = (unsigned __int64)&v11[*v10 - 1];
do
{
v13 = *v11;
if ( !*v11 )
break;
v14 = *(int *)(v13 + 1776);
v15 = cocos2d::CCDictionary::objectForKey_1(v30, v14);
if ( !v15 )
{
v16 = sub_1007FE900(v30);
cocos2d::CCDictionary::setObject_1(v30, v16, v14);
v15 = v16;
}
sub_1007FEBF0(v15, v13);
++v11;
}
while ( (unsigned __int64)v11 <= v12 );
}
v17 = cocos2d::CCDictionary::allKeys(v30);
if ( (unsigned int)sub_1007FEF90(v17) )
{
v18 = 0;
while ( 1 )
{
v20 = *(int *)(sub_1007FEFE0(v17, v18) + 56);
v21 = cocos2d::CCDictionary::objectForKey_1((__int64)v28, v20);
if ( !v21 )
break;
v22 = *(_DWORD *)(v21 + 56);
v23 = cocos2d::CCDictionary::objectForKey_1(v30, v20);
switch ( v22 )
{
case 1:
v19 = (int (__cdecl *)(const void *, const void *))sub_1004FA330;
break;
case 3:
v19 = (int (__cdecl *)(const void *, const void *))sub_1004FA2A0;
break;
case 2:
v19 = (int (__cdecl *)(const void *, const void *))sub_1004FA3C0;
break;
default:
goto LABEL_28;
}
LABEL_21:
qsort(*(void **)(*(_QWORD *)(v23 + 56) + 16LL), **(unsigned int **)(v23 + 56), 8u, v19);
if ( ++v18 >= (unsigned int)sub_1007FEF90(v17) )
goto LABEL_30;
}
v23 = cocos2d::CCDictionary::objectForKey_1(v30, v20);
LABEL_28:
v19 = (int (__cdecl *)(const void *, const void *))sub_1004FA210;
goto LABEL_21;
}
LABEL_30:
if ( a3 )
{
sub_1007FF190(a1);
v24 = 0;
LevelTools::moveTriggerObjectsToArray(a1, v30, 0);
if ( (unsigned int)sub_1007FEF90(v17) )
{
do
{
v25 = sub_1007FEFE0(v17, v24);
v26 = cocos2d::CCDictionary::objectForKey_1(v30, *(int *)(v25 + 56));
sub_1007FEF70(a1, v26);
++v24;
}
while ( v24 < (unsigned int)sub_1007FEF90(v17) );
}
}
}
}