//
// EditorUI::onDuplicate from 0x6c4dc4 to 0x6c503c (632 bytes)
//
// 5 xrefs:
// > EditorUI::ccTouchBegan @ 0x6c53e8
// > EditorUI::keyDown @ 0x6c5710
// > ??> @ 0x61f98
// > EditorUI::init @ 0x6bd070
// > ??> @ 0x122b290
//
// 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
//
void EditorUI::onDuplicate(EditorUI *a1, cocos2d::CCObject *a2)
{
int v3; // w19
int v4; // w0
cocos2d::CCArray *v5; // x0
cocos2d::CCArray *m_selectedObjects; // x19
char *v7; // x0
void *v8; // x0
LevelEditorLayer *m_editorLayer; // x0
unsigned int *v10; // x20
int v11; // w1
unsigned int *v12; // x1
int v13; // w2
__int64 v14; // [xsp+48h] [xbp+48h] BYREF
_DWORD *v15; // [xsp+50h] [xbp+50h] BYREF
if ( !a1->m_selectedObject && !(unsigned int)cocos2d::CCArray::count(a1->m_selectedObjects) )
return;
v3 = a1->m_editorLayer->m_objectCount.random - a1->m_editorLayer->m_objectCount.seed;
v4 = cocos2d::CCArray::count(a1->m_selectedObjects) + v3;
if ( v4 > 80000 )
{
m_editorLayer = a1->m_editorLayer;
if ( !m_editorLayer->m_level->m_unlimitedObjectsEnabled )
{
EditorUI::showMaxError(a1);
return;
}
LABEL_12:
if ( !m_editorLayer->m_level->m_highObjectsEnabled )
{
EditorUI::showMaxBasicError(a1);
return;
}
goto LABEL_4;
}
if ( v4 > 40000 )
{
m_editorLayer = a1->m_editorLayer;
goto LABEL_12;
}
LABEL_4:
v5 = (cocos2d::CCArray *)cocos2d::CCArray::count(a1->m_selectedObjects);
if ( (_DWORD)v5 )
{
m_selectedObjects = a1->m_selectedObjects;
}
else
{
m_selectedObjects = (cocos2d::CCArray *)cocos2d::CCArray::create(v5);
cocos2d::CCArray::addObject(m_selectedObjects, a1->m_selectedObject);
}
EditorUI::copyObjects(&v14, a1, m_selectedObjects, 0, 0);
a1->m_editorLayer->m_keepEditorLayer = 1;
sub_D18D28(&v15, &v14);
EditorUI::pasteObjects(a1, (const void **)&v15, 0, 0);
v7 = (char *)(v15 - 6);
if ( v15 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = v15 - 2;
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *(v15 - 2);
*(v15 - 2) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v7);
}
a1->m_editorLayer->m_keepEditorLayer = 0;
EditorUI::tryUpdateTimeMarkers(a1);
EditorUI::updateButtons(a1);
EditorUI::updateObjectInfoLabel(a1);
v8 = (void *)(v14 - 24);
if ( (__int64 *)(v14 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v10 = (unsigned int *)(v14 - 8);
do
v11 = __ldaxr(v10);
while ( __stlxr(v11 - 1, v10) );
}
else
{
v11 = *(_DWORD *)(v14 - 8);
*(_DWORD *)(v14 - 8) = v11 - 1;
}
if ( v11 <= 0 )
operator delete(v8);
}
}