//
// LevelTools::sortChannelOrderObjects from 0x1001a9768 to 0x1001a99dc (628 bytes)
//
// 5 xrefs:
// > LevelTools::sortSpeedObjects @ 0x1001a9ac0
// > LevelTools::sortSpeedObjects @ 0x1001a9d08
// > LevelTools::sortSpeedObjects @ 0x1001a9d18
// > GJBaseGameLayer::orderSpawnObjects @ 0x1002074e0
// > LevelEditorLayer::updateGameObjects @ 0x1003588c0
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
void __fastcall LevelTools::sortChannelOrderObjects(cocos2d::CCArray *a1, cocos2d::CCDictionary *a2, bool a3)
{
cocos2d::CCDictionary *v5; // x22
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x21
unsigned __int64 v9; // x25
cocos2d::CCObject *v10; // x23
intptr_t m_nLuaID; // x24
int ObjectDirection; // w0
cocos2d::CCObject *v13; // x0
cocos2d::ccArray *v14; // x9
__int64 v15; // x8
cocos2d::CCObject **v16; // x21
unsigned __int64 v17; // x26
cocos2d::CCObject *v18; // x23
intptr_t m_unknown2; // x24
cocos2d::CCObject *v20; // x25
cocos2d::CCArray *v21; // x23
__int64 v22; // x24
intptr_t v23; // x25
cocos2d::CCObject *v24; // x0
int v25; // w27
cocos2d::CCObject *v26; // x0
int (__cdecl *v27)(const void *, const void *); // x3
__int64 v28; // x21
__int64 v29; // x0
cocos2d::CCObject *v30; // x0
if ( a1 )
{
v5 = cocos2d::CCDictionary::create();
data = a1->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v9 = (unsigned __int64)&arr[num - 1];
do
{
v10 = *arr;
if ( !*arr )
break;
if ( v10[18].m_uReference == 2900 && LOBYTE(v10[33].m_uID) == 1 )
{
m_nLuaID = v10[33].m_nLuaID;
if ( !cocos2d::CCDictionary::objectForKey(v5, m_nLuaID) )
{
ObjectDirection = GameObject::getObjectDirection((GameObject *)v10);
v13 = sub_10011C030(ObjectDirection);
cocos2d::CCDictionary::setObject(v5, v13, m_nLuaID);
}
}
++arr;
}
while ( (unsigned __int64)arr <= v9 );
}
if ( !a2 )
a2 = cocos2d::CCDictionary::create();
v14 = a1->data;
v15 = v14->num;
if ( (_DWORD)v15 )
{
v16 = v14->arr;
v17 = (unsigned __int64)&v16[v15 - 1];
do
{
v18 = *v16;
if ( !*v16 )
break;
m_unknown2 = v18[31].m_unknown2;
v20 = cocos2d::CCDictionary::objectForKey(a2, m_unknown2);
if ( !v20 )
{
v20 = (cocos2d::CCObject *)sub_10024A15C(0);
cocos2d::CCDictionary::setObject(a2, v20, m_unknown2);
}
sub_10024A2D0(v20, v18);
++v16;
}
while ( (unsigned __int64)v16 <= v17 );
}
v21 = cocos2d::CCDictionary::allKeys(a2);
if ( (unsigned int)sub_10024A36C(v21) )
{
v22 = 0;
while ( 1 )
{
v23 = *(int *)(sub_10024A388(v21, v22) + 56);
v24 = cocos2d::CCDictionary::objectForKey(v5, v23);
if ( !v24 )
break;
v25 = (int)v24[1].__vftable;
v26 = cocos2d::CCDictionary::objectForKey(a2, v23);
if ( v25 == 1 )
{
v27 = (int (__cdecl *)(const void *, const void *))sub_1001A6B34;
goto LABEL_29;
}
if ( v25 == 3 )
{
v27 = (int (__cdecl *)(const void *, const void *))sub_1001A6A9C;
goto LABEL_29;
}
if ( v25 != 2 )
goto LABEL_26;
v27 = (int (__cdecl *)(const void *, const void *))sub_1001A6BCC;
LABEL_29:
qsort(v26[1].~CCObject_0, (size_t)v26[1].copyWithZone, 8u, v27);
v22 = (unsigned int)(v22 + 1);
if ( (unsigned int)v22 >= (unsigned int)sub_10024A36C(v21) )
goto LABEL_30;
}
v26 = cocos2d::CCDictionary::objectForKey(a2, v23);
LABEL_26:
v27 = (int (__cdecl *)(const void *, const void *))sub_1001A6A04;
goto LABEL_29;
}
LABEL_30:
if ( a3 )
{
sub_10024A45C(a1);
LevelTools::moveTriggerObjectsToArray(a1, a2, 0);
if ( (unsigned int)sub_10024A36C(v21) )
{
v28 = 0;
do
{
v29 = sub_10024A388(v21, v28);
v30 = cocos2d::CCDictionary::objectForKey(a2, *(int *)(v29 + 56));
sub_10024A360(a1, v30);
v28 = (unsigned int)(v28 + 1);
}
while ( (unsigned int)v28 < (unsigned int)sub_10024A36C(v21) );
}
}
}
}