//
// GJBaseGameLayer::setGroupParent from 0x10013d690 to 0x10013d7cd (317 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::addToGroupParents @ 0x10013d92c
// > GJBaseGameLayer::loadGroupParentsFromString @ 0x10013de02
// > SetGroupIDLayer::onAddGroupParent @ 0x10031535a
//
// 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 GJBaseGameLayer::setGroupParent(GJBaseGameLayer *a1, GameObject *a2, int a3)
{
intptr_t v6; // r15
GameObject *v7; // rax
cocos2d::CCDictionary *m_parentGroupIDs; // rdi
intptr_t m_uniqueID; // rsi
cocos2d::CCObject *v10; // rax
cocos2d::CCObject *v11; // r15
unsigned int v12; // r12d
cocos2d::CCObject *v13; // r12
if ( a3 > 0 && a2 != nullptr )
{
v6 = (unsigned int)a3;
v7 = (GameObject *)cocos2d::CCDictionary::objectForKey(a1->m_parentGroupsDict, (unsigned int)a3);
if ( v7 != a2 && (!v7 || !a1->m_keepGroupParents) )
{
GJBaseGameLayer::removeGroupParent(a1, a3);
cocos2d::CCDictionary::setObject(a1->m_parentGroupsDict, a2, v6);
m_parentGroupIDs = a1->m_parentGroupIDs;
m_uniqueID = (unsigned int)a2->m_uniqueID;
v10 = cocos2d::CCDictionary::objectForKey(m_parentGroupIDs, m_uniqueID);
v11 = v10;
if ( v10 )
{
if ( !(unsigned int)sub_100720070(v10) )
goto LABEL_12;
}
else
{
v11 = (cocos2d::CCObject *)sub_10071F9E0(m_parentGroupIDs, m_uniqueID);
cocos2d::CCDictionary::setObject(a1->m_parentGroupIDs, v11, (unsigned int)a2->m_uniqueID);
if ( !(unsigned int)sub_100720070(v11) )
{
LABEL_12:
v13 = (cocos2d::CCObject *)operator new(0x40u);
cocos2d::CCObject::CCObject(v13);
v13->__vftable = (cocos2d::CCObject_vtbl *)off_1008B8348;
LODWORD(v13[1].__vftable) = a3;
cocos2d::CCObject::autorelease(v13);
sub_10071FCD0(v11, v13);
LABEL_13:
a2->m_hasGroupParentsString = 1;
return;
}
}
v12 = 0;
while ( *(_DWORD *)(sub_1007200C0(v11, v12) + 56) != a3 )
{
if ( ++v12 >= (unsigned int)sub_100720070(v11) )
goto LABEL_12;
}
goto LABEL_13;
}
}
}