//
// LocalLevelManager::saveFinished from 0x1006cde40 to 0x1006ce059 (537 bytes)
//
// 1 xrefs:
// > ??> @ 0x100b8f710
//
// 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 12:35:37 +0000
//
void __fastcall LocalLevelManager::saveFinished(__int64 a1, int a2)
{
__int64 v3; // rax
std::error_code *v4; // rsi
__int64 v5; // r14
__int64 i; // r15
__int64 v7; // r14
__int64 v8; // r15
const std::__fs::filesystem::path *v9; // rdi
unsigned int v10; // r12d
size_t v11; // rdx
unsigned int v12; // r15d
const void *v13; // rdi
_BYTE *v14; // r13
__int128 v15; // [rsp-68h] [rbp-68h] BYREF
std::error_code *v16; // [rsp-58h] [rbp-58h]
__int128 v17; // [rsp-48h] [rbp-48h] BYREF
std::__fs::filesystem::path *v18; // [rsp-38h] [rbp-38h]
if ( !a2 )
return;
v3 = GameLevelManager::sharedState();
v4 = (std::error_code *)(a1 + 440);
sub_10054DBF0(v3, (_QWORD *)(a1 + 440));
v5 = *(_QWORD *)(a1 + 440);
for ( i = *(_QWORD *)(a1 + 448); i != v5; i -= 32 )
{
if ( (*(_BYTE *)(i - 32) & 1) != 0 )
operator delete(*(void **)(i - 16));
}
*(_QWORD *)(a1 + 448) = v5;
v7 = *(_QWORD *)(a1 + 416);
v8 = *(_QWORD *)(a1 + 424);
if ( v7 != v8 )
{
do
{
if ( (*(_BYTE *)v7 & 1) != 0 )
v9 = *(const std::__fs::filesystem::path **)(v7 + 16);
else
v9 = (const std::__fs::filesystem::path *)(v7 + 1);
remove(v9, v4);
v7 += 24;
}
while ( v7 != v8 );
v7 = *(_QWORD *)(a1 + 416);
v8 = *(_QWORD *)(a1 + 424);
}
while ( v8 != v7 )
{
if ( (*(_BYTE *)(v8 - 24) & 1) != 0 )
operator delete(*(void **)(v8 - 8));
v8 -= 24;
}
*(_QWORD *)(a1 + 424) = v7;
std::mutex::lock((std::mutex *)(a1 + 464));
v16 = *(std::error_code **)(a1 + 568);
v15 = *(_OWORD *)(a1 + 552);
v18 = *(std::__fs::filesystem::path **)(a1 + 592);
v17 = *(_OWORD *)(a1 + 576);
*(_WORD *)(a1 + 552) = 0;
*(_WORD *)(a1 + 576) = 0;
v10 = *(unsigned __int8 *)(a1 + 528);
if ( (v10 & 1) != 0 )
{
v11 = *(_QWORD *)(a1 + 536);
v12 = (unsigned __int8)v15;
if ( (v15 & 1) == 0 )
goto LABEL_20;
}
else
{
v11 = v10 >> 1;
v12 = (unsigned __int8)v15;
if ( (v15 & 1) == 0 )
{
LABEL_20:
if ( v11 != v12 >> 1 )
goto LABEL_33;
goto LABEL_24;
}
}
if ( v11 != *((_QWORD *)&v15 + 1) )
goto LABEL_33;
LABEL_24:
v13 = (const void *)(a1 + 529);
v14 = *(_BYTE **)(a1 + 544);
if ( (v10 & 1) != 0 )
v13 = *(const void **)(a1 + 544);
if ( (v12 & 1) != 0 )
{
v4 = v16;
if ( memcmp(v13, v16, v11) )
goto LABEL_33;
}
else
{
v4 = (std::error_code *)((char *)&v15 + 1);
if ( memcmp(v13, (char *)&v15 + 1, v11) )
goto LABEL_33;
}
if ( (v10 & 1) != 0 )
{
*v14 = 0;
*(_QWORD *)(a1 + 536) = 0;
}
else
{
*(_WORD *)(a1 + 528) = 0;
}
LABEL_33:
std::mutex::unlock((std::mutex *)(a1 + 464));
if ( (v17 & 1) != 0 )
{
if ( *((_QWORD *)&v17 + 1) )
remove(v18, v4);
operator delete(v18);
if ( (v12 & 1) != 0 )
goto LABEL_37;
}
else
{
if ( (_BYTE)v17 )
remove((const std::__fs::filesystem::path *)((char *)&v17 + 1), v4);
if ( (v12 & 1) != 0 )
LABEL_37:
operator delete(v16);
}
}