//
// LevelTools::sortChannelOrderObjects from 0x72c8e8 to 0x72cc30 (840 bytes)
//
// 6 xrefs:
// > LevelTools::sortSpeedObjects @ 0x72cc8c
// > LevelTools::sortSpeedObjects @ 0x72cdc8
// > LevelTools::sortSpeedObjects @ 0x72cfb8
// > LevelEditorLayer::updateGameObjects @ 0x79e368
// > GJBaseGameLayer::orderSpawnObjects @ 0x9ab594
// > ??> @ 0xcbf20
//
// This function is hookable on this platform (idp: arm, 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:52:34 +0000
//
__int64 __fastcall LevelTools::sortChannelOrderObjects(
LevelTools *this,
cocos2d::CCArray *a2,
cocos2d::CCDictionary *a3)
{
__int64 result; // x0
cocos2d::CCDictionary *v6; // x22
unsigned int *v7; // x1
__int64 v8; // x0
unsigned int v9; // w19
cocos2d::CCArray *v10; // x20
__int64 v11; // x26
__int64 v12; // x3
__int64 v13; // x1
int v14; // w26
__int64 v15; // x0
int **v16; // x19
char *v17; // x24
int *v18; // x20
unsigned int *v19; // x1
__int64 v20; // x0
int *v21; // x25
__int64 v22; // x27
cocos2d::CCObject *v23; // x20
unsigned int v24; // w19
unsigned int v25; // w1
__int64 v26; // x0
cocos2d::CCArray *v27; // x0
__int64 v28; // x27
int ObjectDirection; // w28
cocos2d::CCObject *v30; // x20
unsigned int v31; // [xsp+6Ch] [xbp+6Ch]
result = (unsigned __int8)a3;
v31 = (unsigned __int8)a3;
if ( !this )
return result;
v6 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create((cocos2d::CCDictionary *)(unsigned __int8)a3);
v7 = *((unsigned int **)this + 7);
v8 = *v7;
if ( !(_DWORD)v8
|| (v16 = *((int ***)v7 + 2),
v8 = 8LL * (unsigned int)v8 - 8,
v17 = (char *)v16 + v8,
v16 > (int **)((char *)v16 + v8)) )
{
if ( a2 )
goto LABEL_4;
goto LABEL_39;
}
v18 = *v16;
if ( !*v16 )
{
if ( a2 )
{
do
{
LABEL_26:
v21 = *v16;
if ( !*v16 )
break;
v22 = v21[444];
v23 = (cocos2d::CCObject *)cocos2d::CCDictionary::objectForKey(a2, v22);
if ( !v23 )
{
v23 = (cocos2d::CCObject *)cocos2d::CCArray::create(nullptr);
cocos2d::CCDictionary::setObject(a2, v23, v22);
}
++v16;
cocos2d::CCArray::addObject(v23, (cocos2d::CCObject *)v21);
}
while ( v17 >= (char *)v16 );
goto LABEL_4;
}
goto LABEL_39;
}
v8 = (unsigned int)v18[257];
if ( (_DWORD)v8 == 2900 )
goto LABEL_35;
while ( v17 >= (char *)++v16 )
{
v18 = *v16;
if ( !*v16 )
break;
v8 = (unsigned int)v18[257];
if ( (_DWORD)v8 == 2900 )
{
LABEL_35:
v8 = *((unsigned __int8 *)v18 + 1860);
if ( *((_BYTE *)v18 + 1860) )
{
v28 = v18[466];
v8 = cocos2d::CCDictionary::objectForKey(v6, v28);
if ( !v8 )
{
ObjectDirection = GameObject::getObjectDirection((GameObject *)v18);
v30 = (cocos2d::CCObject *)operator new(0x40u);
cocos2d::CCObject::CCObject(v30);
*((_DWORD *)v30 + 14) = ObjectDirection;
*(_QWORD *)v30 = &off_1428350;
cocos2d::CCObject::autorelease(v30);
v8 = cocos2d::CCDictionary::setObject(v6, v30, v28);
}
}
}
}
if ( !a2 )
LABEL_39:
a2 = (cocos2d::CCArray *)cocos2d::CCDictionary::create((cocos2d::CCDictionary *)v8);
v19 = *((unsigned int **)this + 7);
if ( *v19 )
{
v16 = *((int ***)v19 + 2);
v20 = 8LL * *v19 - 8;
v17 = (char *)v16 + v20;
if ( v16 <= (int **)((char *)v16 + v20) )
goto LABEL_26;
}
LABEL_4:
v9 = 0;
v10 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(a2);
if ( (unsigned int)cocos2d::CCArray::count(v10) )
{
do
{
v11 = *(int *)(cocos2d::CCArray::objectAtIndex(v10, v9) + 56);
v12 = cocos2d::CCDictionary::objectForKey(v6, v11);
v13 = v11;
if ( v12 )
{
v14 = *(_DWORD *)(v12 + 56);
v15 = cocos2d::CCDictionary::objectForKey(a2, v13);
switch ( v14 )
{
case 2:
++v9;
qsort(
*(void **)(*(_QWORD *)(v15 + 56) + 16LL),
**(unsigned int **)(v15 + 56),
8u,
(int (*)(const void *, const void *))compOrderYInv);
continue;
case 3:
++v9;
qsort(
*(void **)(*(_QWORD *)(v15 + 56) + 16LL),
**(unsigned int **)(v15 + 56),
8u,
(int (*)(const void *, const void *))compOrderXInv);
continue;
case 1:
++v9;
qsort(
*(void **)(*(_QWORD *)(v15 + 56) + 16LL),
**(unsigned int **)(v15 + 56),
8u,
(int (*)(const void *, const void *))compOrderY);
continue;
}
}
else
{
v15 = cocos2d::CCDictionary::objectForKey(a2, v11);
}
++v9;
qsort(
*(void **)(*(_QWORD *)(v15 + 56) + 16LL),
**(unsigned int **)(v15 + 56),
8u,
(int (*)(const void *, const void *))compOrder);
}
while ( v9 < (unsigned int)cocos2d::CCArray::count(v10) );
}
result = v31;
if ( v31 )
{
v24 = 0;
cocos2d::CCArray::removeAllObjects(this);
LevelTools::moveTriggerObjectsToArray(this, a2, nullptr);
while ( 1 )
{
result = cocos2d::CCArray::count(v10);
if ( v24 >= (unsigned int)result )
break;
v25 = v24++;
v26 = cocos2d::CCArray::objectAtIndex(v10, v25);
v27 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a2, *(int *)(v26 + 56));
cocos2d::CCArray::addObjectsFromArray(this, v27);
}
}
return result;
}