//
// EditorUI::onDuplicate from 0x1401c5520 to 0x1401c56f8 (472 bytes)
//
// 5 xrefs:
// > EditorUI::startFreeMoveTouch @ 0x1401bfb87
// > EditorUI::handleEditorAction @ 0x1401c23ec
// > EditorUI::init @ 0x1401ab48e
// > ??> @ 0x14091a720
// > ??> @ 0x14091a72c
//
// 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:04 +0000
//
// Hidden C++ exception states: #wind=1
void __fastcall EditorUI::onDuplicate(__int64 a1)
{
__int64 v2; // rax
int v3; // ebx
int v4; // ecx
__int64 v5; // rcx
cocos2d::CCArray *v6; // rbx
__int64 v7; // rax
__int64 v8; // rdx
int v9; // ecx
int v10; // eax
int v11; // ecx
char v12; // [rsp+20h] [rbp-68h]
_BYTE v13[32]; // [rsp+38h] [rbp-50h] BYREF
_BYTE v14[32]; // [rsp+58h] [rbp-30h] BYREF
if ( !*(_QWORD *)(a1 + 1568) && !cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 944)) )
return;
v2 = EditorSFXManager::sharedState();
EditorSFXManager::playAction(v2, 103);
v3 = *(_DWORD *)(*(_QWORD *)(a1 + 1512) + 14928LL) - *(_DWORD *)(*(_QWORD *)(a1 + 1512) + 14932LL);
v4 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 944)) + v3;
if ( v4 > 80000 )
{
if ( !*(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a1 + 1512) + 2168LL) + 1297LL) )
{
EditorUI::showMaxError(a1);
return;
}
LABEL_7:
if ( !*(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a1 + 1512) + 2168LL) + 1296LL) )
{
EditorUI::showMaxBasicError(a1);
return;
}
goto LABEL_9;
}
if ( v4 > 40000 )
goto LABEL_7;
LABEL_9:
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 944)) )
{
v6 = *(cocos2d::CCArray **)(a1 + 944);
}
else
{
v6 = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
cocos2d::CCArray::addObject(v6, *(struct cocos2d::CCObject **)(a1 + 1568));
}
v12 = 0;
EditorUI::copyObjects(a1, v14, v6, 0, v12);
*(_BYTE *)(*(_QWORD *)(a1 + 1512) + 14808LL) = 1;
v7 = sub_14003F4F0((__int64)v13, (__int64)v14);
EditorUI::pasteObjects(a1, v7, 0, 0);
*(_BYTE *)(*(_QWORD *)(a1 + 1512) + 14808LL) = 0;
v8 = *(_QWORD *)(a1 + 1512) + 15408LL;
v9 = *(_DWORD *)(*(_QWORD *)(a1 + 1512) + 15504LL);
if ( v9 >= 0 )
{
v10 = *(_DWORD *)(*(_QWORD *)(a1 + 1512) + 15440LL) - v9;
v11 = 0;
if ( v10 > 1 )
{
do
{
if ( v11 >= 7 )
break;
v10 = (unsigned int)v10 >> 1;
++v11;
}
while ( (unsigned int)v10 > 1 );
}
++*(_DWORD *)(v8 + 4LL * v11 + 64);
}
*(_DWORD *)(v8 + 96) = *(_DWORD *)(v8 + 32);
EditorUI::updateButtons(a1);
EditorUI::updateObjectInfoLabel(a1);
sub_14003D310((__int64)v14);
}