//
// EditorUI::pasteObjects from 0xbd94b0 to 0xbd9e30 (2432 bytes)
//
// 8 xrefs:
// > EditorUI::createPrefab @ 0x7c9e00
// > EditorUI::onCreateObject @ 0x7ca40c
// > EditorUI::createSmartObjectsFromTemplate @ 0x7cb4e4
// > SetupSmartBlockLayer::onPasteTemplate @ 0xb15cc0
// > EditorUI::doPasteObjects @ 0xbd9f3c
// > EditorUI::doPasteInPlace @ 0xbda178
// > EditorUI::onDuplicate @ 0xbdaab4
// > ??> @ 0xc0c88
//
// This function is hookable on this platform (idp: arm, 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 13:03:42 +0000
//
cocos2d::CCArray *__fastcall EditorUI::pasteObjects(__int64 a1, __int64 a2, unsigned __int8 a3, unsigned __int8 a4)
{
int v6; // w21
_BYTE *v7; // x2
__int64 v8; // x0
_BYTE *v9; // x0
_BYTE *v10; // x1
__int64 *v11; // x19
char *v12; // x1
size_t v13; // x2
const void *v14; // x1
size_t v15; // x2
char *v16; // x0
unsigned int locked; // w0
cocos2d::CCArray *v18; // x27
__int64 v20; // x19
unsigned int v21; // w19
cocos2d::CCObject *v22; // x20
void (__fastcall *v23)(cocos2d::CCObject *, void *); // x2
__int64 v24; // x1
unsigned __int8 *v25; // x27
const char *v26; // x0
int v27; // w0
__int64 v28; // x2
ColorAction *v29; // x19
char v30; // w0
__int64 v31; // x0
__int64 v32; // x1
_QWORD *v33; // x0
char *v34; // x23
char *v35; // x19
__int64 v36; // x22
unsigned int *v37; // x1
GameObject **v38; // x23
__int64 v39; // x0
char *v40; // x24
GameObject *v41; // x19
int *MainColor; // x0
int *v43; // x22
int v44; // w2
int v45; // w0
int v46; // w0
int v47; // w1
int *SecondaryColor; // x0
int *v49; // x22
int v50; // w2
int v51; // w0
int v52; // w0
int v53; // w1
int v54; // w0
_BYTE *v55; // x19
_BYTE *v56; // x0
unsigned __int8 *v57; // x0
_QWORD *v58; // x0
_QWORD *v59; // x19
void *v60; // x0
LevelEditorLayer *v61; // x0
int NextColorChannel; // w19
UndoObject *v63; // x0
GameObject *v64; // x0
__int64 v65; // x0
void (__fastcall *v66)(__int64, void *); // x2
int v67; // [xsp+6Ch] [xbp+6Ch]
unsigned __int8 *v68; // [xsp+80h] [xbp+80h]
cocos2d::CCArray *ObjectsFromString; // [xsp+88h] [xbp+88h]
int v70; // [xsp+9Ch] [xbp+9Ch] BYREF
int v71[2]; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v72; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v73; // [xsp+B0h] [xbp+B0h]
void *v74; // [xsp+B8h] [xbp+B8h]
void *v75; // [xsp+C0h] [xbp+C0h] BYREF
char *v76; // [xsp+C8h] [xbp+C8h]
char *v77; // [xsp+D0h] [xbp+D0h]
void *v78; // [xsp+D8h] [xbp+D8h] BYREF
unsigned __int8 *v79; // [xsp+E0h] [xbp+E0h]
__int64 v80; // [xsp+E8h] [xbp+E8h]
void *v81; // [xsp+F0h] [xbp+F0h] BYREF
_BYTE *v82; // [xsp+F8h] [xbp+F8h]
__int64 v83; // [xsp+100h] [xbp+100h]
__int64 v84; // [xsp+108h] [xbp+108h] BYREF
__int64 v85; // [xsp+110h] [xbp+110h]
void *v86; // [xsp+118h] [xbp+118h]
void *v87; // [xsp+120h] [xbp+120h] BYREF
__int64 *v88; // [xsp+128h] [xbp+128h]
void *v89; // [xsp+130h] [xbp+130h]
__int64 v90; // [xsp+138h] [xbp+138h]
float v91; // [xsp+140h] [xbp+140h]
v6 = a3;
v72 = 0;
v73 = 0;
v67 = a4;
v74 = nullptr;
if ( a3 )
{
if ( (*(_BYTE *)a2 & 1) != 0 )
{
v7 = *(_BYTE **)(a2 + 16);
v8 = *(_QWORD *)(a2 + 8);
}
else
{
v7 = (_BYTE *)(a2 + 1);
v8 = *(_BYTE *)a2 >> 1;
}
if ( v8 > 0 )
{
v9 = &v7[v8];
if ( v9 != v7 )
{
v10 = v7;
if ( *v7 == 35 )
{
LABEL_7:
if ( v10 - v7 != -1 )
{
v87 = nullptr;
v88 = nullptr;
v89 = nullptr;
sub_BD8DB0((unsigned __int8 *)a2, "#", (__int64 *)&v87);
v11 = (__int64 *)v87;
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)v88 - (_BYTE *)v87) >> 3) > 1 )
{
if ( (void *)a2 == v87 )
{
v11 = (__int64 *)a2;
}
else
{
if ( (*(_BYTE *)v87 & 1) != 0 )
{
v12 = *(char **)((char *)&word_10 + (_QWORD)v87);
v13 = *(_QWORD *)&byte_8[(_QWORD)v87];
}
else
{
v12 = (char *)v87 + 1;
v13 = *(_BYTE *)v87 >> 1;
}
std::string::assign((__int64 *)a2, v12, v13);
v11 = (__int64 *)v87;
}
if ( &v72 != v11 + 3 )
{
if ( (v11[3] & 1) != 0 )
{
v14 = (const void *)v11[5];
v15 = v11[4];
}
else
{
v14 = (char *)v11 + 25;
v15 = *((_BYTE *)v11 + 24) >> 1;
}
std::string::assign(&v72, v14, v15);
v11 = (__int64 *)v87;
}
}
if ( v11 )
{
v16 = (char *)v88;
if ( v11 != v88 )
{
do
{
v88 = (__int64 *)(v16 - 24);
std::string::~string((__int64)(v16 - 24));
v16 = (char *)v88;
}
while ( v11 != v88 );
v16 = (char *)v87;
}
operator delete(v16);
}
}
}
else
{
while ( v9 != ++v10 )
{
if ( *v10 == 35 )
goto LABEL_7;
}
}
}
}
}
locked = LevelEditorLayer::lockedLayerForObjectString(*(_QWORD *)(a1 + 1440), (unsigned __int8 *)a2);
if ( locked != -1 )
{
EditorUI::showLockedLayerAlert((EditorUI *)a1, (const char *)locked);
LABEL_24:
v18 = nullptr;
goto LABEL_25;
}
GJBaseGameLayer::lockExistingFirstParents(*(GJBaseGameLayer **)(a1 + 1440));
ObjectsFromString = LevelEditorLayer::createObjectsFromString(
*(_QWORD *)(a1 + 1440),
(unsigned __int8 *)a2,
1u,
*(_BYTE *)(*(_QWORD *)(*(_QWORD *)(a1 + 1440) + 1936LL) + 1201LL));
GJBaseGameLayer::unlockExistingFirstParents(*(_QWORD *)(a1 + 1440));
if ( !ObjectsFromString )
goto LABEL_24;
v20 = *(_QWORD *)(a1 + 1440);
*(_DWORD *)(v20 + 14708) += cocos2d::CCArray::count(ObjectsFromString);
if ( !v6 )
goto LABEL_31;
v24 = (unsigned __int8)v72 >> 1;
if ( (v72 & 1) != 0 )
v24 = v73;
if ( !v24 )
goto LABEL_31;
v87 = nullptr;
v88 = nullptr;
v89 = nullptr;
v90 = 0;
v91 = 1.0;
v75 = nullptr;
v76 = nullptr;
v77 = nullptr;
v78 = nullptr;
v79 = nullptr;
v80 = 0;
sub_BD8DB0((unsigned __int8 *)&v72, "|", (__int64 *)&v78);
v68 = v79;
if ( v78 == v79 )
goto LABEL_95;
v25 = (unsigned __int8 *)v78;
do
{
v81 = nullptr;
v82 = nullptr;
v83 = 0;
sub_BD8DB0(v25, &byte_1169BE0, (__int64 *)&v81);
if ( 0xAAAAAAAAAAAAAAABLL * ((v82 - (_BYTE *)v81) >> 3) <= 1 )
goto LABEL_57;
v26 = (char *)v81 + 1;
if ( (*(_BYTE *)v81 & 1) != 0 )
v26 = *((const char **)v81 + 2);
v27 = atoi(v26);
v28 = *(_QWORD *)(a1 + 1440);
v70 = v27;
*(_QWORD *)v71 = GJEffectManager::getColorAction(*(GJEffectManager **)(*(_QWORD *)(v28 + 3272) + 320LL), v27);
if ( ColorAction::isInUse(*(ColorAction **)v71) )
{
v61 = *(LevelEditorLayer **)(a1 + 1440);
*(_QWORD *)v71 = 0;
NextColorChannel = LevelEditorLayer::getNextColorChannel(v61);
if ( (unsigned int)(NextColorChannel - 1) <= 0x3E6 )
{
*(_QWORD *)v71 = GJEffectManager::getColorAction(
*(GJEffectManager **)(*(_QWORD *)(*(_QWORD *)(a1 + 1440) + 3272LL) + 320LL),
NextColorChannel);
*(_DWORD *)std::unordered_map::operator[]((__int64)&v87, &v70) = NextColorChannel;
}
}
v29 = *(ColorAction **)v71;
if ( !*(_QWORD *)v71 )
goto LABEL_57;
v84 = 0;
v85 = 0;
v30 = *((_BYTE *)v81 + 24);
v86 = nullptr;
if ( (v30 & 1) != 0 )
{
std::string::__init(&v84, *((void **)v81 + 5), *((_QWORD *)v81 + 4));
}
else
{
v31 = *((_QWORD *)v81 + 3);
v32 = *((_QWORD *)v81 + 4);
v86 = *((void **)v81 + 5);
v84 = v31;
v85 = v32;
}
ColorAction::setupFromString((__int64)v29, (unsigned __int8 *)&v84);
if ( (v84 & 1) != 0 )
{
operator delete(v86);
v33 = v76;
if ( v76 != v77 )
{
LABEL_54:
if ( v33 )
{
*v33 = *(_QWORD *)v71;
v33 = v76;
}
v76 = (char *)(v33 + 1);
goto LABEL_57;
}
}
else
{
v33 = v76;
if ( v76 != v77 )
goto LABEL_54;
}
std::vector::__push_back_slow_path((__int64)&v75, v71);
LABEL_57:
if ( v90 )
{
v34 = v76;
v35 = (char *)v75;
if ( v75 != v76 )
{
do
{
while ( 1 )
{
v36 = *(_QWORD *)v35;
v71[0] = *(_DWORD *)(*(_QWORD *)v35 + 120LL);
if ( (unsigned int)(v71[0] - 1) <= 0x3E6 )
{
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v87,
v71) )
{
break;
}
}
v35 += 8;
if ( v34 == v35 )
goto LABEL_64;
}
v35 += 8;
*(_DWORD *)(v36 + 120) = *(_DWORD *)std::unordered_map::operator[]((__int64)&v87, v71);
}
while ( v34 != v35 );
}
LABEL_64:
v37 = *((unsigned int **)ObjectsFromString + 7);
if ( *v37 )
{
v38 = *((GameObject ***)v37 + 2);
v39 = 8LL * *v37 - 8;
v40 = (char *)v38 + v39;
if ( v38 <= (GameObject **)((char *)v38 + v39) )
{
while ( 1 )
{
v41 = *v38;
if ( !*v38 )
goto LABEL_88;
MainColor = (int *)GameObject::getMainColor(*v38);
v43 = MainColor;
if ( MainColor )
{
v44 = *MainColor;
v45 = MainColor[1];
if ( v44 == v45 || !v44 )
v44 = v45;
v71[0] = v44;
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v87,
v71) )
{
v46 = *(_DWORD *)std::unordered_map::operator[]((__int64)&v87, v71);
v47 = 1101;
if ( v46 <= 1100 )
{
if ( v46 < 0 )
v47 = 0;
else
v47 = v46;
}
*v43 = v47;
}
}
SecondaryColor = (int *)GameObject::getSecondaryColor(v41);
v49 = SecondaryColor;
if ( SecondaryColor )
{
v50 = *SecondaryColor;
v51 = SecondaryColor[1];
if ( v50 == v51 || !v50 )
v50 = v51;
v71[0] = v50;
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v87,
v71) )
{
v52 = *(_DWORD *)std::unordered_map::operator[]((__int64)&v87, v71);
v53 = 1101;
if ( v52 <= 1100 )
{
if ( v52 < 0 )
v53 = 0;
else
v53 = v52;
}
*v49 = v53;
}
}
v54 = *((_DWORD *)v41 + 257);
if ( v54 == 899 )
goto LABEL_114;
if ( v54 == 1006 )
break;
LABEL_87:
if ( v40 < (char *)++v38 )
goto LABEL_88;
}
if ( !*((_DWORD *)v41 + 402) )
{
LABEL_114:
v71[0] = *((_DWORD *)v41 + 256);
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v87,
v71) )
{
*((_DWORD *)v41 + 256) = *(_DWORD *)std::unordered_map::operator[]((__int64)&v87, v71);
}
}
v71[0] = *((_DWORD *)v41 + 407);
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v87,
v71) )
{
*((_DWORD *)v41 + 407) = *(_DWORD *)std::unordered_map::operator[]((__int64)&v87, v71);
}
goto LABEL_87;
}
}
}
LABEL_88:
v55 = v81;
if ( v81 )
{
v56 = v82;
if ( v82 != v81 )
{
do
{
v82 = v56 - 24;
std::string::~string((__int64)(v56 - 24));
v56 = v82;
}
while ( v82 != v55 );
v55 = v81;
}
operator delete(v55);
}
v25 += 24;
}
while ( v68 != v25 );
v68 = (unsigned __int8 *)v78;
LABEL_95:
if ( v68 )
{
v57 = v79;
if ( v79 != v68 )
{
do
{
v79 = v57 - 24;
std::string::~string((__int64)(v57 - 24));
v57 = v79;
}
while ( v68 != v79 );
v68 = (unsigned __int8 *)v78;
}
operator delete(v68);
}
if ( v75 )
{
if ( v75 != v76 )
v76 += 8 * ~((unsigned __int64)(v76 - 8 - (_BYTE *)v75) >> 3);
operator delete(v75);
}
v58 = v89;
if ( v89 )
{
do
{
v59 = (_QWORD *)*v58;
operator delete(v58);
v58 = v59;
}
while ( v59 );
}
v60 = v87;
v87 = nullptr;
if ( v60 )
operator delete(v60);
LABEL_31:
if ( !v67 )
{
v63 = (UndoObject *)UndoObject::createWithArray(ObjectsFromString, 3);
LevelEditorLayer::addToUndoList(*(cocos2d::CCArray ***)(a1 + 1440), v63, 0);
}
if ( (unsigned int)cocos2d::CCArray::count(ObjectsFromString) )
{
EditorUI::deselectAll((EditorUI *)a1);
v21 = 0;
if ( (unsigned int)cocos2d::CCArray::count(ObjectsFromString) == 1 )
{
v64 = (GameObject *)cocos2d::CCArray::objectAtIndex(ObjectsFromString, 0);
EditorUI::selectObject((EditorUI *)a1, v64, 0);
v65 = *(_QWORD *)(a1 + 1496);
if ( v65 )
{
v66 = *(void (__fastcall **)(__int64, void *))(*(_QWORD *)v65 + 1528LL);
LOWORD(v81) = -256;
BYTE2(v81) = -1;
v66(v65, v81);
}
}
else
{
while ( v21 < (unsigned int)cocos2d::CCArray::count(ObjectsFromString) )
{
v22 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(ObjectsFromString, v21);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 896), v22);
v23 = *(void (__fastcall **)(cocos2d::CCObject *, void *))(*(_QWORD *)v22 + 1528LL);
LOWORD(v87) = -256;
BYTE2(v87) = -1;
v23(v22, v87);
++v21;
}
}
GJBaseGameLayer::assignNewStickyGroups(*(cocos2d::CCArray **)(a1 + 1440), ObjectsFromString);
}
v18 = ObjectsFromString;
LABEL_25:
if ( (v72 & 1) != 0 )
operator delete(v74);
return v18;
}