//
// LevelEditorLayer::updateLevelSaveInfo from 0x1403ff620 to 0x1403ffaf6 (1238 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::saveLevel @ 0x1403ff494
// > LevelEditorLayer::prepareSaveData @ 0x140408fd8
// > ??> @ 0x14092597c
//
// This function is hookable on this platform (idp: pc, 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 11:31:54 +0000
//
// Hidden C++ exception states: #wind=2
void __fastcall LevelEditorLayer::updateLevelSaveInfo(__int64 a1)
{
__int64 v2; // r15
double LastObjectX; // xmm0_8
__int64 v4; // rdi
__int64 v5; // rdx
char v6; // bl
int v7; // esi
__int64 v8; // rdi
const struct cocos2d::CCPoint *v9; // rax
int v10; // eax
double v11; // xmm0_8
int v12; // eax
int v13; // eax
int v14; // ecx
int v15; // ebx
float v16; // xmm0_4
const struct cocos2d::CCPoint *v17; // rax
__int64 v18; // rax
char v19; // r8
int v20; // ebx
unsigned __int64 v21; // rdi
int v22; // ecx
_BYTE *v23; // rax
size_t v24; // rdi
size_t v25; // r8
void **v26; // rdx
__int64 i; // rbx
__int64 v28; // rsi
_BYTE *v29; // rax
void **v30; // rdx
__int64 v31; // rax
_QWORD *SongIDs; // rax
_QWORD *SFXIDs; // rax
bool v34; // [rsp+50h] [rbp-B0h] BYREF
_QWORD v35[2]; // [rsp+60h] [rbp-A0h] BYREF
void *Src[2]; // [rsp+70h] [rbp-90h] BYREF
size_t Size; // [rsp+80h] [rbp-80h]
unsigned __int64 v38; // [rsp+88h] [rbp-78h]
void *v39[2]; // [rsp+90h] [rbp-70h] BYREF
size_t v40; // [rsp+A0h] [rbp-60h]
unsigned __int64 v41; // [rsp+A8h] [rbp-58h]
void **v42; // [rsp+B0h] [rbp-50h] BYREF
__int64 v43; // [rsp+B8h] [rbp-48h]
_BYTE v44[528]; // [rsp+D0h] [rbp-30h] BYREF
v2 = *(_QWORD *)(a1 + 2168);
*(_BYTE *)(v2 + 1072) = *(_BYTE *)(*(_QWORD *)(a1 + 3528) + 340LL);
LastObjectX = LevelEditorLayer::getLastObjectX(a1);
v4 = *(_QWORD *)(a1 + 14944);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v35, *(float *)&LastObjectX + 340.0, 0.0);
v5 = *(_QWORD *)(*(_QWORD *)(v4 + 520) + 3528LL);
v6 = *(_BYTE *)(v5 + 341);
v7 = *(_DWORD *)(v5 + 332);
v8 = *(_QWORD *)(v4 + 592);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v42, v9);
v11 = LevelTools::timeForPos(v10, v8, v7, 0, 0, 0, v6, 0, 0, 0);
v12 = *(_DWORD *)(v2 + 1336);
if ( v12 > 0 )
LODWORD(v11) = fmaxf((float)v12 / 240.0, *(float *)&v11);
if ( *(_BYTE *)(*(_QWORD *)(a1 + 3528) + 341LL) )
{
v13 = 5;
}
else
{
v14 = (int)*(float *)&v11;
if ( (int)*(float *)&v11 >= 10 )
{
if ( v14 >= 30 )
{
if ( v14 >= 60 )
v13 = (v14 >= 120) + 3;
else
v13 = 2;
}
else
{
v13 = 1;
}
}
else
{
v13 = 0;
}
}
*(_DWORD *)(v2 + 972) = v13;
v15 = *(_DWORD *)(a1 + 14928) - *(_DWORD *)(a1 + 14932);
*(_DWORD *)(v2 + 700) = v15;
v16 = (float)((float)rand() / 32767.0) * 1000.0;
*(_DWORD *)(v2 + 696) = (int)v16;
*(_DWORD *)(v2 + 692) = v15 + (int)v16;
*(_DWORD *)(v2 + 1036) = *(_DWORD *)(a1 + 14812) - *(_DWORD *)(a1 + 14816);
*(_BYTE *)(v2 + 840) = *(_BYTE *)(a1 + 14674);
if ( v15 <= 40000 )
{
*(_BYTE *)(v2 + 1296) = 0;
LABEL_15:
*(_BYTE *)(v2 + 1297) = 0;
goto LABEL_16;
}
if ( v15 <= 80000 )
goto LABEL_15;
LABEL_16:
v17 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 4296) + 200LL))(*(_QWORD *)(a1 + 4296));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v42, v17);
cocos2d::CCPoint::operator=(v2 + 1196, v18);
*(float *)(v2 + 1204) = (*(float (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 4296) + 168LL))(*(_QWORD *)(a1 + 4296));
fmt::BasicWriter::BasicWriter(v44);
v19 = 1;
v20 = 0;
v21 = 0;
do
{
v22 = *(_DWORD *)(*(_QWORD *)(a1 + 15208) + 4 * (v21 >> 5));
if ( _bittest(&v22, v21 & 0x1F) )
{
if ( !v19 )
{
v42 = (void **)byte_14070ECF8;
v43 = 0;
fmt::BasicWriter::operator<<(v44, &v42);
}
fmt::BasicWriter::operator<<(v44, (unsigned int)v20);
v19 = 0;
}
++v20;
++v21;
}
while ( v20 <= 9999 );
v23 = (_BYTE *)fmt::BasicWriter::c_str(v44);
*(_OWORD *)Src = 0;
Size = 0;
v38 = 0;
v24 = -1;
v25 = -1;
do
++v25;
while ( v23[v25] );
sub_14003D230(Src, v23, v25);
fmt::BasicWriter::~BasicWriter(v44);
v42 = Src;
if ( (void **)(v2 + 576) != Src )
{
v26 = Src;
if ( v38 > 0xF )
v26 = (void **)Src[0];
sub_1400405A0((void **)(v2 + 576), v26, Size);
}
sub_14003D310((__int64)Src);
fmt::BasicWriter::BasicWriter(v44);
for ( i = 0; i < 10; ++i )
{
v28 = *(_QWORD *)(a1 + 15248);
if ( i )
{
v42 = (void **)byte_14070ECF8;
v43 = 0;
fmt::BasicWriter::operator<<(v44, &v42);
}
fmt::BasicWriter::operator<<(v44, (unsigned int)(int)*(float *)(v28 + 8 * i));
v35[0] = byte_14070ECF8;
v35[1] = 0;
fmt::BasicWriter::operator<<(v44, v35);
fmt::BasicWriter::operator<<(v44, (unsigned int)(int)*(float *)(v28 + 8 * i + 4));
}
v29 = (_BYTE *)fmt::BasicWriter::c_str(v44);
*(_OWORD *)v39 = 0;
v40 = 0;
v41 = 0;
do
++v24;
while ( v29[v24] );
sub_14003D230(v39, v29, v24);
fmt::BasicWriter::~BasicWriter(v44);
v42 = v39;
if ( (void **)(v2 + 608) != v39 )
{
v30 = v39;
if ( v41 > 0xF )
v30 = (void **)v39[0];
sub_1400405A0((void **)(v2 + 608), v30, v40);
}
sub_14003D310((__int64)v39);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v42, (const struct cocos2d::CCPoint *)(a1 + 15272));
cocos2d::CCPoint::operator=(v2 + 640, v31);
v34 = 0;
SongIDs = LevelEditorLayer::getSongIDs(a1, &v42, &v34);
sub_140059C40(v2 + 1344, (__int64)SongIDs);
sub_14003D310((__int64)&v42);
SFXIDs = LevelEditorLayer::getSFXIDs(a1, &v42);
sub_140059C40(v2 + 1376, (__int64)SFXIDs);
sub_14003D310((__int64)&v42);
if ( !*(_QWORD *)(v2 + 1392) && !v34 )
sub_1400405A0((void **)(v2 + 1344), &byte_1406ED6E0, 0);
}