//
// LevelEditorLayer::getLevelString from 0x7a77cc to 0x7a7b70 (932 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::saveLevel @ 0x7a7bb4
// > LevelEditorLayer::doAutoSave @ 0x7a7e44
// > LevelEditorLayer::doAutoBackup @ 0x7a8384
// > ??> @ 0xe2e28
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 12:53:43 +0000
//
__int64 *__usercall LevelEditorLayer::getLevelString@(LevelSettingsObject **this@, __int64 *a2@)
{
char *v2; // x20
int v5; // w0
char *v6; // x1
size_t v7; // x2
__int64 v8; // x0
unsigned int *v9; // x1
__int64 *v10; // x25
__int64 v11; // x0
char *v12; // x27
__int64 v13; // x22
int v14; // w26
void **v15; // x19
void **v16; // x20
void **v17; // x0
void *v18; // x0
int v20; // w20
int v21; // w24
__int64 *v22; // x0
int v23; // w0
char *v24; // x1
size_t v25; // x2
char *v27; // [xsp+78h] [xbp+78h]
__int64 v28; // [xsp+88h] [xbp+88h] BYREF
size_t v29; // [xsp+90h] [xbp+90h]
void *v30; // [xsp+98h] [xbp+98h]
void *v31[2]; // [xsp+A0h] [xbp+A0h] BYREF
void *v32; // [xsp+B0h] [xbp+B0h]
__int64 v33; // [xsp+B8h] [xbp+B8h]
float v34; // [xsp+C0h] [xbp+C0h]
v2 = (char *)(this + 1536);
v27 = (char *)(this + 1536);
GJBaseGameLayer::generateSpawnRemap((GJBaseGameLayer *)this);
GJBaseGameLayer::calculateColorGroups((GJBaseGameLayer *)this);
v2[1730] = 0;
*a2 = 0;
a2[1] = 0;
a2[2] = 0;
v31[0] = nullptr;
v31[1] = nullptr;
v32 = nullptr;
v33 = 0;
v34 = 1.0;
std::string::__init(a2, &byte_11B8890, 0);
v5 = cocos2d::CCArray::count(*(this + 410));
std::string::reserve(a2, (unsigned int)(200 * v5));
LevelSettingsObject::getSaveString(*(this + 409), &v28);
if ( (v28 & 1) != 0 )
{
v6 = (char *)v30;
v7 = v29;
}
else
{
v7 = (unsigned __int8)v28 >> 1;
v6 = (char *)&v28 + 1;
}
std::string::append((__int64)a2, v6, v7);
if ( (v28 & 1) != 0 )
operator delete(v30);
std::string::append((__int64)a2, ";", 1u);
qsort(
*(void **)(*((_QWORD *)*(this + 410) + 7) + 16LL),
**((unsigned int **)*(this + 410) + 7),
8u,
(int (*)(const void *, const void *))mIDSaveSort);
v8 = (__int64)*(this + 410);
if ( !v8 )
goto LABEL_12;
v9 = *(unsigned int **)(v8 + 56);
if ( !*v9 )
goto LABEL_12;
v10 = *((__int64 **)v9 + 2);
v11 = 8LL * *v9 - 8;
v12 = (char *)v10 + v11;
if ( v10 > (__int64 *)((char *)v10 + v11) )
goto LABEL_12;
v13 = *v10;
v14 = 1;
if ( !*v10 )
goto LABEL_12;
do
{
if ( *(_BYTE *)(v13 + 1303) )
goto LABEL_10;
GameObject::updateHSVState((GameObject *)v13);
v20 = 0;
if ( GameObject::hasSecondaryColor((GameObject *)v13) )
v21 = 2;
else
v21 = 1;
do
{
GameObject::getColorKey((GameObject *)v13, (v20 ^ 1) & 1, 1u, &v28);
v22 = std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
v31,
(__int64)&v28);
if ( v22 )
{
v23 = *((_DWORD *)v22 + 10);
}
else
{
*(_DWORD *)std::unordered_map::operator[]((__int64)v31, &v28) = v14;
v23 = v14++;
}
if ( (((unsigned __int8)v20 ^ 1) & 1) != 0 )
{
*(_DWORD *)(v13 + 1320) = v23;
if ( (v28 & 1) == 0 )
goto LABEL_27;
}
else
{
*(_DWORD *)(v13 + 1324) = v23;
if ( (v28 & 1) == 0 )
goto LABEL_27;
}
operator delete(v30);
LABEL_27:
++v20;
}
while ( v20 != v21 );
(*(void (__fastcall **)(__int64 *__return_ptr, __int64, LevelSettingsObject **))(*(_QWORD *)v13 + 1392LL))(
&v28,
v13,
this);
if ( (v28 & 1) != 0 )
{
v24 = (char *)v30;
v25 = v29;
}
else
{
v25 = (unsigned __int8)v28 >> 1;
v24 = (char *)&v28 + 1;
}
std::string::append((__int64)a2, v24, v25);
std::string::append((__int64)a2, ";", 1u);
if ( !v27[1730] )
v27[1730] = *(_BYTE *)(v13 + 1259);
if ( (v28 & 1) != 0 )
operator delete(v30);
LABEL_10:
if ( v12 < (char *)++v10 )
break;
v13 = *v10;
}
while ( *v10 );
LABEL_12:
v15 = (void **)v32;
if ( v32 )
{
do
{
v16 = (void **)*v15;
if ( ((_BYTE)v15[2] & 1) != 0 )
operator delete(v15[4]);
v17 = v15;
v15 = v16;
operator delete(v17);
}
while ( v16 );
}
v18 = v31[0];
v31[0] = nullptr;
if ( v18 )
operator delete(v18);
return a2;
}