//
// LevelEditorLayer::resetUnusedColorChannels from 0x672e0c to 0x67308c (640 bytes)
//
// 2 xrefs:
// > EditorPauseLayer::doResetUnused @ 0x78bcb8
// > ??> @ 0x9f5e8
//
// 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 LevelEditorLayer::resetUnusedColorChannels(LevelEditorLayer *a1)
{
unsigned __int64 v2; // x0
__int64 *v3; // x1
cocos2d::CCArray *AllObjects; // x0
cocos2d::ccArray *data; // x1
GameObject **arr; // x19
GameObject **v7; // x22
GameObject *i; // x28
int SecondaryColorMode; // w0
cocos2d::CCArray *m_colorTriggers; // x0
cocos2d::ccArray *v11; // x1
cocos2d::CCDictionary *m_unkObject148; // x0
cocos2d::CCDictElement *m_pElements; // x0
_QWORD *next; // x19
int m_uUnknown; // w22
_QWORD *v16; // x0
GameObject **v17; // x19
GameObject **v18; // x22
GameObject *j; // x0
int MainColorMode; // [xsp+64h] [xbp+64h] BYREF
_QWORD *v21; // [xsp+68h] [xbp+68h]
_QWORD *v22; // [xsp+70h] [xbp+70h] BYREF
_QWORD *v23; // [xsp+78h] [xbp+78h] BYREF
_QWORD v24[4]; // [xsp+80h] [xbp+80h] BYREF
float v25; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v26; // [xsp+A8h] [xbp+A8h]
__int64 v27; // [xsp+B0h] [xbp+B0h] BYREF
v24[2] = 0;
v24[3] = 0;
v25 = 1.0;
v26 = 0;
v2 = sub_D146DC(&v25, 10);
v24[1] = v2;
if ( v2 == 1 )
{
v27 = 0;
v3 = &v27;
}
else
{
v3 = (__int64 *)sub_65C6D0(v2);
}
v24[0] = v3;
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( AllObjects )
{
data = AllObjects->data;
if ( data->num )
{
arr = (GameObject **)data->arr;
v7 = &arr[data->num - 1];
if ( arr <= v7 )
{
for ( i = *arr; *arr; i = *arr )
{
MainColorMode = GameObject::getMainColorMode(i);
SecondaryColorMode = GameObject::getSecondaryColorMode(i);
LODWORD(v23) = SecondaryColorMode;
if ( MainColorMode <= 999 )
{
v21 = v24;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v24,
&MainColorMode);
SecondaryColorMode = (int)v23;
}
if ( SecondaryColorMode <= 999 )
{
v22 = v24;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v24,
(int *)&v23);
}
if ( v7 < ++arr )
break;
}
}
}
}
m_colorTriggers = a1->m_colorTriggers;
if ( m_colorTriggers )
{
v11 = m_colorTriggers->data;
if ( v11->num )
{
v17 = (GameObject **)v11->arr;
v18 = &v17[v11->num - 1];
if ( v17 <= v18 )
{
for ( j = *v17; *v17; j = *v17 )
{
LODWORD(v22) = GameObject::getColorIndex(j);
if ( (int)v22 <= 999 )
{
v23 = v24;
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert>>>(
v24,
(int *)&v22);
}
if ( v18 < ++v17 )
break;
}
}
}
}
m_unkObject148 = a1->m_levelSettings->GJBaseGameLayer::m_effectManager->m_unkObject148;
if ( m_unkObject148 )
{
m_pElements = m_unkObject148->m_pElements;
if ( m_pElements )
{
next = m_pElements->hh.next;
m_uUnknown = m_pElements->m_pObject[1].m_uUnknown;
if ( (unsigned int)(m_uUnknown - 1) <= 0x3E6 )
goto LABEL_20;
LABEL_18:
while ( next )
{
while ( 1 )
{
v16 = next;
next = (_QWORD *)next[36];
m_uUnknown = *(_DWORD *)(v16[33] + 92LL);
if ( (unsigned int)(m_uUnknown - 1) > 0x3E6 )
break;
LABEL_20:
if ( sub_65B9F4(v24, m_uUnknown) )
goto LABEL_18;
GJEffectManager::removeColorAction(a1->m_levelSettings->GJBaseGameLayer::m_effectManager, m_uUnknown);
if ( !next )
goto LABEL_22;
}
}
}
}
LABEL_22:
std::_Hashtable,std::__detail::_Identity,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::~_Hashtable((__int64)v24);
}