//
// LevelEditorLayer::getLevelString from 0x10035c378 to 0x10035c5b4 (572 bytes)
//
// 1 xrefs:
// > EditorPauseLayer::saveLevel @ 0x10039e2d8
//
// 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 __usercall LevelEditorLayer::getLevelString(__int64 a1@, std::string *a2@)
{
cocos2d::CCDictionary *v4; // x21
const std::string::value_type *p_p; // x1
std::string::size_type v6; // x2
__int64 v7; // x8
unsigned int *v8; // x9
__int64 v9; // x8
GameObject **v10; // x27
unsigned __int64 v11; // x28
__int64 v12; // x24
GameObject *v13; // x23
bool hasSecondaryColor; // w25
char v15; // w22
__int64 v16; // x26
cocos2d::CCObject *v17; // x0
char v18; // w8
const std::string::value_type *v19; // x1
std::string::size_type v20; // x2
void *__p; // [xsp+8h] [xbp-68h] BYREF
std::string::size_type v22; // [xsp+10h] [xbp-60h]
unsigned __int8 v23; // [xsp+1Fh] [xbp-51h]
GJBaseGameLayer::generateSpawnRemap((GJBaseGameLayer *)a1);
GJBaseGameLayer::calculateColorGroups((GJBaseGameLayer *)a1);
v4 = cocos2d::CCDictionary::create();
*(_BYTE *)(a1 + 13753) = 0;
sub_100009900(a2, "");
LevelSettingsObject::getSaveString(&__p, *(_QWORD *)(a1 + 3288));
if ( (v23 & 0x80u) == 0 )
p_p = (const std::string::value_type *)&__p;
else
p_p = (const std::string::value_type *)__p;
if ( (v23 & 0x80u) == 0 )
v6 = v23;
else
v6 = v22;
std::string::append(a2, p_p, v6);
if ( (char)v23 < 0 )
operator delete(__p);
std::string::append(a2, ";");
qsort(
*(void **)(*(_QWORD *)(*(_QWORD *)(a1 + 3296) + 56LL) + 16LL),
**(unsigned int **)(*(_QWORD *)(a1 + 3296) + 56LL),
8u,
(int (__cdecl *)(const void *, const void *))sub_1003566B4);
v7 = *(_QWORD *)(a1 + 3296);
if ( !v7 )
return;
v8 = *(unsigned int **)(v7 + 56);
v9 = *v8;
if ( !(_DWORD)v9 )
return;
v10 = *((GameObject ***)v8 + 2);
v11 = (unsigned __int64)&v10[v9 - 1];
v12 = 1;
do
{
v13 = *v10;
if ( !*v10 )
return;
if ( v13->m_unk507 )
goto LABEL_34;
GameObject::updateHSVState(*v10);
hasSecondaryColor = GameObject::hasSecondaryColor(v13);
v15 = 1;
do
{
GameObject::getColorKey((__int64)v13, v15 & 1, 1, &__p);
if ( cocos2d::CCDictionary::objectForKey_1(v4, &__p) )
{
v16 = v12;
LODWORD(v12) = *(_DWORD *)(cocos2d::CCDictionary::objectForKey_1(v4, &__p) + 56);
if ( (v15 & 1) != 0 )
goto LABEL_17;
}
else
{
v17 = sub_10011C030(v12);
cocos2d::CCDictionary::setObject_1(v4, v17, &__p);
v16 = (unsigned int)(v12 + 1);
if ( (v15 & 1) != 0 )
{
LABEL_17:
v13->m_mainColorKeyIndex = v12;
goto LABEL_20;
}
}
v13->m_detailColorKeyIndex = v12;
LABEL_20:
if ( (char)v23 < 0 )
operator delete(__p);
v18 = hasSecondaryColor & v15;
v12 = v16;
v15 = 0;
}
while ( (v18 & 1) != 0 );
((void (__fastcall *)(void **__return_ptr, GameObject *, __int64))v13->getSaveString)(&__p, v13, a1);
if ( (v23 & 0x80u) == 0 )
v19 = (const std::string::value_type *)&__p;
else
v19 = (const std::string::value_type *)__p;
if ( (v23 & 0x80u) == 0 )
v20 = v23;
else
v20 = v22;
std::string::append(a2, v19, v20);
std::string::append(a2, ";");
if ( (*(_BYTE *)(a1 + 13753) & 1) == 0 )
*(_BYTE *)(a1 + 13753) = v13->m_isHighDetail;
if ( (char)v23 < 0 )
operator delete(__p);
v12 = v16;
LABEL_34:
++v10;
}
while ( (unsigned __int64)v10 <= v11 );
}