//
// GameManager::addNewCustomObject from 0x1401837f0 to 0x14018396a (378 bytes)
//
// 2 xrefs:
// > EditorUI::onNewCustomItem @ 0x1400e44d3
// > ??> @ 0x1406cb5c8
//
// 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=2
__int64 __fastcall GameManager::addNewCustomObject(__int64 a1, __int64 a2)
{
struct cocos2d::CCArray *v4; // rsi
int v5; // edi
cocos2d::ccArray *data; // rbx
__int64 num; // rax
cocos2d::CCString **arr; // rbx
cocos2d::CCString **i; // rsi
int v10; // eax
cocos2d::CCString *v11; // rax
const char *CString; // rax
size_t v13; // r8
__int64 v14; // rax
void *v15; // rcx
void *Block[2]; // [rsp+28h] [rbp-40h] BYREF
__int128 v18; // [rsp+38h] [rbp-30h]
v4 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 424));
if ( cocos2d::CCArray::count(v4) )
qsort(v4->data->arr, v4->data->num, 8u, (_CoreCrtNonSecureSearchSortCompareFunction)sub_14017B290);
v5 = 0;
if ( v4 )
{
data = v4->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (cocos2d::CCString **)data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
if ( !*arr )
break;
v10 = cocos2d::CCString::intValue(*arr);
if ( v10 < v5 )
v5 = v10;
}
}
}
v11 = cocos2d::CCString::createWithFormat("%i", v5 - 1);
CString = cocos2d::CCString::getCString(v11);
*(_OWORD *)Block = 0;
v18 = 0;
v13 = -1;
do
++v13;
while ( CString[v13] );
sub_14003A930(Block, CString, v13);
v14 = cocos2d::CCString::create(a2);
cocos2d::CCDictionary::setObject(*(_QWORD *)(a1 + 424), v14, Block);
if ( *((_QWORD *)&v18 + 1) > 0xFu )
{
v15 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v18 + 1) + 1LL) >= 0x1000 )
{
v15 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v15 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v15);
}
sub_14003A830(a2);
return (unsigned int)(v5 - 1);
}