//
// GManager::save from 0x1004a5110 to 0x1004a51f8 (232 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::saveLevel @ 0x1000c6456
// > GameManager::doQuickSave @ 0x100376475
// > AppDelegate::trySaveGame @ 0x10073bd04
// > AppDelegate::trySaveGame @ 0x10073bd23
//
// 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:30:54 +0000
//
__int64 __fastcall GManager::save(__int64 a1, int a2)
{
std::chrono::duration>::rep rep; // r15
std::chrono::nanoseconds __ns; // [rsp+8h] [rbp-48h] BYREF
__int128 v5; // [rsp+10h] [rbp-40h] BYREF
void *__p; // [rsp+20h] [rbp-30h]
if ( !a2 )
{
rep = std::chrono::steady_clock::now().__d_.__rep_;
do
{
if ( (*(_BYTE *)(a1 + 345) & 1) == 0 )
break;
__ns.__rep_ = 10000000;
std::this_thread::sleep_for(&__ns);
}
while ( std::chrono::steady_clock::now().__d_.__rep_ - rep < 0x6FC23AC01LL );
}
LOBYTE(rep) = *(_BYTE *)(a1 + 345);
*(_BYTE *)(a1 + 345) = 1;
if ( (rep & 1) == 0 )
{
if ( (*(_BYTE *)(a1 + 320) & 1) != 0 )
{
sub_10001AD30(&v5, *(const void **)(a1 + 336), *(_QWORD *)(a1 + 328));
}
else
{
__p = *(void **)(a1 + 336);
v5 = *(_OWORD *)(a1 + 320);
}
sub_1004A52A0(a1, &v5, (unsigned __int8)a2);
if ( (v5 & 1) != 0 )
operator delete(__p);
}
LOBYTE(rep) = (rep & 1) == 0;
return (unsigned int)rep;
}