//
// EditorUI::doPasteObjects from 0x6c37a0 to 0x6c39f0 (592 bytes)
//
// 3 xrefs:
// > EditorUI::onPaste @ 0x6c39f4
// > EditorPauseLayer::onPasteWColor @ 0x78ab98
// > ??> @ 0x505b0
//
// 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::doPasteObjects(EditorUI *a1, bool a2)
{
int v4; // w21
int v5; // w0
LevelEditorLayer *m_editorLayer; // x0
GameManager *v7; // x0
cocos2d::CCArray *v8; // x22
void *v9; // x0
cocos2d::CCDirector *v10; // x0
cocos2d::CCLayer *m_objectLayer; // x25
unsigned int *v12; // x2
int v13; // w1
__int64 v14; // [xsp+0h] [xbp+0h] BYREF
float v15; // [xsp+58h] [xbp+58h]
float v16; // [xsp+5Ch] [xbp+5Ch]
cocos2d::CCPoint v17; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCPoint v18; // [xsp+68h] [xbp+68h] BYREF
cocos2d::CCPoint v19; // [xsp+70h] [xbp+70h] BYREF
cocos2d::CCPoint GridSnappedPos; // 0:kr10_8.8
cocos2d::CCPoint v21; // 0:s0.4,4:s1.4
cocos2d::CCPoint v22; // 0:s0.4,4:s1.4
if ( !*((_QWORD *)GameManager::sharedState()->m_editorClipboard.m_data.m_data - 3) )
return;
v4 = a1->m_editorLayer->m_objectCount.random - a1->m_editorLayer->m_objectCount.seed;
v5 = v4 + GameManager::sharedState()->m_copiedObjectCount;
if ( v5 > 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_6;
}
if ( v5 > 40000 )
{
m_editorLayer = a1->m_editorLayer;
goto LABEL_12;
}
LABEL_6:
v7 = GameManager::sharedState();
sub_D18D28(&v19, &v7->m_editorClipboard);
v8 = EditorUI::pasteObjects(a1, (const void **)&v19, a2, 0);
v9 = (void *)(*(_QWORD *)&v19 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v19 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(*(_QWORD *)&v19 - 8LL);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *(_DWORD *)(*(_QWORD *)&v19 - 8LL);
*(_DWORD *)(*(_QWORD *)&v19 - 8LL) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v9);
}
if ( v8 )
{
if ( (unsigned int)cocos2d::CCArray::count(v8) )
{
v10 = cocos2d::CCDirector::sharedDirector();
cocos2d::CCDirector::getWinSize(v10);
m_objectLayer = a1->m_editorLayer->m_objectLayer;
cocos2d::CCPoint::CCPoint(&v19, v15 * 0.5, (float)(a1->m_toolbarHeight * 0.5) + (float)(v16 * 0.5));
cocos2d::CCNode::convertToNodeSpace(m_objectLayer, &v19);
cocos2d::CCPoint::CCPoint(&v18, &v17);
GridSnappedPos = EditorUI::getGridSnappedPos(a1, v21);
cocos2d::CCPoint::operator=(&v17, GridSnappedPos.x, GridSnappedPos.y);
cocos2d::CCPoint::CCPoint(&v19, &v17);
EditorUI::repositionObjectsToCenter(a1, v8, v22, (unsigned __int8)&v14 + 112);
}
}
EditorUI::updateButtons(a1);
EditorUI::updateObjectInfoLabel(a1);
}