//
// GJSmartTemplate::dataLoaded from 0x1402b5540 to 0x1402b580f (719 bytes)
//
// 3 xrefs:
// > GJObjectDecoder::getDecodedObject @ 0x1402843d5
// > ??> @ 0x1406d2420
// > ??> @ 0x1406d242c
//
// 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
//
// Hidden C++ exception states: #wind=1
void GJSmartTemplate::dataLoaded(GJSmartTemplate *a1, DS_Dictionary *a2)
{
int v4; // eax
__int64 StringForKey; // rax
int v6; // eax
int v7; // eax
int v8; // eax
int v9; // eax
struct cocos2d::CCDictionary *DictForKey; // rax
cocos2d::CCDictionary *v11; // rbx
cocos2d::CCDictionary *m_prefabArrays; // rcx
cocos2d::CCDictionary *v13; // rcx
cocos2d::CCArray *v14; // r12
unsigned int i; // r14d
cocos2d::CCString *v16; // rax
const char *CString; // rax
size_t v18; // r8
__int64 v19; // rdx
__int64 v20; // rcx
__int64 v21; // r8
__int64 v22; // r9
void **v23; // rsi
size_t v24; // rdi
size_t v25; // rbx
__int64 v26; // rax
unsigned int *v27; // rbx
__int64 v28; // rax
__int64 *v29; // rbx
__int64 *j; // rdi
__int64 v31; // rax
void **v32; // rdx
void *Src[2]; // [rsp+28h] [rbp-48h] BYREF
size_t Size; // [rsp+38h] [rbp-38h]
unsigned __int64 v35; // [rsp+40h] [rbp-30h]
__int128 v36; // [rsp+48h] [rbp-28h] BYREF
size_t v37; // [rsp+58h] [rbp-18h]
__int64 v38; // [rsp+60h] [rbp-10h]
DS_Dictionary::getIntegerForKey(a2, (const char *)&word_140531EA4);
a1->m_nameIndex = v4;
StringForKey = DS_Dictionary::getStringForKey(a2, &v36, &word_140531EA0);
sub_140051590((__int64)&a1->m_templateName, StringForKey);
sub_14003A830((__int64)&v36);
DS_Dictionary::getIntegerForKey(a2, (const char *)&word_140531E94);
a1->m_allowRotation = v6 != 0;
DS_Dictionary::getIntegerForKey(a2, (const char *)&word_140531E90);
a1->m_allowFlipX = v7 != 0;
DS_Dictionary::getIntegerForKey(a2, "6");
a1->m_allowFlipY = v8 != 0;
DS_Dictionary::getIntegerForKey(a2, (const char *)&word_140531E88);
a1->m_ignoreCorners = v9 != 0;
DictForKey = DS_Dictionary::getDictForKey(a2, (const char *)&word_140531E9C, 0);
v11 = DictForKey;
m_prefabArrays = a1->m_prefabArrays;
if ( m_prefabArrays != DictForKey )
{
if ( DictForKey )
cocos2d::CCObject::retain(DictForKey);
v13 = a1->m_prefabArrays;
if ( v13 )
cocos2d::CCObject::release(v13);
a1->m_prefabArrays = v11;
m_prefabArrays = v11;
}
v14 = cocos2d::CCDictionary::allKeys(m_prefabArrays);
for ( i = 0; i < cocos2d::CCArray::count(v14); ++i )
{
v16 = cocos2d::CCArray::stringAtIndex(v14, i);
CString = cocos2d::CCString::getCString(v16);
*(_OWORD *)Src = 0;
Size = 0;
v35 = 0;
v18 = -1;
do
++v18;
while ( CString[v18] );
sub_14003A930(Src, CString, v18);
v36 = 0;
v37 = 0;
v38 = 0;
v23 = Src;
if ( v35 > 0xF )
v23 = (void **)Src[0];
v24 = Size;
if ( Size > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v20, v19, v21, v22);
v38 = 15;
if ( Size > 0xF )
{
v25 = Size | 0xF;
if ( (Size | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
if ( v25 < 0x16 )
v25 = 22;
}
else
{
v25 = 0x7FFFFFFFFFFFFFFFLL;
}
*(_QWORD *)&v36 = sub_14003AA10(v25 + 1);
v37 = v24;
v38 = v25;
memcpy((void *)v36, v23, v24 + 1);
}
else
{
v37 = Size;
v36 = *(_OWORD *)v23;
}
GJSmartTemplate::saveRemap(a1, (__int64)&v36);
v26 = cocos2d::CCDictionary::objectForKey(a1->m_prefabArrays, Src);
if ( v26 )
{
v27 = *(unsigned int **)(v26 + 56);
v28 = *v27;
if ( (_DWORD)v28 )
{
v29 = *((__int64 **)v27 + 2);
for ( j = &v29[v28 - 1]; v29 <= j; ++v29 )
{
v31 = *v29;
if ( !*v29 )
break;
if ( (void **)(v31 + 56) != Src )
{
v32 = Src;
if ( v35 > 0xF )
v32 = (void **)Src[0];
sub_14003CCE0((void **)(v31 + 56), v32, Size);
}
}
}
}
sub_14003A830((__int64)Src);
}
}