//
// cocos2d::CCComponentContainer::add from 0xb2f31c to 0xb2f514 (504 bytes)
//
// 2 xrefs:
// > ??> @ 0xbe1d0
// > ??> @ 0x1219a38
//
// 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
//
bool cocos2d::CCComponentContainer::add(cocos2d::CCComponentContainer *a1, cocos2d::CCComponent *a2)
{
cocos2d::CCDictionary *m_pComponents; // x22
char *Name; // x0
const void *v6; // x0
void *v7; // x25
const char *v8; // x1
char *v9; // x0
bool result; // w0
unsigned int *v11; // x1
int v12; // w2
cocos2d::CCDictionary *v13; // x23
char *v14; // x0
char *v15; // x0
cocos2d::CCDictionary *v16; // x0
unsigned int *v17; // x1
int v18; // w2
_QWORD v19[2]; // [xsp+0h] [xbp+0h] BYREF
const char *v20; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCComponent::getOwner(a2);
m_pComponents = a1->m_pComponents;
if ( !m_pComponents )
{
v16 = cocos2d::CCDictionary::create();
a1->m_pComponents = v16;
cocos2d::CCObject::retain(v16);
m_pComponents = a1->m_pComponents;
}
Name = (char *)cocos2d::CCComponent::getName(a2);
sub_D153B8((unsigned int)v19 + 96, Name);
v6 = (const void *)cocos2d::CCDictionary::objectForKey((__int64)m_pComponents, &v20);
if ( v6 )
{
v7 = _dynamic_cast(
v6,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCComponent,
0);
v8 = v20;
v9 = (char *)(v20 - 24);
if ( v20 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_5;
}
else
{
v8 = v20;
v7 = nullptr;
v9 = (char *)(v20 - 24);
if ( v20 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_5;
}
if ( &pthread_create )
{
v11 = (unsigned int *)(v8 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v8 - 2);
*((_DWORD *)v8 - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v9);
LABEL_5:
result = 0;
if ( !v7 )
{
cocos2d::CCComponent::setOwner(a2, a1->m_pOwner);
v13 = a1->m_pComponents;
v14 = (char *)cocos2d::CCComponent::getName(a2);
sub_D153B8((unsigned int)v19 + 96, v14);
cocos2d::CCDictionary::setObject((__int64)v13, a2, &v20);
v15 = (char *)(v20 - 24);
if ( v20 - 24 != (const char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v20 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v20 - 2);
*((_DWORD *)v20 - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v15);
}
a2->onEnter(a2);
return 1;
}
return result;
}