//
// GameManager::addNewCustomObject from 0x100384670 to 0x1003847e6 (374 bytes)
//
// 1 xrefs:
// > EditorUI::onNewCustomItem @ 0x100030c60
//
// 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 GameManager::addNewCustomObject(__int64 a1, __int64 a2, double a3)
{
cocos2d::CCArray *v3; // rbx
cocos2d::ccArray *data; // rax
cocos2d::CCString **arr; // r12
unsigned __int64 v6; // r13
int v7; // ebx
int v8; // eax
unsigned int v9; // ebx
__int64 v10; // r15
cocos2d::CCObject *v11; // r14
cocos2d::CCString *v12; // rax
const char *CString; // r13
size_t v14; // rax
size_t v15; // r12
char *v16; // r15
size_t v17; // r14
char v19; // [rsp+0h] [rbp-50h]
__int64 v20; // [rsp+0h] [rbp-50h]
cocos2d::CCObject *v21; // [rsp+8h] [rbp-48h]
_QWORD __dst[2]; // [rsp+10h] [rbp-40h] BYREF
void *__p; // [rsp+20h] [rbp-30h]
v3 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 416));
if ( (unsigned int)sub_100720070(v3) )
{
qsort(v3->data->arr, v3->data->num, 8u, (int (__cdecl *)(const void *, const void *))sub_1003768B0);
}
else if ( !v3 )
{
LABEL_11:
v9 = -1;
goto LABEL_12;
}
data = v3->data;
if ( !data->num )
goto LABEL_11;
arr = (cocos2d::CCString **)data->arr;
v6 = (unsigned __int64)&arr[data->num - 1];
v7 = 0;
do
{
if ( !*arr )
break;
v8 = cocos2d::CCString::intValue(*arr);
if ( v8 < v7 )
v7 = v8;
++arr;
}
while ( (unsigned __int64)arr <= v6 );
v9 = v7 - 1;
LABEL_12:
v10 = *(_QWORD *)(a1 + 416);
v11 = (cocos2d::CCObject *)sub_1007AB360(a2);
v12 = (cocos2d::CCString *)sub_1007AB580("%i", v19);
CString = cocos2d::CCString::getCString(v12);
v14 = strlen(CString);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(a3);
v15 = v14;
v20 = v10;
if ( v14 >= 0x17 )
{
v21 = v11;
v17 = 26;
if ( (v14 | 7) != 0x17 )
v17 = (v14 | 7) + 1;
v16 = (char *)operator new(v17);
__p = v16;
__dst[0] = v17 + 1;
v11 = v21;
__dst[1] = v15;
goto LABEL_19;
}
LOBYTE(__dst[0]) = 2 * v14;
v16 = (char *)__dst + 1;
if ( v14 )
LABEL_19:
memmove(v16, CString, v15);
v16[v15] = 0;
cocos2d::CCDictionary::setObject_1(v20, v11, (char *)__dst);
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
return v9;
}