//
// LevelEditorLayer::getLevelString from 0x4725ec to 0x4727ca (478 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::saveLevel @ 0x472804
// > LevelEditorLayer::doAutoSave @ 0x472980
// > LevelEditorLayer::doAutoBackup @ 0x472c20
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:49:05 +0000
//
LevelEditorLayer *__fastcall LevelEditorLayer::getLevelString(LevelEditorLayer *this, int a2)
{
int v4; // r0
_BYTE *v5; // r1
size_t v6; // r2
int v7; // r3
_DWORD *v9; // r3
int v10; // r9
int *v11; // r8
int v12; // r5
int v13; // t1
int v14; // r10
int v15; // r3
int *v16; // r0
int v17; // r3
_BYTE *v18; // r1
size_t v19; // r2
int v20; // [sp+8h] [bp-3Ch]
int *v21; // [sp+Ch] [bp-38h]
unsigned __int8 v22; // [sp+1Ch] [bp-28h] BYREF
_BYTE v23[3]; // [sp+1Dh] [bp-27h] BYREF
size_t v24; // [sp+20h] [bp-24h]
_BYTE *v25; // [sp+24h] [bp-20h]
_DWORD v26[5]; // [sp+28h] [bp-1Ch] BYREF
GJBaseGameLayer::generateSpawnRemap((GJBaseGameLayer *)a2);
GJBaseGameLayer::calculateColorGroups((GJBaseGameLayer *)a2);
v26[4] = 1065353216;
*(_BYTE *)(a2 + 11710) = 0;
*(_DWORD *)this = 0;
*((_DWORD *)this + 1) = 0;
*((_DWORD *)this + 2) = 0;
memset(v26, 0, 16);
std::string::__init((int *)this, &unk_B6B226, 0);
v4 = cocos2d::CCArray::count(*(cocos2d::CCArray **)(a2 + 2088));
std::string::reserve((int *)this, 200 * v4);
LevelSettingsObject::getSaveString((LevelSettingsObject *)&v22, *(_DWORD *)(a2 + 2084));
if ( (v22 & 1) != 0 )
{
v5 = v25;
v6 = v24;
}
else
{
v6 = (int)v22 >> 1;
v5 = v23;
}
std::string::append(this, v5, v6);
std::string::~string((int)&v22);
std::string::append(this, ";");
qsort(
*(void **)(*(_DWORD *)(*(_DWORD *)(a2 + 2088) + 52) + 12),
**(_DWORD **)(*(_DWORD *)(a2 + 2088) + 52),
4u,
mIDSaveSort);
v7 = *(_DWORD *)(a2 + 2088);
if ( v7 )
{
v9 = *(_DWORD **)(v7 + 52);
if ( *v9 )
{
v10 = 1;
v11 = (int *)v9[3];
v21 = &v11[*v9 - 1];
while ( v11 <= v21 )
{
v13 = *v11++;
v12 = v13;
if ( !v13 )
break;
if ( !*(_BYTE *)(v12 + 1123) )
{
GameObject::updateHSVState(v12);
v14 = 0;
if ( GameObject::hasSecondaryColor((GameObject *)v12) )
v15 = 2;
else
v15 = 1;
v20 = v15;
do
{
GameObject::getColorKey((GameObject *)&v22, v12, ((unsigned __int8)v14 ^ 1) & 1, 1);
v16 = std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
v26,
&v22);
if ( v16 )
{
v17 = v16[5];
}
else
{
*std::unordered_map::operator[]((int)v26, &v22) = v10;
v17 = v10++;
}
if ( (((unsigned __int8)v14 ^ 1) & 1) != 0 )
*(_DWORD *)(v12 + 1140) = v17;
else
*(_DWORD *)(v12 + 1144) = v17;
++v14;
std::string::~string((int)&v22);
}
while ( v14 != v20 );
(*(void (__fastcall **)(unsigned __int8 *, int, int))(*(_DWORD *)v12 + 696))(&v22, v12, a2);
if ( (v22 & 1) != 0 )
{
v18 = v25;
v19 = v24;
}
else
{
v19 = (int)v22 >> 1;
v18 = v23;
}
std::string::append(this, v18, v19);
std::string::append(this, ";");
if ( !*(_BYTE *)(a2 + 11710) )
*(_BYTE *)(a2 + 11710) = *(_BYTE *)(v12 + 1095);
std::string::~string((int)&v22);
}
}
}
}
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::~__hash_table((int)v26);
return this;
}