//
// LevelTools::sortChannelOrderObjects from 0x140468200 to 0x14046847a (634 bytes)
//
// 8 xrefs:
// > GJBaseGameLayer::orderSpawnObjects @ 0x140350127
// > LevelEditorLayer::updateGameObjects @ 0x1403faec1
// > LevelTools::sortSpeedObjects @ 0x1404685af
// > LevelTools::sortSpeedObjects @ 0x1404687f9
// > ??> @ 0x1408cdbc0
// > ??> @ 0x1408cdbd8
// > ??> @ 0x1408cdbe8
// > ??> @ 0x140927f38
//
// 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::sortChannelOrderObjects(cocos2d::CCArray *a1, cocos2d::CCDictionary *a2, char a3)
{
__int64 v5; // rax
__int64 v6; // rcx
unsigned int *v7; // rdi
cocos2d::CCDictionary *v8; // r12
__int64 v9; // rdx
__int64 *v10; // rdi
__int64 *i; // r14
__int64 v12; // rbx
__int64 v13; // rsi
int ObjectDirection; // eax
struct cocos2d::CCObject *v15; // rax
unsigned int *v16; // rbx
__int64 v17; // rax
int **v18; // rbx
int **j; // r15
int *v20; // rsi
__int64 v21; // r14
__int64 v22; // rcx
struct cocos2d::CCObject *v23; // rdi
unsigned int v24; // esi
cocos2d::CCArray *v25; // rdi
unsigned int v26; // r14d
__int64 v27; // r15
struct cocos2d::CCObject *v28; // rax
int v29; // ebx
void **v30; // rcx
int v31; // ebx
int v32; // ebx
int (__cdecl *v33)(const void *, const void *); // r9
struct cocos2d::CCObject *v34; // rax
struct cocos2d::CCArray *v35; // rax
if ( a1 )
{
v5 = cocos2d::CCDictionary::create(a1);
v7 = *((unsigned int **)a1 + 7);
v8 = (cocos2d::CCDictionary *)v5;
v9 = *v7;
if ( (_DWORD)v9 )
{
v10 = *((__int64 **)v7 + 2);
for ( i = &v10[v9 - 1]; v10 <= i; ++v10 )
{
v12 = *v10;
if ( !*v10 )
break;
if ( *(_DWORD *)(v12 + 1036) == 2900 )
{
if ( *(_BYTE *)(v12 + 1876) )
{
v13 = *(int *)(v12 + 1880);
if ( !cocos2d::CCDictionary::objectForKey(v8, v13) )
{
ObjectDirection = GameObject::getObjectDirection(v12);
v15 = cocos2d::CCInteger::create(ObjectDirection);
cocos2d::CCDictionary::setObject(v8, v15, v13);
}
}
}
}
}
if ( !a2 )
a2 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(v6);
v16 = *((unsigned int **)a1 + 7);
v17 = *v16;
if ( (_DWORD)v17 )
{
v18 = *((int ***)v16 + 2);
for ( j = &v18[v17 - 1]; v18 <= j; ++v18 )
{
v20 = *v18;
if ( !*v18 )
break;
v21 = v20[448];
v23 = cocos2d::CCDictionary::objectForKey(a2, v21);
if ( !v23 )
{
v23 = (struct cocos2d::CCObject *)cocos2d::CCArray::create(v22);
cocos2d::CCDictionary::setObject(a2, v23, v21);
}
cocos2d::CCArray::addObject(v23, (struct cocos2d::CCObject *)v20);
}
}
v24 = 0;
v25 = cocos2d::CCDictionary::allKeys(a2);
v26 = 0;
if ( cocos2d::CCArray::count(v25) )
{
while ( 1 )
{
v27 = *((int *)cocos2d::CCArray::objectAtIndex(v25, v26) + 14);
v28 = cocos2d::CCDictionary::objectForKey(v8, v27);
if ( !v28 )
break;
v29 = *((_DWORD *)v28 + 14);
v30 = *((void ***)cocos2d::CCDictionary::objectForKey(a2, v27) + 7);
v31 = v29 - 1;
if ( v31 )
{
v32 = v31 - 1;
if ( v32 )
{
if ( v32 != 1 )
goto LABEL_27;
v33 = (int (__cdecl *)(const void *, const void *))sub_14045FE00;
}
else
{
v33 = (int (__cdecl *)(const void *, const void *))sub_14045FF40;
}
}
else
{
v33 = (int (__cdecl *)(const void *, const void *))sub_14045FEA0;
}
LABEL_28:
qsort(v30[2], *(unsigned int *)v30, 8u, v33);
if ( ++v26 >= cocos2d::CCArray::count(v25) )
goto LABEL_29;
}
v30 = *((void ***)cocos2d::CCDictionary::objectForKey(a2, v27) + 7);
LABEL_27:
v33 = (int (__cdecl *)(const void *, const void *))sub_14045FD60;
goto LABEL_28;
}
LABEL_29:
if ( a3 )
{
cocos2d::CCArray::removeAllObjects(a1);
LevelTools::moveTriggerObjectsToArray(a1, a2, 0);
if ( cocos2d::CCArray::count(v25) )
{
do
{
v34 = cocos2d::CCArray::objectAtIndex(v25, v24);
v35 = cocos2d::CCDictionary::objectForKey(a2, *((int *)v34 + 14));
cocos2d::CCArray::addObjectsFromArray(a1, v35);
++v24;
}
while ( v24 < cocos2d::CCArray::count(v25) );
}
}
}
}