//
// cocos2d::CCSpriteBatchNode::updateAtlasIndex from 0x18008f2a0 to 0x18008f45d (445 bytes)
//
// 8 xrefs:
// > cocos2d::CCSpriteBatchNode::sortAllChildren @ 0x18008f160
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0x18008f314
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0x18008f3dc
// > ??> @ 0x18013d980
// > ??> @ 0x18013d990
// > ??> @ 0x18013d9a4
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b6144
//
// 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::updateAtlasIndex(
cocos2d::CCSpriteBatchNode *this,
struct cocos2d::CCSprite *a2,
int *a3)
{
__int64 v6; // rax
bool m_bDontDraw; // cl
__int64 v8; // rdi
unsigned int *v9; // r9
__int64 v10; // rcx
struct cocos2d::CCSprite **v11; // rdi
struct cocos2d::CCSprite **i; // rsi
char v13; // bp
unsigned int m_uAtlasIndex; // edx
unsigned int *v15; // rsi
__int64 v16; // rax
struct cocos2d::CCSprite **v17; // rsi
struct cocos2d::CCSprite **j; // r12
struct cocos2d::CCSprite *v19; // rdi
unsigned int v20; // edx
unsigned int v21; // edx
unsigned int v22; // edx
v6 = ((__int64 (__fastcall *)(struct cocos2d::CCSprite *))a2->getChildren)(a2);
m_bDontDraw = a2->m_bDontDraw;
v8 = v6;
if ( v6 && (v9 = *(unsigned int **)(v6 + 56), *v9) )
{
if ( m_bDontDraw )
{
v10 = *v9;
if ( (_DWORD)v10 )
{
v11 = *((struct cocos2d::CCSprite ***)v9 + 2);
for ( i = &v11[v10 - 1]; v11 <= i; ++v11 )
{
if ( !*v11 )
break;
cocos2d::CCSpriteBatchNode::updateAtlasIndex(this, *v11, a3);
}
}
}
else
{
v13 = 1;
if ( (*(int (__fastcall **)(_QWORD))(***((_QWORD ***)v9 + 2) + 96LL))(**((_QWORD **)v9 + 2)) >= 0 )
{
m_uAtlasIndex = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
if ( m_uAtlasIndex != *a3 )
cocos2d::CCSpriteBatchNode::swap(this, m_uAtlasIndex, *a3);
++*a3;
v13 = 0;
}
v15 = *(unsigned int **)(v8 + 56);
v16 = *v15;
if ( (_DWORD)v16 )
{
v17 = *((struct cocos2d::CCSprite ***)v15 + 2);
for ( j = &v17[v16 - 1]; v17 <= j; ++v17 )
{
v19 = *v17;
if ( !*v17 )
break;
if ( v13 && ((int (__fastcall *)(struct cocos2d::CCSprite *))v19->getZOrder)(*v17) >= 0 )
{
v20 = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
if ( v20 != *a3 )
cocos2d::CCSpriteBatchNode::swap(this, v20, *a3);
++*a3;
v13 = 0;
}
cocos2d::CCSpriteBatchNode::updateAtlasIndex(this, v19, a3);
}
}
if ( v13 )
{
v21 = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
if ( v21 != *a3 )
cocos2d::CCSpriteBatchNode::swap(this, v21, *a3);
++*a3;
}
}
}
else if ( !m_bDontDraw )
{
v22 = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
if ( v22 != *a3 )
cocos2d::CCSpriteBatchNode::swap(this, v22, *a3);
++*a3;
}
}