//
// cocos2d::CCTMXLayer::insertTileForGID from 0x1800ac420 to 0x1800ac60f (495 bytes)
//
// 3 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0x1800ace81
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b810c
//
// 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
//
struct cocos2d::CCSprite *__fastcall cocos2d::CCTMXLayer::insertTileForGID(
cocos2d::CCTMXLayer *this,
unsigned int a2,
struct cocos2d::CCPoint *a3)
{
cocos2d::CCDirector *v6; // rax
float ContentScaleFactor; // xmm0_4
float v8; // xmm8_4
cocos2d::CCDirector *v9; // rax
float v10; // xmm0_4
float v11; // xmm7_4
cocos2d::CCDirector *v12; // rax
float v13; // xmm0_4
float v14; // xmm6_4
cocos2d::CCDirector *v15; // rax
float v16; // xmm0_4
cocos2d::CCRect *v17; // rax
__int64 v18; // rdi
struct cocos2d::CCRect *v19; // rax
cocos2d::CCSprite *v20; // rbp
_DWORD *v21; // rax
__int64 v22; // rcx
__int64 v23; // rbx
unsigned int v24; // edx
__int64 v25; // rcx
cocos2d::CCArray *m_pChildren; // rcx
cocos2d::CCArray *v27; // rax
cocos2d::ccArray *data; // rcx
__int64 num; // rax
cocos2d::CCObject **arr; // rcx
cocos2d::CCObject **i; // r8
cocos2d::CCObject *v32; // rdx
unsigned int m_uAutoReleaseCount; // eax
struct cocos2d::CCRect v35; // [rsp+30h] [rbp-68h] BYREF
cocos2d::CCRect v36; // [rsp+40h] [rbp-58h] BYREF
int v37; // [rsp+A0h] [rbp+8h] BYREF
cocos2d::CCTMXTilesetInfo::rectForGID(*((struct cocos2d::CCRect **)this + 48), (unsigned int)&v35);
v6 = cocos2d::CCDirector::sharedDirector();
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v6);
v8 = v35.size.height / ContentScaleFactor;
v9 = cocos2d::CCDirector::sharedDirector();
v10 = cocos2d::CCDirector::getContentScaleFactor(v9);
v11 = v35.size.width / v10;
v12 = cocos2d::CCDirector::sharedDirector();
v13 = cocos2d::CCDirector::getContentScaleFactor(v12);
v14 = v35.origin.y / v13;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = cocos2d::CCDirector::getContentScaleFactor(v15);
v17 = cocos2d::CCRect::CCRect(&v36, v35.origin.x / v16, v14, v11, v8);
cocos2d::CCRect::operator=((float *)&v35.origin, (float *)&v17->origin);
v18 = (unsigned int)(int)(float)((float)(*((float *)this + 90) * a3->y) + a3->x);
v19 = cocos2d::CCRect::CCRect(&v36, &v35);
v20 = cocos2d::CCTMXLayer::reusedTileWithRect(this, v19);
v21 = cocos2d::cc_timeval::operator=(&v37, a3);
cocos2d::CCTMXLayer::setupTileSprite(this, v20, (struct cocos2d::CCPoint)v21, a2);
v22 = *((_QWORD *)this + 59);
v23 = 0;
v24 = *(_DWORD *)v22;
if ( *(_DWORD *)v22 )
{
v25 = *(_QWORD *)(v22 + 16);
do
{
if ( (int)v18 < *(_DWORD *)(v25 + 8 * v23) )
break;
v23 = (unsigned int)(v23 + 1);
}
while ( (unsigned int)v23 < v24 );
}
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(this, v20, v23);
sub_18009E210(*((int **)this + 59), v18, v23);
m_pChildren = this->m_pChildren;
if ( m_pChildren )
{
if ( (unsigned int)cocos2d::CCArray::count(m_pChildren) )
{
v27 = this->m_pChildren;
if ( v27 )
{
data = v27->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v32 = *arr;
if ( !*arr )
break;
m_uAutoReleaseCount = v32[6].m_uAutoReleaseCount;
if ( m_uAutoReleaseCount >= (unsigned int)v23 )
v32[6].m_uAutoReleaseCount = m_uAutoReleaseCount + 1;
}
}
}
}
}
*(_DWORD *)(*((_QWORD *)this + 47) + 4 * v18) = a2;
return v20;
}