//
// LevelEditorLayer::recreateGroups from 0x66089c to 0x660af4 (600 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::onResumePlaytest @ 0x661764
// > LevelEditorLayer::onPlaytest @ 0x664320
// > EditorUI::dynamicGroupUpdate @ 0x6c41ac
// > ??> @ 0xb6c88
//
// 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::recreateGroups(LevelEditorLayer *a1)
{
std::__detail::_Hash_node_base *M_nxt; // x19
std::__detail::_Hash_node_base *v3; // x21
std::__detail::_Hash_node_base *v4; // x0
std::__detail::_Hash_node_base *v5; // x0
std::__detail::_Hash_node_base *v6; // x19
std::__detail::_Hash_node_base *v7; // x21
std::__detail::_Hash_node_base *v8; // x0
std::__detail::_Hash_node_base *v9; // x0
__int64 v10; // x19
cocos2d::CCArray *m_collisionBlocks; // x0
cocos2d::CCArray *v12; // x0
cocos2d::CCArray *v13; // x0
cocos2d::CCArray *v14; // x1
cocos2d::CCDictionary *m_triggerGroupsDict; // x0
cocos2d::CCDictElement *m_pElements; // x0
cocos2d::CCDictElement *i; // x19
unsigned int v18; // w22
cocos2d::CCArray *AllObjects; // x23
int v20; // w19
LabelGameObject *v21; // x21
int v22; // w1
int GroupID; // w0
int m_objectID; // w0
GJBaseGameLayer::resetMoveOptimizedValue(a1);
M_nxt = a1->m_labelObjects._M_h._M_before_begin._M_nxt;
if ( M_nxt )
{
do
{
v3 = M_nxt->_M_nxt;
v4 = M_nxt[2]._M_nxt;
if ( v4 )
operator delete(v4);
v5 = M_nxt;
M_nxt = v3;
operator delete(v5);
}
while ( v3 );
}
memset(a1->m_labelObjects._M_h._M_buckets, 0, 8 * a1->m_labelObjects._M_h._M_bucket_count);
a1->m_labelObjects._M_h._M_before_begin._M_nxt = nullptr;
a1->m_labelObjects._M_h._M_element_count = 0;
v6 = a1->m_timeLabelObjects._M_h._M_before_begin._M_nxt;
if ( v6 )
{
do
{
v7 = v6->_M_nxt;
v8 = v6[2]._M_nxt;
if ( v8 )
operator delete(v8);
v9 = v6;
v6 = v7;
operator delete(v9);
}
while ( v7 );
}
v10 = 0;
memset(a1->m_timeLabelObjects._M_h._M_buckets, 0, 8 * a1->m_timeLabelObjects._M_h._M_bucket_count);
a1->m_timeLabelObjects._M_h._M_element_count = 0;
m_collisionBlocks = a1->m_collisionBlocks;
a1->m_timeLabelObjects._M_h._M_before_begin._M_nxt = nullptr;
cocos2d::CCArray::removeAllObjects(m_collisionBlocks);
cocos2d::CCArray::addObject(a1->m_collisionBlocks, a1->m_player1CollisionBlock);
cocos2d::CCArray::addObject(a1->m_collisionBlocks, a1->m_player2CollisionBlock);
do
{
v12 = a1->m_groups.m_start[v10];
if ( v12 )
cocos2d::CCArray::removeAllObjects(v12);
v13 = a1->m_staticGroups.m_start[v10];
if ( v13 )
cocos2d::CCArray::removeAllObjects(v13);
v14 = a1->m_optimizedGroups.m_start[v10++];
if ( v14 )
cocos2d::CCArray::removeAllObjects(v14);
}
while ( v10 != 10000 );
m_triggerGroupsDict = a1->m_triggerGroupsDict;
if ( m_triggerGroupsDict )
{
m_pElements = m_triggerGroupsDict->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
cocos2d::CCArray::removeAllObjects((cocos2d::CCArray *)m_pElements->m_pObject);
m_pElements = i;
if ( !i )
break;
}
}
}
v18 = 0;
AllObjects = LevelEditorLayer::getAllObjects(a1);
if ( (unsigned int)cocos2d::CCArray::count(AllObjects) )
{
do
{
v20 = 0;
v21 = (LabelGameObject *)cocos2d::CCArray::objectAtIndex(AllObjects, v18);
if ( v21->m_groupCount > 0 )
{
do
{
v22 = v20++;
GroupID = GameObject::getGroupID(v21, v22);
a1->addToGroup(a1, v21, GroupID, 1);
}
while ( v21->m_groupCount > v20 );
}
m_objectID = v21->m_objectID;
if ( m_objectID == 1615 )
{
++v18;
GJBaseGameLayer::addObjectCounter(a1, v21);
}
else if ( m_objectID == 1816 && v21->m_isDynamicBlock )
{
++v18;
cocos2d::CCArray::addObject(a1->m_collisionBlocks, v21);
}
else
{
++v18;
}
}
while ( v18 < (unsigned int)cocos2d::CCArray::count(AllObjects) );
}
if ( a1->m_levelSettings->m_sortGroups )
GJBaseGameLayer::sortAllGroupsX(a1);
}