//
// cocos2d::CCComponentContainer::removeAll from 0x1002c5800 to 0x1002c59cb (459 bytes)
//
// 1 xrefs:
// > ??> @ 0x100907040
//
// 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 cocos2d::CCComponentContainer::removeAll(cocos2d::CCComponentContainer *a1)
{
cocos2d::CCDictionary *m_pComponents; // rax
cocos2d::CCDictElement *m_pElements; // r14
char *prev; // rax
cocos2d::CCDictElement *next; // r15
cocos2d::CCDictionary *v6; // rcx
cocos2d::CCDictElement *v7; // rdx
UT_hash_table *tbl; // rdi
std::ptrdiff_t hho; // rsi
cocos2d::CCDictElement **p_m_pElements; // rcx
cocos2d::CCDictElement *v11; // rdi
cocos2d::CCDictElement **v12; // rsi
UT_hash_table *v13; // rcx
UT_hash_bucket *buckets; // rdx
__int64 v15; // rax
UT_hash_handle *hh_prev; // rax
UT_hash_handle *hh_next; // rdx
m_pComponents = a1->m_pComponents;
if ( m_pComponents )
{
m_pElements = m_pComponents->m_pElements;
if ( !m_pElements )
{
LABEL_3:
cocos2d::CCNode::unscheduleUpdate(a1->m_pOwner);
return;
}
while ( 1 )
{
prev = (char *)m_pElements->hh.prev;
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
if ( prev )
break;
v6 = a1->m_pComponents;
if ( next )
goto LABEL_9;
free(v6->m_pElements->hh.tbl->buckets);
free(a1->m_pComponents->m_pElements->hh.tbl);
a1->m_pComponents->m_pElements = nullptr;
LABEL_5:
((void (__fastcall *)(cocos2d::CCObject *))m_pElements->m_pObject->__vftable[1].~CCObject_0)(m_pElements->m_pObject);
cocos2d::CCComponent::setOwner((cocos2d::CCComponent *)m_pElements->m_pObject, nullptr);
cocos2d::CCObject::release(m_pElements->m_pObject);
sub_10030D9D0(m_pElements);
operator delete(m_pElements);
m_pElements = next;
if ( !next )
goto LABEL_3;
}
v6 = a1->m_pComponents;
LABEL_9:
v7 = v6->m_pElements;
tbl = v7->hh.tbl;
hho = tbl->hho;
if ( m_pElements == (cocos2d::CCDictElement *)((char *)tbl->tail - hho) )
tbl->tail = (UT_hash_handle *)&prev[hho];
p_m_pElements = &v6->m_pElements;
v11 = (cocos2d::CCDictElement *)m_pElements->hh.next;
v12 = (cocos2d::CCDictElement **)&prev[hho + 16];
if ( !prev )
{
v12 = p_m_pElements;
v7 = (cocos2d::CCDictElement *)m_pElements->hh.next;
}
*v12 = v11;
v13 = v7->hh.tbl;
if ( v11 )
*(_QWORD *)&v11->m_szKey[v13->hho + 8] = prev;
buckets = v13->buckets;
v15 = m_pElements->hh.hashv & (v13->num_buckets - 1);
--buckets[v15].count;
if ( buckets[v15].hh_head == &m_pElements->hh )
{
buckets[v15].hh_head = m_pElements->hh.hh_next;
hh_prev = m_pElements->hh.hh_prev;
hh_next = m_pElements->hh.hh_next;
if ( !hh_prev )
goto LABEL_18;
}
else
{
hh_prev = m_pElements->hh.hh_prev;
hh_next = m_pElements->hh.hh_next;
if ( !hh_prev )
{
LABEL_18:
if ( hh_next )
hh_next->hh_prev = hh_prev;
--v13->num_items;
goto LABEL_5;
}
}
hh_prev->hh_next = hh_next;
goto LABEL_18;
}
}