//
// GJSmartTemplate::dataLoaded from 0x9d5684 to 0x9d5a24 (928 bytes)
//
// 2 xrefs:
// > GJSmartTemplate::createWithCoder @ 0x9d5a40
// > ??> @ 0xaf7b8
//
// 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 GJSmartTemplate::dataLoaded(GJSmartTemplate *a1, DS_Dictionary *a2)
{
void *v4; // x0
cocos2d::CCDictionary *DictForKey; // x0
cocos2d::CCDictionary *v6; // x19
cocos2d::CCDictionary *m_prefabArrays; // x1
unsigned int v8; // w24
cocos2d::CCArray *v9; // x26
cocos2d::CCString *v10; // x0
char *CString; // x0
void *v12; // x0
__int64 v13; // x0
unsigned int *v14; // x0
_QWORD *v15; // x19
_QWORD *i; // x21
char *v17; // x0
unsigned int *v18; // x1
int v19; // w2
unsigned int *v20; // x1
int v21; // w2
unsigned int *v22; // x3
int v23; // w1
_QWORD v24[14]; // [xsp+0h] [xbp+0h] BYREF
char v25; // [xsp+70h] [xbp+70h] BYREF
std::string v26; // [xsp+78h] [xbp+78h] BYREF
__int64 v27; // [xsp+80h] [xbp+80h] BYREF
a1->m_nameIndex = DS_Dictionary::getIntegerForKey(a2, "1");
DS_Dictionary::getStringForKey(&v27, a2, &byte_F78BA8);
sub_D163D4(&a1->m_templateName, &v27);
v4 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) != &qword_124B6B0 )
{
v22 = (unsigned int *)(v27 - 8);
if ( &pthread_create )
{
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v4);
}
a1->m_allowRotation = DS_Dictionary::getIntegerForKey(a2, &byte_F2CA20) != 0;
a1->m_allowFlipX = DS_Dictionary::getIntegerForKey(a2, "5") != 0;
a1->m_allowFlipY = DS_Dictionary::getIntegerForKey(a2, "6") != 0;
a1->m_ignoreCorners = DS_Dictionary::getIntegerForKey(a2, "7") != 0;
DictForKey = DS_Dictionary::getDictForKey(a2, "3", 0);
v6 = DictForKey;
m_prefabArrays = a1->m_prefabArrays;
if ( DictForKey != m_prefabArrays )
{
if ( DictForKey )
{
cocos2d::CCObject::retain(DictForKey);
m_prefabArrays = a1->m_prefabArrays;
}
if ( m_prefabArrays )
cocos2d::CCObject::release(m_prefabArrays);
a1->m_prefabArrays = v6;
}
v8 = 0;
v9 = cocos2d::CCDictionary::allKeys(v6);
v24[13] = &v25;
if ( (unsigned int)cocos2d::CCArray::count(v9) )
{
do
{
v10 = cocos2d::CCArray::stringAtIndex(v9, v8);
CString = (char *)cocos2d::CCString::getCString(v10);
sub_D153B8((unsigned int)v24 + 120, CString);
sub_D18D28(&v27);
GJSmartTemplate::saveRemap((cocos2d::CCDictionary **)a1);
v12 = (void *)(v27 - 24);
if ( (__int64 *)(v27 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v20 = (unsigned int *)(v27 - 8);
do
v21 = __ldaxr(v20);
while ( __stlxr(v21 - 1, v20) );
}
else
{
v21 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v21 - 1;
}
if ( v21 <= 0 )
operator delete(v12);
}
v13 = cocos2d::CCDictionary::objectForKey(a1->m_prefabArrays, &v26);
if ( v13 )
{
v14 = *(unsigned int **)(v13 + 56);
if ( *v14 )
{
v15 = *((_QWORD **)v14 + 2);
for ( i = &v15[*v14 - 1]; i >= v15; ++v15 )
{
if ( !*v15 )
break;
sub_D18EA8(*v15 + 56LL, &v26);
}
}
}
v17 = (char *)v26.m_data.m_data - 24;
if ( (__int64 *)v26.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_16;
if ( &pthread_create )
{
v18 = (unsigned int *)((char *)v26.m_data.m_data - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v26.m_data.m_data - 2);
*((_DWORD *)v26.m_data.m_data - 2) = v19 - 1;
}
if ( v19 > 0 )
{
LABEL_16:
++v8;
}
else
{
++v8;
operator delete(v17);
}
}
while ( v8 < (unsigned int)cocos2d::CCArray::count(v9) );
}
}