//
// GameManager::addNewCustomObject from 0x14027ef00 to 0x14027f090 (400 bytes)
//
// 2 xrefs:
// > EditorUI::onNewCustomItem @ 0x1401f5f45
// > ??> @ 0x14091d018
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:28:59 +0000
//
// Hidden C++ exception states: #wind=2
__int64 __fastcall GameManager::addNewCustomObject(__int64 a1, __int64 a2)
{
struct cocos2d::CCArray *v4; // rsi
int v5; // edi
unsigned int *v6; // rbx
__int64 v7; // rax
cocos2d::CCString **v8; // rbx
cocos2d::CCString **i; // rsi
int v10; // eax
cocos2d::CCString *v11; // rax
const char *CString; // rax
size_t v13; // r8
__int64 v14; // rbx
__int64 v15; // rax
void *v16; // rcx
void *Block[2]; // [rsp+38h] [rbp-40h] BYREF
__int128 v19; // [rsp+48h] [rbp-30h]
v4 = cocos2d::CCDictionary::allKeys(*(cocos2d::CCDictionary **)(a1 + 464));
if ( cocos2d::CCArray::count(v4) )
qsort(
*(void **)(*((_QWORD *)v4 + 7) + 16LL),
**((unsigned int **)v4 + 7),
8u,
(_CoreCrtNonSecureSearchSortCompareFunction)sub_1402760B0);
v5 = 0;
if ( v4 )
{
v6 = *((unsigned int **)v4 + 7);
v7 = *v6;
if ( (_DWORD)v7 )
{
v8 = *((cocos2d::CCString ***)v6 + 2);
for ( i = &v8[v7 - 1]; v8 <= i; ++v8 )
{
if ( !*v8 )
break;
v10 = cocos2d::CCString::intValue(*v8);
if ( v10 < v5 )
v5 = v10;
}
}
}
v11 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)(v5 - 1));
CString = cocos2d::CCString::getCString(v11);
*(_OWORD *)Block = 0;
v19 = 0;
v13 = -1;
do
++v13;
while ( CString[v13] );
sub_14003D230(Block, CString, v13);
v14 = *(_QWORD *)(a1 + 464);
v15 = cocos2d::CCString::create(a2);
cocos2d::CCDictionary::setObject(v14, v15, Block);
if ( *((_QWORD *)&v19 + 1) > 0xFu )
{
v16 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v19 + 1) + 1LL) >= 0x1000 )
{
v16 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v16 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v16);
}
sub_14003D310(a2);
return (unsigned int)(v5 - 1);
}