//
// PlayLayer::optimizeOpacityGroups from 0x5d836c to 0x5d850c (416 bytes)
//
// 2 xrefs:
// > PlayLayer::setupHasCompleted @ 0x5dc2e8
// > ??> @ 0xa7628
//
// 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 PlayLayer::optimizeOpacityGroups(PlayLayer *a1)
{
unsigned int v2; // w19
__int64 v3; // x2
std::_Rb_tree_node_base::_Base_ptr i; // x22
int M_color; // w21
cocos2d::CCArray *Group; // x20
unsigned int j; // w19
GameObject *v8; // x0
std::_Rb_tree_node_base::_Base_ptr M_parent; // x19
std::_Rb_tree_node_base::_Base_ptr v10; // x0
int v11; // [xsp+54h] [xbp+54h] BYREF
std::set v12; // [xsp+58h] [xbp+58h] BYREF
v2 = 0;
v12._M_t._M_impl._M_header._M_color = _S_red;
v12._M_t._M_impl._M_header._M_parent = nullptr;
v12._M_t._M_impl._M_node_count = 0;
v12._M_t._M_impl._M_header._M_left = &v12._M_t._M_impl._M_header;
v12._M_t._M_impl._M_header._M_right = &v12._M_t._M_impl._M_header;
while ( v2 < (unsigned int)cocos2d::CCArray::count(a1->m_objects) )
{
v3 = cocos2d::CCArray::objectAtIndex(a1->m_objects, v2);
if ( *(_DWORD *)(v3 + 1012) == 1007 )
{
v11 = *(_DWORD *)(v3 + 1448);
std::_Rb_tree,std::less,std::allocator>::_M_insert_unique(&v12, &v11);
}
++v2;
}
GJBaseGameLayer::addRemapTargets(a1, &v12);
for ( i = v12._M_t._M_impl._M_header._M_left;
i != &v12._M_t._M_impl._M_header;
i = (std::_Rb_tree_node_base::_Base_ptr)sub_CFAB74(i) )
{
M_color = i[1]._M_color;
Group = GJBaseGameLayer::getGroup(a1, M_color);
for ( j = 0; j < (unsigned int)cocos2d::CCArray::count(Group); ++j )
{
v8 = (GameObject *)cocos2d::CCArray::objectAtIndex(Group, j);
GameObject::addToOpacityGroup(v8, M_color);
}
}
M_parent = v12._M_t._M_impl._M_header._M_parent;
while ( M_parent )
{
std::_Rb_tree,std::less,std::allocator>::_M_erase(
(__int64)&v12,
M_parent->_M_right);
v10 = M_parent;
M_parent = M_parent->_M_left;
operator delete(v10);
}
}