//
// cocos2d::CCSpriteBatchNode::removeSpriteFromAtlas from 0x18008ee50 to 0x18008efaa (346 bytes)
//
// 9 xrefs:
// > cocos2d::CCSprite::removeAllChildrenWithCleanup @ 0x18008c078
// > cocos2d::CCSprite::removeChild @ 0x18008c0e5
// > cocos2d::CCSpriteBatchNode::removeChild @ 0x18008ee1e
// > cocos2d::CCSpriteBatchNode::removeSpriteFromAtlas @ 0x18008ef23
// > cocos2d::CCSpriteBatchNode::removeSpriteFromAtlas @ 0x18008ef8c
// > ??> @ 0x18013d80c
// > ??> @ 0x18013d81c
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b60d8
//
// 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::removeSpriteFromAtlas(
cocos2d::CCSpriteBatchNode *this,
struct cocos2d::CCSprite *a2)
{
unsigned int m_unknown2; // ebp
unsigned int v5; // esi
__int64 v6; // r8
cocos2d::CCArray *v7; // rax
cocos2d::CCArray *v8; // rbx
cocos2d::ccArray *v9; // rbx
__int64 v10; // rax
struct cocos2d::CCSprite **v11; // rbx
struct cocos2d::CCSprite **j; // rsi
cocos2d::CCArray *v13; // rax
cocos2d::CCArray *v14; // rbx
cocos2d::ccArray *data; // rbx
__int64 num; // rax
struct cocos2d::CCSprite **arr; // rbx
struct cocos2d::CCSprite **i; // rsi
if ( a2->m_bDontDraw )
{
v13 = (cocos2d::CCArray *)((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2);
v14 = v13;
if ( v13 )
{
if ( (unsigned int)cocos2d::CCArray::count(v13) )
{
data = v14->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (struct cocos2d::CCSprite **)data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
if ( !*arr )
break;
cocos2d::CCSpriteBatchNode::removeSpriteFromAtlas(this, *arr);
}
}
}
}
}
else
{
m_unknown2 = a2->m_unknown2;
if ( m_unknown2 != -1 )
{
v5 = cocos2d::CCArray::count(this->m_pobDescendants) - 1;
if ( m_unknown2 < v5 )
cocos2d::CCSpriteBatchNode::swap(this, m_unknown2, v5);
cocos2d::CCTextureAtlas::removeQuadAtIndex(this->m_pobTextureAtlas, v5);
this->m_bReorderChildDirty = 1;
((void (__fastcall *)(struct cocos2d::CCSprite *, _QWORD))a2->setBatchNode)(a2, 0);
LOBYTE(v6) = 1;
sub_18009DF50(this->m_pobDescendants->data, this->m_pobDescendants->data->num - 1, v6);
v7 = (cocos2d::CCArray *)((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2);
v8 = v7;
if ( v7 )
{
if ( (unsigned int)cocos2d::CCArray::count(v7) )
{
v9 = v8->data;
v10 = v9->num;
if ( (_DWORD)v10 )
{
v11 = (struct cocos2d::CCSprite **)v9->arr;
for ( j = &v11[v10 - 1]; v11 <= j; ++v11 )
{
if ( !*v11 )
break;
cocos2d::CCSpriteBatchNode::removeSpriteFromAtlas(this, *v11);
}
}
}
}
}
}
}