//
// GJSmartTemplate::saveRemapToDict from 0x9d0890 to 0x9d0a60 (464 bytes)
//
// 8 xrefs:
// > GJSmartTemplate::saveRemap @ 0x9d269c
// > GJSmartTemplate::saveRemap @ 0x9d270c
// > GJSmartTemplate::saveRemap @ 0x9d2790
// > GJSmartTemplate::saveRemap @ 0x9d2874
// > GJSmartTemplate::saveRemap @ 0x9d28e4
// > GJSmartTemplate::saveRemap @ 0x9d29d0
// > GJSmartTemplate::saveRemap @ 0x9d2a3c
// > ??> @ 0x34db8
//
// 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
//
__int64 __fastcall GJSmartTemplate::saveRemapToDict(
__int64 a1,
const std::string *a2,
cocos2d::CCString *a3,
cocos2d::CCDictionary *a4)
{
cocos2d::CCArray *v6; // x21
unsigned int v7; // w20
const std::string *v8; // x1
cocos2d::CCString *v9; // x0
char *CString; // x0
_QWORD *v11; // x27
__int64 *v12; // x28
unsigned __int64 v13; // x19
bool (__fastcall *canEncode)(cocos2d::CCObject *__hidden); // x26
size_t v15; // x2
int v16; // w2
__int64 v17; // x19
cocos2d::CCObject *v18; // x0
unsigned int *v19; // x3
int v20; // w0
int v21; // [xsp+60h] [xbp+60h]
int v22; // [xsp+68h] [xbp+68h]
_QWORD *v23; // [xsp+80h] [xbp+80h] BYREF
if ( *((_QWORD *)a2->m_data.m_data - 3) )
{
v22 = (int)a4;
v6 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a4, a2);
if ( !v6 )
{
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(nullptr);
cocos2d::CCDictionary::setObject(v22, v6);
}
v7 = 0;
if ( (unsigned int)cocos2d::CCArray::count(v6) )
{
while ( 1 )
{
v9 = cocos2d::CCArray::stringAtIndex(v6, v7);
CString = (char *)cocos2d::CCString::getCString(v9);
sub_D153B8((int)&v23, CString);
v11 = v23;
v12 = v23 - 3;
v13 = *(v23 - 3);
canEncode = a3->__vftable[-1].canEncode;
if ( (unsigned __int64)canEncode > v13 )
v15 = *(v23 - 3);
else
v15 = (size_t)a3->__vftable[-1].canEncode;
v16 = memcmp(v23, a3->__vftable, v15);
if ( !v16 )
{
v17 = v13 - (_QWORD)canEncode;
v16 = 0x7FFFFFFF;
if ( v17 <= 0x7FFFFFFF )
{
if ( v17 < (__int64)0xFFFFFFFF80000000LL )
v16 = 0x80000000;
else
v16 = v17;
}
}
if ( v12 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v11 - 1);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 - 2) = v20 - 1;
}
if ( v20 <= 0 )
{
v21 = v16;
operator delete(v12);
v16 = v21;
}
}
if ( !v16 )
break;
if ( ++v7 >= (unsigned int)cocos2d::CCArray::count(v6) )
goto LABEL_17;
}
}
else
{
LABEL_17:
v18 = (cocos2d::CCObject *)cocos2d::CCString::create(a3, v8);
cocos2d::CCArray::addObject(v6, v18);
}
}
return _stack_chk_guard;
}