//
// cocos2d::CCTMXLayer::insertTileForGID from 0xb39458 to 0xb39638 (480 bytes)
//
// 2 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0xb39f98
// > ??> @ 0x73590
//
// 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
//
cocos2d::CCSprite *cocos2d::CCTMXLayer::insertTileForGID(
cocos2d::CCTMXLayer *a1,
unsigned int a2,
const cocos2d::CCPoint *a3)
{
cocos2d::CCDirector *v6; // x0
float v7; // s10
cocos2d::CCDirector *v8; // x0
cocos2d::CCDirector *v9; // x0
cocos2d::CCDirector *v10; // x0
float ContentScaleFactor; // s0
__int64 v12; // x21
cocos2d::CCSprite *v13; // x23
unsigned int v14; // w25
cocos2d::CCArray *m_pChildren; // x0
cocos2d::CCArray *v16; // x0
cocos2d::ccArray *data; // x0
unsigned int num; // w1
cocos2d::CCObject **arr; // x0
cocos2d::CCObject **i; // x2
cocos2d::CCObject *v21; // x20
unsigned int m_uAutoReleaseCount; // w1
float v24; // [xsp+60h] [xbp+60h]
float v25; // [xsp+70h] [xbp+70h]
cocos2d::CCRect v26; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCRect v27; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v28; // 0:s0.4,4:s1.4
cocos2d::CCRect v29; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4
cocos2d::CCTMXTilesetInfo::rectForGID(*(cocos2d::CCTMXTilesetInfo **)&a1[1].m_uAutoReleaseCount, a2);
v6 = cocos2d::CCDirector::sharedDirector();
v7 = v26.origin.x / cocos2d::CCDirector::getContentScaleFactor(v6);
v8 = cocos2d::CCDirector::sharedDirector();
v24 = v26.origin.y / cocos2d::CCDirector::getContentScaleFactor(v8);
v9 = cocos2d::CCDirector::sharedDirector();
v25 = v26.size.width / cocos2d::CCDirector::getContentScaleFactor(v9);
v10 = cocos2d::CCDirector::sharedDirector();
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v10);
cocos2d::CCRect::CCRect(&v27, v7, v24, v25, v26.size.height / ContentScaleFactor);
cocos2d::CCRect::operator=(&v26, (float *)&v27.origin);
v12 = (__int64)(float)(a3->x + (float)(a3->y * *(float *)(&a1->m_bManualSortAllChildrenDirty + 3)));
cocos2d::CCRect::CCRect(&v27, &v26);
v13 = cocos2d::CCTMXLayer::reusedTileWithRect(a1, v29);
cocos2d::CCPoint::CCPoint(&v27.origin, a3);
cocos2d::CCTMXLayer::setupTileSprite(a1, v13, v28, (unsigned int)&v27);
v14 = cocos2d::CCTMXLayer::atlasIndexForNewZ(a1, v12);
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(a1, v13, v14);
cocos2d::ccCArrayInsertValueAtIndex(*(_QWORD *)&a1[1].m_fSkewY, v12, v14);
m_pChildren = a1->m_pChildren;
if ( m_pChildren )
{
if ( (unsigned int)cocos2d::CCArray::count(m_pChildren) )
{
v16 = a1->m_pChildren;
if ( v16 )
{
data = v16->data;
num = data->num;
if ( data->num )
{
arr = data->arr;
for ( i = &arr[num - 1]; i >= arr; ++arr )
{
v21 = *arr;
if ( !*arr )
break;
m_uAutoReleaseCount = v21[6].m_uAutoReleaseCount;
if ( v14 <= m_uAutoReleaseCount )
v21[6].m_uAutoReleaseCount = m_uAutoReleaseCount + 1;
}
}
}
}
}
*(_DWORD *)(*(_QWORD *)&a1[1].m_nTag + 4 * v12) = a2;
return v13;
}