//
// LevelTools::sortChannelOrderObjects from 0x41f55c to 0x41f71c (448 bytes)
//
// 4 xrefs:
// > LevelTools::sortSpeedObjects @ 0x41f764
// > LevelTools::sortSpeedObjects @ 0x41f7ca
// > LevelEditorLayer::updateGameObjects @ 0x46cac8
// > GJBaseGameLayer::orderSpawnObjects @ 0x597f60
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:48:00 +0000
//
cocos2d::CCDictionary *__fastcall LevelTools::sortChannelOrderObjects(
cocos2d::CCDictionary *this,
cocos2d::CCArray *a2,
cocos2d::CCDictionary *a3,
bool a4)
{
cocos2d::CCDictionary *v5; // r5
cocos2d::CCDictionary *v6; // r0
_DWORD *v7; // r2
cocos2d::CCDictionary *v8; // r9
int *v9; // r7
int *v10; // r11
int v11; // r8
int v12; // t1
_DWORD *v13; // r2
cocos2d::CCObject **v14; // r7
cocos2d::CCObject **v15; // r8
cocos2d::CCObject *v16; // r11
cocos2d::CCObject *v17; // t1
unsigned int v18; // r8
cocos2d::CCArray *v19; // r7
int v20; // r11
int v21; // r0
int v22; // r10
int v23; // r3
int (**v24)(const void *, const void *); // r2
unsigned int v25; // r6
int v26; // r3
int v27; // r0
cocos2d::CCArray *v28; // r0
int v29; // r10
cocos2d::CCObject *v30; // r8
int v31; // r10
cocos2d::CCArray *v32; // r3
int (*ObjectDirection)(const void *, const void *); // [sp+0h] [bp-Ch]
int (*v34)(const void *, const void *); // [sp+0h] [bp-Ch]
v5 = this;
if ( !this )
return this;
v6 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(this);
v7 = *((_DWORD **)v5 + 13);
v8 = v6;
if ( *v7 )
{
v9 = (int *)v7[3];
v10 = &v9[*v7 - 1];
while ( v9 <= v10 )
{
v12 = *v9++;
v11 = v12;
if ( !v12 )
break;
if ( *(_DWORD *)(v11 + 892) == 2900 )
{
if ( *(_BYTE *)(v11 + 1668) )
{
v29 = *(_DWORD *)(v11 + 1672);
v6 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::objectForKey(v8, v29);
if ( !v6 )
{
ObjectDirection = (int (*)(const void *, const void *))GameObject::getObjectDirection((GameObject *)v11);
v30 = (cocos2d::CCObject *)operator new(0x38u);
cocos2d::CCObject::CCObject(v30);
*(_DWORD *)v30 = &off_C8DBE0;
*((_DWORD *)v30 + 13) = ObjectDirection;
cocos2d::CCObject::autorelease(v30);
v6 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::setObject(v8, v30, v29);
}
}
}
}
if ( a2 )
goto LABEL_8;
goto LABEL_7;
}
if ( !a2 )
{
LABEL_7:
a2 = (cocos2d::CCArray *)cocos2d::CCDictionary::create(v6);
LABEL_8:
v13 = *((_DWORD **)v5 + 13);
if ( *v13 )
{
v14 = (cocos2d::CCObject **)v13[3];
v15 = &v14[*v13] + 0x3FFFFFFF;
while ( v14 <= v15 )
{
v17 = *v14++;
v16 = v17;
if ( !v17 )
break;
v31 = *((_DWORD *)v16 + 398);
v32 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a2, v31);
if ( !v32 )
{
v34 = (int (*)(const void *, const void *))cocos2d::CCArray::create(nullptr);
cocos2d::CCDictionary::setObject(a2, (cocos2d::CCObject *)v34, v31);
v32 = (cocos2d::CCArray *)v34;
}
cocos2d::CCArray::addObject(v32, v16);
}
}
}
v18 = 0;
v19 = (cocos2d::CCArray *)cocos2d::CCDictionary::allKeys(a2);
while ( 1 )
{
this = (cocos2d::CCDictionary *)cocos2d::CCArray::count(v19);
if ( v18 >= (unsigned int)this )
break;
v20 = *(_DWORD *)(cocos2d::CCArray::objectAtIndex(v19, v18) + 52);
v21 = cocos2d::CCDictionary::objectForKey(v8, v20);
if ( v21 )
v22 = *(_DWORD *)(v21 + 52);
else
v22 = 4;
v23 = *(_DWORD *)(cocos2d::CCDictionary::objectForKey(a2, v20) + 52);
switch ( v22 )
{
case 2:
v24 = (int (**)(const void *, const void *))&compOrderYInv;
break;
case 3:
v24 = (int (**)(const void *, const void *))&compOrderXInv;
break;
case 1:
v24 = (int (**)(const void *, const void *))&compOrderY;
break;
default:
v24 = (int (**)(const void *, const void *))&compOrder;
break;
}
++v18;
qsort(*(void **)(v23 + 12), *(_DWORD *)v23, 4u, *v24);
}
if ( a3 )
{
v25 = 0;
cocos2d::CCArray::removeAllObjects(v5);
LevelTools::moveTriggerObjectsToArray(v5, a2, nullptr, v26);
while ( 1 )
{
this = (cocos2d::CCDictionary *)cocos2d::CCArray::count(v19);
if ( v25 >= (unsigned int)this )
break;
v27 = cocos2d::CCArray::objectAtIndex(v19, v25++);
v28 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a2, *(_DWORD *)(v27 + 52));
cocos2d::CCArray::addObjectsFromArray(v5, v28);
}
}
return this;
}