//
// cocos2d::CCTMXLayer::insertTileForGID from 0x1800afc20 to 0x1800afe0f (495 bytes)
//
// 3 xrefs:
// > cocos2d::CCTMXLayer::setTileGID @ 0x1800b06e1
// > ??> @ 0x18014cf68
// > ??> @ 0x1801c23d0
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:22:19 +0000
//
struct cocos2d::CCSprite *__fastcall cocos2d::CCTMXLayer::insertTileForGID(
cocos2d::CCTMXLayer *this,
unsigned int a2,
const 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
cocos2d::CCRect *v19; // rax
struct cocos2d::CCSprite *v20; // rbp
_DWORD *v21; // rax
__int64 v22; // rcx
__int64 v23; // rbx
unsigned int v24; // edx
__int64 v25; // rcx
cocos2d::CCArray *v26; // rcx
__int64 v27; // rax
unsigned int *v28; // rcx
__int64 v29; // rax
__int64 *v30; // rcx
__int64 *i; // r8
__int64 v32; // rdx
unsigned int v33; // eax
float v35[4]; // [rsp+30h] [rbp-68h] BYREF
_BYTE v36[16]; // [rsp+40h] [rbp-58h] BYREF
int v37; // [rsp+A0h] [rbp+8h] BYREF
cocos2d::CCTMXTilesetInfo::rectForGID(*((_QWORD *)this + 48), v35, a2);
v6 = cocos2d::CCDirector::sharedDirector();
ContentScaleFactor = cocos2d::CCDirector::getContentScaleFactor(v6);
v8 = v35[3] / ContentScaleFactor;
v9 = cocos2d::CCDirector::sharedDirector();
v10 = cocos2d::CCDirector::getContentScaleFactor(v9);
v11 = v35[2] / v10;
v12 = cocos2d::CCDirector::sharedDirector();
v13 = cocos2d::CCDirector::getContentScaleFactor(v12);
v14 = v35[1] / v13;
v15 = cocos2d::CCDirector::sharedDirector();
v16 = cocos2d::CCDirector::getContentScaleFactor(v15);
v17 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v36, v35[0] / v16, v14, v11, v8);
cocos2d::CCRect::operator=((__int64)v35, (__int64)v17);
v18 = (unsigned int)(int)(float)((float)(*((float *)this + 90) * *((float *)a3 + 1)) + *(float *)a3);
v19 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v36, (const struct cocos2d::CCRect *)v35);
v20 = (struct cocos2d::CCSprite *)cocos2d::CCTMXLayer::reusedTileWithRect(this, v19);
v21 = cocos2d::cc_timeval::operator=(&v37, a3);
cocos2d::CCTMXLayer::setupTileSprite(this, v20, 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_1800A1EA0(*((int **)this + 59), v18, v23);
v26 = *((cocos2d::CCArray **)this + 26);
if ( v26 )
{
if ( (unsigned int)cocos2d::CCArray::count(v26) )
{
v27 = *((_QWORD *)this + 26);
if ( v27 )
{
v28 = *(unsigned int **)(v27 + 56);
v29 = *v28;
if ( (_DWORD)v29 )
{
v30 = *((__int64 **)v28 + 2);
for ( i = &v30[v29 - 1]; v30 <= i; ++v30 )
{
v32 = *v30;
if ( !*v30 )
break;
v33 = *(_DWORD *)(v32 + 360);
if ( v33 >= (unsigned int)v23 )
*(_DWORD *)(v32 + 360) = v33 + 1;
}
}
}
}
}
*(_DWORD *)(*((_QWORD *)this + 47) + 4 * v18) = a2;
return v20;
}