//
// LevelEditorLayer::createObjectsFromString from 0x100359730 to 0x100359abc (908 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::duplicateKeyframeAnimation @ 0x1003642fc
// > EditorUI::spriteFromObjectString @ 0x1003ea89c
// > EditorUI::pasteObjects @ 0x1003ec988
//
// 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
//
__int64 __fastcall LevelEditorLayer::createObjectsFromString(__int64 a1, std::string *a2, char a3, int a4)
{
bool v6; // w22
cocos2d::CCObject *v8; // x19
__int64 v9; // x8
unsigned __int64 v10; // x28
int v11; // w23
__int64 i; // x9
__int64 v13; // x24
std::string::size_type v14; // x25
__int64 v15; // x8
std::string::size_type v16; // x26
__int64 v17; // x22
char v18; // w19
std::string *v19; // x26
__int128 v20; // q0
void *v21; // x26
GameObject *v22; // x0
GameObject *v23; // x25
int v24; // w8
UndoObject *v25; // x0
EditorUI *v26; // x0
__int64 v27; // [xsp+8h] [xbp-C8h]
std::string v30; // [xsp+18h] [xbp-B8h] BYREF
__int64 v31; // [xsp+30h] [xbp-A0h] BYREF
__int64 v32; // [xsp+38h] [xbp-98h]
__int64 v33; // [xsp+40h] [xbp-90h]
std::vector __p; // [xsp+48h] [xbp-88h] BYREF
std::vector v35; // [xsp+60h] [xbp-70h] BYREF
std::allocator __a; // [xsp+7Fh] [xbp-51h] BYREF
sub_100009900(&v35, " ");
if ( sub_1000045BC(a2, &v35) )
{
v6 = 1;
}
else
{
sub_100009900(&__p, "");
v6 = sub_1000045BC(a2, &__p);
if ( SHIBYTE(__p.__end_cap_.__value_) < 0 )
operator delete(__p.__begin_);
}
if ( SHIBYTE(v35.__end_cap_.__value_) < 0 )
{
operator delete(v35.__begin_);
if ( v6 )
return 0;
}
else if ( v6 )
{
return 0;
}
*(_BYTE *)(a1 + 13128) = 1;
sub_10024A45C(*(_QWORD *)(a1 + 14000));
v8 = sub_10024A15C();
memset(&v35, 0, sizeof(v35));
sub_10011BFA4(&v35, 0x259u);
memset(&__p, 0, sizeof(__p));
sub_10000EC70(&__p, 0x259u);
v27 = (__int64)v8;
v31 = 0;
v32 = 0;
v33 = 0;
sub_100357AB0(a2, ";", (__int64)&v31);
v9 = v31;
if ( v32 != v31 )
{
v10 = 0;
v11 = 0;
while ( a4 || (*(_BYTE *)(a1 + 13944) & 1) != 0 || *(_DWORD *)(a1 + 14008) - *(_DWORD *)(a1 + 14012) < 80000 )
{
for ( i = 0; i != 601; ++i )
__p.__begin_[i] = nullptr;
v13 = v9 + 24 * v10;
v14 = std::string::find((const std::string *)v13, 44, 0);
v15 = *(char *)(v13 + 23);
if ( v15 < 0 )
v15 = *(_QWORD *)(v13 + 8);
v16 = 0;
v17 = (int)v15;
v18 = 1;
while ( 1 )
{
if ( v16 != v17 )
{
if ( (v18 & 1) != 0 )
{
std::string::basic_string(&v30, (const std::string *)v13, v16, v14 - v16, &__a);
if ( SHIBYTE(v30.__r_.__value_.__r.__words[2]) < 0 )
{
v21 = (void *)v30.__r_.__value_.__r.__words[0];
v11 = atoi(v30.__r_.__value_.__l.__data_);
operator delete(v21);
}
else
{
v11 = atoi((const char *)&v30);
}
}
else if ( v11 >= 1 )
{
std::string::basic_string(&v30, (const std::string *)v13, v16, v14 - v16, &__a);
v19 = &v35.__begin_[v11];
if ( v19->m_data.m_short.shortStorage.__elems_[22] < 0 )
operator delete((void *)v19->m_data.m_long.capacitym1);
v20 = *(_OWORD *)&v30.__r_.__value_.__l.__data_;
v19->m_data.m_long.longStorage = (char *)v30.__r_.__value_.__r.__words[2];
*(_OWORD *)&v19->m_data.m_short.sizex2 = v20;
__p.__begin_[v11] = (void *)a1;
}
v18 ^= 1u;
}
if ( v14 == -1 )
break;
v16 = v14 + 1;
v14 = std::string::find((const std::string *)v13, 44, v14 + 1);
}
v22 = LevelEditorLayer::addObjectFromVector((LevelEditorLayer *)a1, &v35, &__p);
v23 = v22;
if ( v22 )
{
v24 = *(unsigned __int16 *)(a1 + 13946);
if ( v24 != 0xFFFF
&& (*(_BYTE *)(a1 + 13888) & 1) == 0
&& (unsigned __int16)v22->m_editorLayer != v24
&& (unsigned __int16)v22->m_editorLayer2 != v24 )
{
v22->m_editorLayer = v24;
}
sub_10024A2D0(v27);
if ( (a3 & 1) == 0 )
{
v25 = UndoObject::create(v23, New);
LevelEditorLayer::addToUndoList((LevelEditorLayer *)a1, v25, 0);
}
}
if ( *(char *)(v13 + 23) < 0 )
{
**(_BYTE **)v13 = 0;
*(_QWORD *)(v13 + 8) = 0;
}
else
{
*(_BYTE *)v13 = 0;
*(_BYTE *)(v13 + 23) = 0;
}
++v10;
v9 = v31;
if ( 0xAAAAAAAAAAAAAAABLL * ((v32 - v31) >> 3) <= v10 )
goto LABEL_43;
}
v26 = *(EditorUI **)(a1 + 13984);
if ( v26 )
EditorUI::showMaxError(v26);
}
LABEL_43:
*(_BYTE *)(a1 + 13128) = 0;
v30.__r_.__value_.__r.__words[0] = (std::string::size_type)&v31;
sub_1000177FC((void ***)&v30);
if ( __p.__begin_ )
{
__p.__end_ = __p.__begin_;
operator delete(__p.__begin_);
}
__p.__begin_ = (std::__vector_base::pointer)&v35;
sub_1000177FC(&__p.__begin_);
return v27;
}