//
// GJBaseGameLayer::groupStickyObjects from 0x8607c4 to 0x8608ec (296 bytes)
//
// 3 xrefs:
// > EditorUI::onGroupSticky @ 0x6b57d4
// > GJBaseGameLayer::assignNewStickyGroups @ 0x8609b4
// > ??> @ 0xc11b8
//
// 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 GJBaseGameLayer::groupStickyObjects(GJBaseGameLayer *a1, cocos2d::CCArray *a2)
{
cocos2d::CCArray *v4; // x0
unsigned int v5; // w1
cocos2d::CCArray *v6; // x22
unsigned int v7; // w19
unsigned int v8; // w21
bool v9; // cf
unsigned int v10; // w1
cocos2d::CCArray *v11; // x0
__int64 v12; // x0
unsigned int v13; // w19
unsigned int v14; // w1
cocos2d::CCArray *i; // x0
__int64 v16; // x3
int v17; // w0
v4 = (cocos2d::CCArray *)cocos2d::CCArray::count(a2);
v6 = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v4, v5);
v7 = 0;
v8 = 0;
v9 = (unsigned int)cocos2d::CCArray::count(a2) == 0;
v10 = 0;
v11 = a2;
if ( v9 )
{
LABEL_6:
if ( !v8 )
goto LABEL_16;
goto LABEL_7;
}
while ( 1 )
{
v12 = cocos2d::CCArray::objectAtIndex(v11, v10);
if ( v8 )
break;
v8 = *(_DWORD *)(v12 + 856);
LABEL_4:
v9 = ++v7 >= (unsigned int)cocos2d::CCArray::count(a2);
v10 = v7;
v11 = a2;
if ( v9 )
goto LABEL_6;
}
v17 = *(_DWORD *)(v12 + 856);
if ( v17 <= 0 || v17 == v8 )
goto LABEL_4;
GJBaseGameLayer::ungroupStickyObjects(a1, a2);
LABEL_16:
v8 = a1->m_lastUsedLinkedID + 1;
a1->m_lastUsedLinkedID = v8;
LABEL_7:
v13 = 0;
v9 = (unsigned int)cocos2d::CCArray::count(a2) == 0;
v14 = 0;
for ( i = a2; !v9; i = a2 )
{
v16 = cocos2d::CCArray::objectAtIndex(i, v14);
if ( ((*(_DWORD *)(v16 + 1012) - 747) & 0xFFFFFFFD) != 0 )
{
*(_DWORD *)(v16 + 856) = v8;
cocos2d::CCArray::addObject(v6, (cocos2d::CCObject *)v16);
}
v9 = ++v13 >= (unsigned int)cocos2d::CCArray::count(a2);
v14 = v13;
}
cocos2d::CCDictionary::setObject(a1->m_linkedGroupDict, v6, v8);
}