//
// cocos2d::CCComponentContainer::add from 0x1002c5170 to 0x1002c536f (511 bytes)
//
// 1 xrefs:
// > ??> @ 0x100907028
//
// 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 __fastcall cocos2d::CCComponentContainer::add(cocos2d::CCComponentContainer *a1, cocos2d::CCComponent *a2)
{
double v2; // xmm0_8
cocos2d::CCComponent *v3; // r14
cocos2d::CCDictionary *m_pComponents; // r15
cocos2d::CCDictionary *v5; // rax
const char *Name; // r13
size_t v7; // rax
size_t v8; // r12
char *v9; // rbx
size_t v10; // r14
const void *v11; // rax
bool v12; // r15
cocos2d::CCDictionary *v13; // rbx
const char *v14; // r13
size_t v15; // rax
size_t v16; // r12
char *v17; // rbx
size_t v18; // r14
cocos2d::CCComponent *v20; // [rsp+0h] [rbp-50h]
cocos2d::CCDictionary *v21; // [rsp+8h] [rbp-48h]
size_t __dst; // [rsp+10h] [rbp-40h] BYREF
size_t v23; // [rsp+18h] [rbp-38h]
void *__p; // [rsp+20h] [rbp-30h]
v3 = a2;
cocos2d::CCComponent::getOwner(a2);
m_pComponents = a1->m_pComponents;
if ( !m_pComponents )
{
v5 = cocos2d::CCDictionary::create();
a1->m_pComponents = v5;
cocos2d::CCObject::retain(v5);
m_pComponents = a1->m_pComponents;
}
Name = cocos2d::CCComponent::getName(a2);
v7 = strlen(Name);
if ( v7 >= 0xFFFFFFFFFFFFFFF8LL )
goto LABEL_29;
v8 = v7;
if ( v7 >= 0x17 )
{
v10 = 26;
if ( (v7 | 7) != 0x17 )
v10 = (v7 | 7) + 1;
v9 = (char *)operator new(v10);
__p = v9;
__dst = v10 + 1;
v3 = a2;
v23 = v8;
goto LABEL_10;
}
LOBYTE(__dst) = 2 * v7;
v9 = (char *)&__dst + 1;
if ( v7 )
LABEL_10:
memmove(v9, Name, v8);
v9[v8] = 0;
v11 = (const void *)cocos2d::CCDictionary::objectForKey_1(m_pComponents, &__dst);
if ( v11 )
{
v12 = __dynamic_cast(
v11,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCObject,
(const struct __class_type_info *)&`typeinfo for'cocos2d::CCComponent,
0) == nullptr;
if ( (__dst & 1) == 0 )
goto LABEL_14;
goto LABEL_13;
}
v12 = 1;
if ( (__dst & 1) != 0 )
LABEL_13:
operator delete(__p);
LABEL_14:
if ( !v12 )
return v12;
cocos2d::CCComponent::setOwner(v3, a1->m_pOwner);
v13 = a1->m_pComponents;
v14 = cocos2d::CCComponent::getName(v3);
v15 = strlen(v14);
if ( v15 >= 0xFFFFFFFFFFFFFFF8LL )
LABEL_29:
sub_100006BF0(v2);
v16 = v15;
v21 = v13;
if ( v15 >= 0x17 )
{
v20 = v3;
v18 = 26;
if ( (v15 | 7) != 0x17 )
v18 = (v15 | 7) + 1;
v17 = (char *)operator new(v18);
__p = v17;
__dst = v18 + 1;
v3 = v20;
v23 = v16;
}
else
{
LOBYTE(__dst) = 2 * v15;
v17 = (char *)&__dst + 1;
if ( !v15 )
goto LABEL_25;
}
memmove(v17, v14, v16);
LABEL_25:
v17[v16] = 0;
cocos2d::CCDictionary::setObject_1(v21, v3, &__dst);
if ( (__dst & 1) != 0 )
operator delete(__p);
((void (__fastcall *)(cocos2d::CCComponent *))v3->onEnter)(v3);
return v12;
}