//
// EditorUI::pasteObjects from 0x6f2d38 to 0x6f31ea (1202 bytes)
//
// 7 xrefs:
// > EditorUI::createPrefab @ 0x4871e0
// > EditorUI::onCreateObject @ 0x487574
// > EditorUI::createSmartObjectsFromTemplate @ 0x487fb4
// > SetupSmartBlockLayer::onPasteTemplate @ 0x6739fc
// > EditorUI::doPasteObjects @ 0x6f3286
// > EditorUI::doPasteInPlace @ 0x6f33d2
// > EditorUI::onDuplicate @ 0x6f3a28
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:57:37 +0000
//
cocos2d::CCArray *__fastcall EditorUI::pasteObjects(int a1, unsigned __int8 *a2, int a3, int a4)
{
int v7; // r3
int v8; // r3
unsigned __int8 *v9; // r1
bool v10; // cc
unsigned __int8 *v11; // r3
unsigned __int8 *v12; // r0
unsigned __int8 *v13; // r2
int v14; // r4
const char *locked; // r1
cocos2d::CCArray *ObjectsFromString; // r4
int v17; // r7
UndoObject *v19; // r0
GameObject *v20; // r0
int v21; // r0
const char *v23; // r0
unsigned int v24; // r0
int v25; // r3
LevelEditorLayer *v26; // r0
int NextColorChannel; // r0
int v28; // r6
ColorAction *v29; // r7
int v30; // r2
int v31; // r3
char *v32; // r10
char *v33; // r6
int v34; // r7
int v35; // t1
_DWORD *v36; // r3
GameObject **v37; // r10
GameObject *v38; // r6
GameObject *v39; // t1
int MainColor; // r0
int *v41; // r9
ColorAction *v42; // r3
int *v43; // r0
int v44; // r3
int SecondaryColor; // r0
int *v46; // r9
ColorAction *v47; // r3
int *v48; // r0
int v49; // r3
int v50; // r3
void (__fastcall *v51)(int, int); // r2
unsigned int j; // r6
cocos2d::CCObject *v53; // r7
void (__fastcall *v54)(cocos2d::CCObject *, unsigned __int8 *); // r3
unsigned __int8 *i; // [sp+0h] [bp-7Ch]
unsigned __int8 *v57; // [sp+8h] [bp-74h]
GameObject **v58; // [sp+Ch] [bp-70h]
unsigned int v59; // [sp+1Ch] [bp-60h] BYREF
ColorAction *ColorAction; // [sp+20h] [bp-5Ch] BYREF
int v61; // [sp+24h] [bp-58h] BYREF
int v62; // [sp+28h] [bp-54h]
int v63; // [sp+2Ch] [bp-50h]
void *v64; // [sp+30h] [bp-4Ch] BYREF
char *v65; // [sp+34h] [bp-48h]
char *v66; // [sp+38h] [bp-44h]
unsigned __int8 *v67; // [sp+3Ch] [bp-40h] BYREF
unsigned __int8 *v68; // [sp+40h] [bp-3Ch]
int v69; // [sp+44h] [bp-38h]
int v70; // [sp+48h] [bp-34h] BYREF
int v71; // [sp+4Ch] [bp-30h]
int v72; // [sp+50h] [bp-2Ch]
int v73[3]; // [sp+54h] [bp-28h] BYREF
unsigned __int8 *v74; // [sp+60h] [bp-1Ch] BYREF
int v75; // [sp+64h] [bp-18h]
int v76; // [sp+68h] [bp-14h]
int v77; // [sp+6Ch] [bp-10h]
int v78; // [sp+70h] [bp-Ch]
v61 = 0;
v62 = 0;
v63 = 0;
if ( a3 )
{
v7 = *a2;
if ( (v7 & 1) != 0 )
{
v8 = *((_DWORD *)a2 + 1);
v9 = *((unsigned __int8 **)a2 + 2);
}
else
{
v8 = v7 >> 1;
v9 = a2 + 1;
}
v10 = v8 <= 0;
if ( v8 )
{
v11 = &v9[v8];
if ( !v10 )
{
v12 = v9;
while ( 1 )
{
v13 = v12;
if ( v12 == v11 )
break;
v14 = *v12++;
if ( v14 == 35 )
goto LABEL_12;
}
}
v13 = v11;
LABEL_12:
if ( v13 != v11 && v13 - v9 != -1 )
{
v74 = nullptr;
v75 = 0;
v76 = 0;
sub_6F29CC(a2, "#", (int *)&v74);
if ( (unsigned int)(-1431655765 * ((v75 - (int)v74) >> 2)) > 1 )
{
std::string::operator=(a2, v74);
std::string::operator=((unsigned __int8 *)&v61, v74 + 12);
}
std::__vector_base::~__vector_base((int)&v74);
}
}
}
locked = (const char *)LevelEditorLayer::lockedLayerForObjectString(*(_DWORD *)(a1 + 944), a2);
if ( locked != (const char *)-1 )
{
EditorUI::showLockedLayerAlert((EditorUI *)a1, locked);
LABEL_19:
ObjectsFromString = nullptr;
goto LABEL_38;
}
GJBaseGameLayer::lockExistingFirstParents(*(GJBaseGameLayer **)(a1 + 944));
ObjectsFromString = LevelEditorLayer::createObjectsFromString(
*(_DWORD *)(a1 + 944),
a2,
1,
*(unsigned __int8 *)(*(_DWORD *)(*(_DWORD *)(a1 + 944) + 1408) + 985));
GJBaseGameLayer::unlockExistingFirstParents(*(GJBaseGameLayer **)(a1 + 944));
if ( !ObjectsFromString )
goto LABEL_19;
v17 = *(_DWORD *)(a1 + 944);
*(_DWORD *)(v17 + 12108) += cocos2d::CCArray::count(ObjectsFromString);
if ( a3 )
{
if ( (v61 & 1) != 0 ? v62 : (int)(unsigned __int8)v61 >> 1 )
{
v78 = 1065353216;
v74 = nullptr;
v75 = 0;
v76 = 0;
v77 = 0;
v64 = nullptr;
v65 = nullptr;
v66 = nullptr;
v67 = nullptr;
v68 = nullptr;
v69 = 0;
sub_6F29CC((unsigned __int8 *)&v61, "|", (int *)&v67);
v57 = v68;
for ( i = v67; i != v57; i += 12 )
{
v70 = 0;
v71 = 0;
v72 = 0;
sub_6F29CC(i, ",", &v70);
if ( (unsigned int)(-1431655765 * ((v71 - v70) >> 2)) > 1 )
{
if ( (*(_BYTE *)v70 & 1) != 0 )
v23 = *(const char **)(v70 + 8);
else
v23 = (const char *)(v70 + 1);
v24 = atoi(v23);
v25 = *(_DWORD *)(*(_DWORD *)(a1 + 944) + 2084);
v59 = v24;
ColorAction = GJEffectManager::getColorAction(*(GJEffectManager **)(v25 + 264), v24);
if ( ColorAction::isInUse(ColorAction) )
{
v26 = *(LevelEditorLayer **)(a1 + 944);
ColorAction = nullptr;
NextColorChannel = LevelEditorLayer::getNextColorChannel(v26);
v28 = NextColorChannel;
if ( (unsigned int)(NextColorChannel - 1) <= 0x3E6 )
{
ColorAction = GJEffectManager::getColorAction(
*(GJEffectManager **)(*(_DWORD *)(*(_DWORD *)(a1 + 944) + 2084) + 264),
NextColorChannel);
*std::unordered_map::operator[]((int)&v74, &v59) = v28;
}
}
v29 = ColorAction;
if ( ColorAction )
{
std::string::basic_string(v73, v70 + 12);
ColorAction::setupFromString((int)v29, (unsigned __int8 *)v73, v30, v31);
std::string::~string((int)v73);
if ( v65 == v66 )
{
std::vector::__push_back_slow_path((int)&v64, &ColorAction);
}
else
{
if ( v65 )
*(_DWORD *)v65 = ColorAction;
v65 += 4;
}
}
}
if ( v77 )
{
v32 = v65;
v33 = (char *)v64;
while ( v33 != v32 )
{
v35 = *(_DWORD *)v33;
v33 += 4;
v34 = v35;
ColorAction = *(ColorAction **)(v35 + 116);
if ( (unsigned int)ColorAction - 1 <= 0x3E6
&& std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v74,
(unsigned int *)&ColorAction) )
{
*(_DWORD *)(v34 + 116) = *std::unordered_map::operator[]((int)&v74, (unsigned int *)&ColorAction);
}
}
v36 = *((_DWORD **)ObjectsFromString + 13);
if ( *v36 )
{
v37 = (GameObject **)v36[3];
v58 = &v37[*v36] + 0x3FFFFFFF;
while ( v37 <= v58 )
{
v39 = *v37++;
v38 = v39;
if ( !v39 )
break;
MainColor = GameObject::getMainColor(v38);
v41 = (int *)MainColor;
if ( MainColor )
{
v42 = *(ColorAction **)MainColor;
if ( *(_DWORD *)(MainColor + 4) != *(_DWORD *)MainColor && !v42 )
v42 = *(ColorAction **)(MainColor + 4);
ColorAction = v42;
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v74,
(unsigned int *)&ColorAction) )
{
v43 = std::unordered_map::operator[]((int)&v74, (unsigned int *)&ColorAction);
if ( *v43 > 1100 )
v44 = 1101;
else
v44 = *v43 & ~(*v43 >> 31);
*v41 = v44;
}
}
SecondaryColor = GameObject::getSecondaryColor(v38);
v46 = (int *)SecondaryColor;
if ( SecondaryColor )
{
v47 = *(ColorAction **)SecondaryColor;
if ( *(_DWORD *)(SecondaryColor + 4) != *(_DWORD *)SecondaryColor && !v47 )
v47 = *(ColorAction **)(SecondaryColor + 4);
ColorAction = v47;
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v74,
(unsigned int *)&ColorAction) )
{
v48 = std::unordered_map::operator[]((int)&v74, (unsigned int *)&ColorAction);
if ( *v48 > 1100 )
v49 = 1101;
else
v49 = *v48 & ~(*v48 >> 31);
*v46 = v49;
}
}
v50 = *((_DWORD *)v38 + 223);
if ( v50 == 899 )
goto LABEL_86;
if ( v50 != 1006 )
continue;
if ( !*((_DWORD *)v38 + 357) )
{
LABEL_86:
ColorAction = *((ColorAction **)v38 + 222);
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v74,
(unsigned int *)&ColorAction) )
{
*((_DWORD *)v38 + 222) = *std::unordered_map::operator[](
(int)&v74,
(unsigned int *)&ColorAction);
}
}
ColorAction = *((ColorAction **)v38 + 362);
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
&v74,
(unsigned int *)&ColorAction) )
{
*((_DWORD *)v38 + 362) = *std::unordered_map::operator[](
(int)&v74,
(unsigned int *)&ColorAction);
}
}
}
}
std::__vector_base::~__vector_base((int)&v70);
}
std::__vector_base::~__vector_base((int)&v67);
if ( v64 )
{
v65 -= 4 * ((unsigned int)(v65 - (_BYTE *)v64) >> 2);
operator delete(v64);
}
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::~__hash_table((int)&v74);
}
}
if ( !a4 )
{
v19 = UndoObject::createWithArray(ObjectsFromString, 3);
LevelEditorLayer::addToUndoList(*(cocos2d::CCArray ***)(a1 + 944), v19, 0);
}
if ( cocos2d::CCArray::count(ObjectsFromString) )
{
EditorUI::deselectAll((EditorUI *)a1);
if ( cocos2d::CCArray::count(ObjectsFromString) == 1 )
{
v20 = (GameObject *)cocos2d::CCArray::objectAtIndex(ObjectsFromString, 0);
EditorUI::selectObject((EditorUI *)a1, v20, 0);
v21 = *(_DWORD *)(a1 + 996);
if ( v21 )
{
v51 = *(void (__fastcall **)(int, int))(*(_DWORD *)v21 + 764);
LOWORD(v70) = -256;
BYTE2(v70) = -1;
v51(v21, v70);
}
}
else
{
for ( j = 0; j < cocos2d::CCArray::count(ObjectsFromString); ++j )
{
v53 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(ObjectsFromString, j);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(a1 + 668), v53);
v54 = *(void (__fastcall **)(cocos2d::CCObject *, unsigned __int8 *))(*(_DWORD *)v53 + 764);
LOWORD(v74) = -256;
BYTE2(v74) = -1;
v54(v53, v74);
}
}
GJBaseGameLayer::assignNewStickyGroups(*(_DWORD *)(a1 + 944), ObjectsFromString);
}
LABEL_38:
std::string::~string((int)&v61);
return ObjectsFromString;
}