//
// cocos2d::CCSpriteBatchNode::updateAtlasIndex from 0xb1734c to 0xb17564 (536 bytes)
//
// 4 xrefs:
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0xb173c8
// > cocos2d::CCSpriteBatchNode::updateAtlasIndex @ 0xb174c4
// > cocos2d::CCSpriteBatchNode::sortAllChildren @ 0xb176a4
// > ??> @ 0x8f688
//
// 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 cocos2d::CCSpriteBatchNode::updateAtlasIndex(cocos2d::CCSpriteBatchNode *a1, cocos2d::CCSprite *a2, int *a3)
{
cocos2d::CCArray *v6; // x0
cocos2d::CCArray *v7; // x21
cocos2d::ccArray *data; // x1
cocos2d::CCSprite **arr; // x19
__int64 v10; // x0
char *v11; // x21
cocos2d::CCSprite *v12; // x1
unsigned int v13; // w1
int v14; // w2
unsigned int m_uAtlasIndex; // w1
int v16; // w2
cocos2d::ccArray *v17; // x1
cocos2d::CCSprite **v18; // x21
__int64 v19; // x0
char *v20; // x24
cocos2d::CCSprite *v21; // x23
int v22; // w25
unsigned int v23; // w4
int v24; // w3
cocos2d::ccArray *v25; // x1
__int64 v26; // x0
v6 = a2->getChildren(a2);
v7 = v6;
if ( !v6 || (data = v6->data, !data->num) )
{
if ( a2->m_bDontDraw )
return;
goto LABEL_9;
}
if ( a2->m_bDontDraw )
{
arr = (cocos2d::CCSprite **)data->arr;
v10 = 8LL * data->num - 8;
v11 = (char *)arr + v10;
if ( arr <= (cocos2d::CCSprite **)((char *)arr + v10) )
{
do
{
v12 = *arr;
if ( !*arr )
break;
++arr;
cocos2d::CCSpriteBatchNode::updateAtlasIndex(a1, v12, a3);
}
while ( v11 >= (char *)arr );
}
return;
}
if ( ((*(__int64 (__fastcall **)(cocos2d::CCObject *))(**(_QWORD **)data->arr + 104LL))(*data->arr) & 0x80000000) != 0 )
{
v25 = v7->data;
if ( !v25->num )
goto LABEL_9;
v18 = (cocos2d::CCSprite **)v25->arr;
v26 = 8LL * v25->num - 8;
v20 = (char *)v18 + v26;
if ( v18 > (cocos2d::CCSprite **)((char *)v18 + v26) )
goto LABEL_9;
v21 = *v18;
v22 = 1;
if ( !*v18 )
goto LABEL_9;
goto LABEL_18;
}
m_uAtlasIndex = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
v16 = *a3;
if ( *a3 != m_uAtlasIndex )
{
cocos2d::CCSpriteBatchNode::swap(a1, m_uAtlasIndex, v16);
v16 = *a3;
}
v17 = v7->data;
*a3 = v16 + 1;
if ( v17->num )
{
v18 = (cocos2d::CCSprite **)v17->arr;
v19 = 8LL * v17->num - 8;
v20 = (char *)v18 + v19;
if ( v18 <= (cocos2d::CCSprite **)((char *)v18 + v19) )
{
v21 = *v18;
v22 = 0;
if ( *v18 )
{
do
{
LABEL_18:
if ( v22 && (((__int64 (__fastcall *)(cocos2d::CCSprite *))v21->getZOrder)(v21) & 0x80000000) == 0 )
{
v23 = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
v24 = *a3;
if ( *a3 != v23 )
{
cocos2d::CCSpriteBatchNode::swap(a1, v23, *a3);
v24 = *a3;
}
v22 = 0;
*a3 = v24 + 1;
}
++v18;
cocos2d::CCSpriteBatchNode::updateAtlasIndex(a1, v21, a3);
if ( v20 < (char *)v18 )
break;
v21 = *v18;
}
while ( *v18 );
if ( !v22 )
return;
LABEL_9:
v13 = a2->m_uAtlasIndex;
a2->m_uAtlasIndex = *a3;
v14 = *a3;
if ( *a3 != v13 )
{
cocos2d::CCSpriteBatchNode::swap(a1, v13, v14);
v14 = *a3;
}
*a3 = v14 + 1;
}
}
}
}