//
// cocos2d::CCTMXLayer::insertTileForGID from 0x10025b030 to 0x10025b233 (515 bytes)
//
// 1 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0x10025b5c4
//
// 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 *__fastcall cocos2d::CCTMXLayer::insertTileForGID(
cocos2d::CCTMXLayer *a1,
unsigned int a2,
const cocos2d::CCPoint *a3)
{
cocos2d::CCDirector *v5; // rax
float v6; // xmm0_4
cocos2d::CCDirector *v7; // rax
float v8; // xmm0_4
cocos2d::CCDirector *v9; // rax
float v10; // xmm0_4
cocos2d::CCDirector *v11; // rax
float v12; // xmm0_4
__int64 v13; // r15
cocos2d::CCSprite *v14; // r12
int m_nTag; // ebx
unsigned int *v16; // rcx
__int64 v17; // rax
__int64 v18; // rcx
__int64 v19; // r13
cocos2d::CCArray *m_pChildren; // rdi
cocos2d::CCArray *v21; // rax
cocos2d::ccArray *data; // rax
__int64 num; // rcx
cocos2d::CCObject **arr; // rax
unsigned __int64 v25; // rcx
cocos2d::CCObject *v26; // rdx
unsigned int m_uAutoReleaseCount; // esi
_BYTE v29[16]; // [rsp+4h] [rbp-5Ch] BYREF
cocos2d::CCTMXTilesetInfo v30; // [rsp+14h] [rbp-4Ch] BYREF
cocos2d::CCRect v31; // 0:xmm0_8.8,8:xmm1_8.8
v30.m_nTag = a2;
cocos2d::CCTMXTilesetInfo::rectForGID(&v30, *(_QWORD *)&a1[1].m_uAutoReleaseCount);
v30.m_uAutoReleaseCount = (unsigned int)v30.__vftable;
v5 = cocos2d::CCDirector::sharedDirector();
v6 = sub_1004849C0(v5);
*(float *)&v30.m_uAutoReleaseCount = *(float *)&v30.m_uAutoReleaseCount / v6;
v30.m_eObjType = HIDWORD(v30.__vftable);
v7 = cocos2d::CCDirector::sharedDirector();
v8 = sub_1004849C0(v7);
*(float *)&v30.m_eObjType = *(float *)&v30.m_eObjType / v8;
v30.m_uIndexInArray = v30.m_uID;
v9 = cocos2d::CCDirector::sharedDirector();
v10 = sub_1004849C0(v9);
*(float *)&v30.m_uIndexInArray = *(float *)&v30.m_uIndexInArray / v10;
v30.m_uReference = v30.m_nLuaID;
v11 = cocos2d::CCDirector::sharedDirector();
v12 = sub_1004849C0(v11);
v31.size = (cocos2d::CCSize)(unsigned int)v30.m_eObjType;
sub_10028CC00(
v29,
COERCE_DOUBLE((unsigned __int64)v30.m_uAutoReleaseCount),
COERCE_DOUBLE((unsigned __int64)(unsigned int)v30.m_eObjType),
*(float *)&v30.m_uIndexInArray,
*(float *)&v30.m_uReference / v12);
sub_10028D1A0(&v30, v29);
v13 = (unsigned int)(int)(float)((float)(a3->y * *(float *)(&a1->m_bManualSortAllChildrenDirty + 3)) + a3->x);
*(double *)&v31.origin = sub_10028D180(v29);
v14 = cocos2d::CCTMXLayer::reusedTileWithRect(a1, v31);
*(double *)&v31.origin = sub_10028CC60(v29);
m_nTag = v30.m_nTag;
cocos2d::CCTMXLayer::setupTileSprite(a1, v14, v31.origin, (unsigned int)v29);
v16 = *(unsigned int **)&a1[1].m_obAnchorPoint.y;
v17 = *v16;
if ( *v16 )
{
v18 = *((_QWORD *)v16 + 2);
v19 = 0;
while ( *(_DWORD *)(v18 + 8 * v19) <= (int)v13 )
{
if ( v17 == ++v19 )
{
LODWORD(v19) = v17;
break;
}
}
}
else
{
LODWORD(v19) = 0;
}
cocos2d::CCSpriteBatchNode::insertQuadFromSprite(a1, v14, v19);
sub_1006683C0(*(_QWORD *)&a1[1].m_obAnchorPoint.y, v13, (unsigned int)v19);
m_pChildren = a1->m_pChildren;
if ( m_pChildren )
{
if ( (unsigned int)sub_100720070(m_pChildren) )
{
v21 = a1->m_pChildren;
if ( v21 )
{
data = v21->data;
num = data->num;
if ( data->num )
{
arr = data->arr;
v25 = (unsigned __int64)&arr[num - 1];
do
{
v26 = *arr;
if ( !*arr )
break;
m_uAutoReleaseCount = v26[6].m_uAutoReleaseCount;
if ( m_uAutoReleaseCount >= (unsigned int)v19 )
v26[6].m_uAutoReleaseCount = m_uAutoReleaseCount + 1;
++arr;
}
while ( (unsigned __int64)arr <= v25 );
}
}
}
}
*(_DWORD *)(*(_QWORD *)&a1[1].m_nTag + 4 * v13) = m_nTag;
return v14;
}