//
// LevelEditorLayer::createObjectsFromSetup from 0x1000dcc90 to 0x1000dd3bc (1836 bytes)
//
// 1 xrefs:
// > LevelEditorLayer::init @ 0x1000dbd38
//
// 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 __fastcall LevelEditorLayer::createObjectsFromSetup(GJBaseGameLayer *a1, unsigned __int8 *a2)
{
unsigned int v2; // ebx
__int64 v3; // rbx
const void *v4; // rdi
void **v5; // rbx
double v6; // xmm0_8
cocos2d::CCDictionary *v7; // rax
LevelSettingsObject *v8; // rax
LevelEditorLayer *v9; // rcx
GameManager *v10; // rax
const std::string *v11; // rbx
void **v12; // r14
__int64 v13; // r15
__int64 v14; // rax
std::string::size_type v15; // rax
std::string::size_type v16; // r13
int v17; // eax
std::string::size_type v18; // rbx
char v19; // r14
std::string::size_type v20; // rax
std::string::size_type v21; // r12
std::string::pointer v22; // r14
std::string::size_type size; // r14
std::string::pointer data; // rbx
size_t v25; // r12
char *v26; // rbx
__int64 v27; // rax
size_t v28; // r15
char *v29; // rbx
__int64 v30; // rax
size_t v31; // r14
char *v32; // r15
size_t v33; // r12
__int64 v34; // rbx
std::string *v35; // r14
std::string::size_type v36; // r13
std::string::size_type v37; // rax
std::string::size_type v38; // rcx
__int64 v39; // rdx
GameObject *v40; // rax
GameObject *v41; // r14
int m_objectID; // eax
std::string *v43; // rdi
std::string *begin; // rbx
std::__vector_base::pointer end; // r14
std::__vector_base::pointer v46; // rdi
__int64 v47; // [rsp+8h] [rbp-108h]
__int128 v48; // [rsp+10h] [rbp-100h] BYREF
void *__p; // [rsp+20h] [rbp-F0h]
__int64 v50; // [rsp+28h] [rbp-E8h]
void *v51[2]; // [rsp+30h] [rbp-E0h] BYREF
__int64 v52; // [rsp+40h] [rbp-D0h]
std::string::size_type v53; // [rsp+50h] [rbp-C0h]
std::vector v54; // [rsp+58h] [rbp-B8h] BYREF
std::vector __s2; // [rsp+70h] [rbp-A0h] BYREF
char __dst[16]; // [rsp+90h] [rbp-80h] BYREF
char *v57; // [rsp+A0h] [rbp-70h]
__int64 v58; // [rsp+A8h] [rbp-68h]
std::string v59; // [rsp+B0h] [rbp-60h] BYREF
std::string::size_type v60; // [rsp+D0h] [rbp-40h]
LevelEditorLayer *v61; // [rsp+D8h] [rbp-38h]
char v62; // [rsp+E7h] [rbp-29h]
v61 = (LevelEditorLayer *)a1;
LOWORD(__s2.__begin_) = 8194;
BYTE2(__s2.__begin_) = 0;
v2 = *a2;
if ( (v2 & 1) != 0 )
{
v3 = *((_QWORD *)a2 + 1);
v4 = *((const void **)a2 + 2);
}
else
{
v3 = v2 >> 1;
v4 = a2 + 1;
}
if ( (memcmp(v4, (char *)&__s2.__begin_ + 1, v3 != 0) != 0 || v3 != 1) && v3 )
{
memset(&__s2, 0, sizeof(__s2));
sub_1000CADA0((__int64)&__s2, 0x259u);
v5 = (void **)operator new(0x12C8u);
__bzero(v5, 4808);
v54.__begin_ = v5;
v54.__end_ = v5 + 601;
v54.__end_cap_.__value_ = v5 + 601;
v6 = 0.0;
memset(&v59, 0, sizeof(v59));
*(_OWORD *)v51 = 0;
v52 = 0;
sub_1000DC810(a2, ";", (__int64)v51, 0.0);
if ( (*a2 & 1) != 0 )
{
**((_BYTE **)a2 + 2) = 0;
*((_QWORD *)a2 + 1) = 0;
}
else
{
*(_WORD *)a2 = 0;
}
v7 = (cocos2d::CCDictionary *)GameToolbox::stringSetupToDict(v51[0], ",");
v8 = LevelSettingsObject::objectFromDict(v7);
v9 = v61;
v61->m_levelSettings = v8;
v8->m_level = v9->m_level;
cocos2d::CCObject::retain(v8);
GJBaseGameLayer::loadLevelSettings(v61);
v10 = GameManager::sharedState();
GameManager::loadFont(v10, v61->m_levelSettings->m_fontIndex);
v11 = (const std::string *)v51[0];
v12 = (void **)v51[1];
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)v51[1] - (char *)v51[0]) >> 3) >= 2 )
{
v58 = 0;
v13 = 1;
while ( 1 )
{
std::string::operator=(&v59, &v11[v13]);
v14 = 0;
*v54.__begin_ = nullptr;
do
{
v54.__begin_[v14 + 1] = nullptr;
v54.__begin_[v14 + 2] = nullptr;
v54.__begin_[v14 + 3] = nullptr;
v14 += 4;
v54.__begin_[v14] = nullptr;
}
while ( v14 != 600 );
v47 = v13;
v15 = std::string::find(&v59, 44, 0);
if ( v15 != -1 )
break;
LABEL_63:
v40 = GameObject::objectFromVector(&__s2, &v54, v61, 0);
v41 = v40;
if ( v40 )
{
m_objectID = v40->m_objectID;
if ( m_objectID != 142 && (m_objectID != 1329 || v61->m_coinCount.random - v61->m_coinCount.seed <= 2) )
{
((void (__fastcall *)(GameObject *, _QWORD))v41->setVisible)(v41, 0);
((void (__fastcall *)(LevelEditorLayer *, GameObject *))v61->addToSection)(v61, v41);
LevelEditorLayer::addSpecial(v61, v41);
if ( v41->m_objectID == 31 )
{
if ( (*(_BYTE *)&v59.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v48, v59.__r_.__value_.__l.__data_, v59.__r_.__value_.__l.__size_, v6);
}
else
{
__p = v59.__r_.__value_.__l.__data_;
v6 = *(double *)v59.__r_.__value_.__r.__words;
v48 = *(_OWORD *)&v59.__r_.__value_.__l.0;
}
StartPosObject::loadSettingsFromString(v41, &v48);
if ( (v48 & 1) != 0 )
operator delete(__p);
}
}
}
v13 = v47 + 1;
v11 = (const std::string *)v51[0];
v12 = (void **)v51[1];
if ( 0xAAAAAAAAAAAAAAABLL * (((char *)v51[1] - (char *)v51[0]) >> 3) <= v47 + 1 )
goto LABEL_73;
}
v16 = v15;
if ( (*(_BYTE *)&v59.__r_.__value_.__s.0 & 1) != 0 )
v17 = v59.__r_.__value_.__r.__words[1];
else
v17 = *(_BYTE *)&v59.__r_.__value_.__l.0 >> 1;
v18 = v17;
v19 = 1;
v20 = 0;
v50 = 0;
v53 = v18;
while ( 1 )
{
v60 = v20;
if ( v20 == v18 )
goto LABEL_60;
if ( (v19 & 1) != 0 )
break;
if ( (unsigned int)(v58 - 1) <= 0x257 )
{
v62 = v19;
if ( (*(_BYTE *)&v59.__r_.__value_.__s.0 & 1) != 0 )
{
size = v59.__r_.__value_.__l.__size_;
if ( v59.__r_.__value_.__l.__size_ < v60 )
LABEL_97:
sub_1000547C0();
data = v59.__r_.__value_.__l.__data_;
}
else
{
size = *(_BYTE *)&v59.__r_.__value_.__l.0 >> 1;
data = v59.__r_.__value_.__s.__data_;
if ( v60 > size )
goto LABEL_97;
}
v31 = size - v60;
if ( v31 >= v16 - v60 )
v31 = v16 - v60;
if ( v31 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v6);
if ( v31 >= 0x17 )
{
v33 = 26;
if ( (v31 | 7) != 0x17 )
v33 = (v31 | 7) + 1;
v32 = (char *)operator new(v33);
v57 = v32;
*(_QWORD *)__dst = v33 | 1;
*(_QWORD *)&__dst[8] = v31;
}
else
{
__dst[0] = 2 * v31;
v32 = &__dst[1];
if ( !v31 )
{
LABEL_55:
v32[v31] = 0;
v34 = (unsigned int)v58;
v35 = &__s2.__begin_[(unsigned int)v58];
if ( (v35->m_data.m_short.sizex2 & 1) != 0 )
operator delete(v35->m_data.m_long.longStorage);
v35->m_data.m_long.longStorage = v57;
v6 = *(double *)__dst;
*(_OWORD *)&v35->m_data.m_short.sizex2 = *(_OWORD *)__dst;
v54.__begin_[v34] = v61;
goto LABEL_58;
}
}
memmove(v32, &data[v60], v31);
goto LABEL_55;
}
LABEL_59:
v19 ^= 1u;
LABEL_60:
if ( (v50 & 1) != 0 )
goto LABEL_63;
v36 = v16 + 1;
v37 = std::string::find(&v59, 44, v36);
v38 = v18;
LOBYTE(v39) = v37 == -1;
v50 = v39;
if ( v37 != -1 )
v38 = v37;
v20 = v36;
v16 = v38;
}
v62 = v19;
if ( (*(_BYTE *)&v59.__r_.__value_.__s.0 & 1) != 0 )
{
v21 = v59.__r_.__value_.__l.__size_;
if ( v59.__r_.__value_.__l.__size_ < v60 )
LABEL_95:
sub_1000547C0();
v22 = v59.__r_.__value_.__l.__data_;
}
else
{
v21 = *(_BYTE *)&v59.__r_.__value_.__l.0 >> 1;
v22 = v59.__r_.__value_.__s.__data_;
if ( v60 > v21 )
goto LABEL_95;
}
v25 = v21 - v60;
if ( v25 >= v16 - v60 )
v25 = v16 - v60;
if ( v25 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v6);
if ( v25 >= 0x17 )
{
v28 = 26;
if ( (v25 | 7) != 0x17 )
v28 = (v25 | 7) + 1;
v26 = (char *)operator new(v28);
v57 = v26;
*(_QWORD *)__dst = v28 | 1;
*(_QWORD *)&__dst[8] = v25;
}
else
{
__dst[0] = 2 * v25;
v26 = &__dst[1];
if ( !v25 )
{
__dst[1] = 0;
if ( (__dst[0] & 1) == 0 )
{
LABEL_37:
LODWORD(v27) = atoi(&__dst[1]);
v58 = v27;
LABEL_58:
v18 = v53;
v19 = v62;
goto LABEL_59;
}
LABEL_42:
v29 = v57;
LODWORD(v30) = atoi(v57);
v58 = v30;
operator delete(v29);
goto LABEL_58;
}
}
memmove(v26, &v22[v60], v25);
v26[v25] = 0;
if ( (__dst[0] & 1) == 0 )
goto LABEL_37;
goto LABEL_42;
}
LABEL_73:
if ( v11 )
{
v43 = (std::string *)v11;
if ( v12 != (void **)v11 )
{
do
{
if ( (*(_BYTE *)(v12 - 3) & 1) != 0 )
operator delete(*(v12 - 1));
v12 -= 3;
}
while ( v12 != (void **)v11 );
v43 = (std::string *)v51[0];
}
v51[1] = (void *)v11;
operator delete(v43);
}
if ( (*(_BYTE *)&v59.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v59.__r_.__value_.__l.__data_);
if ( v54.__begin_ )
{
v54.__end_ = v54.__begin_;
operator delete(v54.__begin_);
}
begin = __s2.__begin_;
if ( __s2.__begin_ )
{
end = __s2.__end_;
v46 = __s2.__begin_;
if ( __s2.__end_ != __s2.__begin_ )
{
do
{
if ( (end[-1].m_data.m_short.sizex2 & 1) != 0 )
operator delete(end[-1].m_data.m_long.longStorage);
--end;
}
while ( end != begin );
v46 = __s2.__begin_;
}
__s2.__end_ = begin;
operator delete(v46);
}
}
}