//
// EditorUI::pasteObjects from 0x1003ec86c to 0x1003eced4 (1640 bytes)
//
// 6 xrefs:
// > SetupSmartBlockLayer::onPasteTemplate @ 0x10006ff58
// > EditorUI::onDuplicate @ 0x1003e4790
// > EditorUI::onCreateObject @ 0x1003eb6b0
// > EditorUI::doPasteObjects @ 0x1003eeca4
// > EditorUI::createSmartObjectsFromTemplate @ 0x1003f1bd8
// > EditorUI::createPrefab @ 0x1003f2508
//
// 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
//
cocos2d::CCArray *__fastcall EditorUI::pasteObjects(__int64 a1, std::string *__s, int a3, char a4)
{
signed __int64 size; // x2
std::string *v9; // x21
_BYTE *v10; // x23
std::string *v11; // x0
_BYTE *v12; // x0
cocos2d::CCArray *ObjectsFromString; // x20
std::string::size_type v14; // x8
UndoObject *v15; // x0
GameObject *v16; // x0
__int64 v17; // x0
unsigned int i; // w21
__int64 v20; // x22
void **v21; // [xsp+38h] [xbp-F8h] BYREF
void *v22[3]; // [xsp+50h] [xbp-E0h] BYREF
void *v23; // [xsp+68h] [xbp-C8h] BYREF
void *v24; // [xsp+70h] [xbp-C0h]
__int64 v25; // [xsp+78h] [xbp-B8h]
__int128 v26; // [xsp+80h] [xbp-B0h] BYREF
__int128 v27; // [xsp+90h] [xbp-A0h]
int v28; // [xsp+A0h] [xbp-90h]
std::string v29; // [xsp+A8h] [xbp-88h] BYREF
memset(&v29, 0, sizeof(v29));
if ( a3 )
{
size = SHIBYTE(__s->__r_.__value_.__r.__words[2]);
if ( size < 0 )
{
v9 = (std::string *)__s->__r_.__value_.__r.__words[0];
size = __s->__r_.__value_.__l.__size_;
}
else
{
v9 = __s;
}
if ( size >= 1 )
{
v10 = (char *)v9 + size;
v11 = v9;
do
{
v12 = memchr(v11, 35, size);
if ( !v12 )
break;
if ( *v12 == 35 )
{
if ( v12 != v10 && v12 - (_BYTE *)v9 != -1 )
{
v26 = 0u;
*(_QWORD *)&v27 = 0;
sub_1003EED9C((int)__s, "#");
v23 = &v26;
sub_1000177FC((void ***)&v23);
}
break;
}
v11 = (std::string *)(v12 + 1);
size = v10 - (_BYTE *)v11;
}
while ( v10 - (_BYTE *)v11 >= 1 );
}
}
ObjectsFromString = (cocos2d::CCArray *)LevelEditorLayer::createObjectsFromString(
*(_QWORD *)(a1 + 1256),
__s,
1,
*(unsigned __int8 *)(*(_QWORD *)(*(_QWORD *)(a1 + 1256) + 1936LL) + 1089LL));
if ( ObjectsFromString )
{
if ( a3 )
{
v14 = HIBYTE(v29.__r_.__value_.__r.__words[2]);
if ( (v29.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
v14 = v29.__r_.__value_.__l.__size_;
if ( v14 )
{
v26 = 0u;
v27 = 0u;
v28 = 1065353216;
v23 = nullptr;
v24 = nullptr;
v25 = 0;
memset(v22, 0, sizeof(v22));
sub_1003EED9C((int)&v29, "|");
v21 = v22;
sub_1000177FC(&v21);
if ( v23 )
{
v24 = v23;
operator delete(v23);
}
sub_100017A98((__int64)&v26);
}
}
if ( (a4 & 1) == 0 )
{
v15 = UndoObject::createWithArray(ObjectsFromString, Paste);
LevelEditorLayer::addToUndoList(*(LevelEditorLayer **)(a1 + 1256), v15, 0);
}
if ( (unsigned int)sub_10024A36C((__int64)ObjectsFromString) )
{
EditorUI::deselectAll((EditorUI *)a1);
if ( (unsigned int)sub_10024A36C((__int64)ObjectsFromString) == 1 )
{
v16 = (GameObject *)sub_10024A388((__int64)ObjectsFromString, 0);
EditorUI::selectObject((EditorUI *)a1, v16, 0);
v17 = *(_QWORD *)(a1 + 1312);
if ( v17 )
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v17 + 1512LL))(v17, 16776960);
}
else
{
for ( i = 0; i < (unsigned int)sub_10024A36C((__int64)ObjectsFromString); ++i )
{
v20 = sub_10024A388((__int64)ObjectsFromString, i);
sub_10024A2D0(*(_QWORD *)(a1 + 808));
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v20 + 1512LL))(v20, 16776960);
}
}
GJBaseGameLayer::assignNewStickyGroups(*(GJBaseGameLayer **)(a1 + 1256), ObjectsFromString);
}
}
if ( SHIBYTE(v29.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v29.__r_.__value_.__l.__data_);
return ObjectsFromString;
}