//
// cocos2d::CCSpriteBatchNode::insertChild from 0x18008e7b0 to 0x18008ea44 (660 bytes)
//
// 4 xrefs:
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x18008e96c
// > cocos2d::CCSpriteBatchNode::insertChild @ 0x18008ea18
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b6030
//
// 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::CCSpriteBatchNode::insertChild(
cocos2d::CCSpriteBatchNode *this,
struct cocos2d::CCSprite *a2,
unsigned int a3)
{
cocos2d::CCSprite_vtbl *v6; // rax
__int64 v7; // rdx
int v8; // ebx
cocos2d::CCTextureAtlas *m_pobTextureAtlas; // rcx
__int128 v10; // xmm1
__int128 v11; // xmm0
__int128 v12; // xmm1
__int128 v13; // xmm0
__int128 v14; // xmm1
cocos2d::ccArray *data; // rbx
__int64 j; // r8
cocos2d::CCObject *v17; // rdx
struct cocos2d::CCSprite **v18; // r14
__int64 v19; // rbx
unsigned __int64 k; // rdi
struct cocos2d::CCSprite *v21; // rbx
int v22; // eax
unsigned int v23; // eax
struct cocos2d::CCSprite **v24; // r14
__int64 v25; // rbx
unsigned __int64 i; // rdi
struct cocos2d::CCSprite *v27; // rbx
int v28; // eax
unsigned int v29; // eax
struct cocos2d::_ccV3F_C4B_T2F_Quad v30; // [rsp+20h] [rbp-98h] BYREF
((void (__fastcall *)(struct cocos2d::CCSprite *, cocos2d::CCSpriteBatchNode *))a2->setBatchNode)(a2, this);
v6 = a2->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
LOBYTE(v7) = 1;
a2->m_uAtlasIndex = a3;
((void (__fastcall *)(struct cocos2d::CCSprite *, __int64))v6->setDirty)(a2, v7);
if ( a2->m_bDontDraw )
{
if ( ((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) )
{
if ( **(_DWORD **)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56) )
{
v24 = *(struct cocos2d::CCSprite ***)(*(_QWORD *)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2)
+ 56)
+ 16LL);
v25 = **(unsigned int **)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56);
for ( i = *(_QWORD *)(*(_QWORD *)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56)
+ 16LL)
+ 8 * v25
- 8; (unsigned __int64)v24 <= i; ++v24 )
{
v27 = *v24;
if ( !*v24 )
break;
v28 = ((__int64 (__fastcall *)(struct cocos2d::CCSprite *))v27->getZOrder)(*v24);
v29 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(this, v27, v28);
cocos2d::CCSpriteBatchNode::insertChild(this, v27, v29);
}
}
}
}
else
{
v8 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))this->m_pobTextureAtlas->getCapacity)(this->m_pobTextureAtlas);
if ( ((unsigned int (__fastcall *)(cocos2d::CCTextureAtlas *))this->m_pobTextureAtlas->getTotalQuads)(this->m_pobTextureAtlas) == v8 )
cocos2d::CCSpriteBatchNode::increaseAtlasCapacity(this);
m_pobTextureAtlas = this->m_pobTextureAtlas;
v10 = *(_OWORD *)&a2->m_sQuad.tl.texCoords.u;
*(_OWORD *)&v30.tl.vertices.x = *(_OWORD *)&a2->m_sQuad.tl.vertices.x;
v11 = *(_OWORD *)&a2->m_sQuad.bl.vertices.z;
*(_OWORD *)&v30.tl.texCoords.u = v10;
v12 = *(_OWORD *)&a2->m_sQuad.tr.vertices.x;
*(_OWORD *)&v30.bl.vertices.z = v11;
v13 = *(_OWORD *)&a2->m_sQuad.tr.texCoords.u;
*(_OWORD *)&v30.tr.vertices.x = v12;
v14 = *(_OWORD *)&a2->m_sQuad.br.vertices.z;
*(_OWORD *)&v30.tr.texCoords.u = v13;
*(_OWORD *)&v30.br.vertices.z = v14;
cocos2d::CCTextureAtlas::insertQuad(m_pobTextureAtlas, &v30, a3);
data = this->m_pobDescendants->data;
sub_18009DBB0(data, a2, a3);
for ( j = a3 + 1; (unsigned int)j < data->num; ++v17[6].m_uAutoReleaseCount )
{
v17 = data->arr[j];
j = (unsigned int)(j + 1);
}
if ( ((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) )
{
if ( **(_DWORD **)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56) )
{
v18 = *(struct cocos2d::CCSprite ***)(*(_QWORD *)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2)
+ 56)
+ 16LL);
v19 = **(unsigned int **)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56);
for ( k = *(_QWORD *)(*(_QWORD *)(((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2) + 56)
+ 16LL)
+ 8 * v19
- 8; (unsigned __int64)v18 <= k; ++v18 )
{
v21 = *v18;
if ( !*v18 )
break;
v22 = ((__int64 (__fastcall *)(struct cocos2d::CCSprite *))v21->getZOrder)(*v18);
v23 = cocos2d::CCSpriteBatchNode::atlasIndexForChild(this, v21, v22);
cocos2d::CCSpriteBatchNode::insertChild(this, v21, v23);
}
}
}
}
}