//
// GameLevelManager::writePlatformerSaveJournal from 0x83cce4 to 0x83d08c (936 bytes)
//
// 2 xrefs:
// > PlayLayer::onQuit @ 0x7036a4
// > ??> @ 0x5a5e0
//
// 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:55:14 +0000
//
__int64 __fastcall GameLevelManager::writePlatformerSaveJournal(GameLevelManager *this, GJGameLevel *a2)
{
int v3; // w21
std::mutex *v6; // x27
DS_Dictionary *v7; // x23
char *v8; // x0
char *v9; // x2
const char *v10; // x1
const char *v11; // x1
int v12; // w0
char *v13; // x0
char *v14; // x2
void *v15[2]; // [xsp+68h] [xbp+68h] BYREF
void *v16; // [xsp+78h] [xbp+78h]
__int64 v17[2]; // [xsp+80h] [xbp+80h] BYREF
void *v18; // [xsp+90h] [xbp+90h]
if ( a2 )
{
v3 = *((_DWORD *)a2 + 285);
if ( (v3 != 3) <= (unsigned int)(v3 == 2) && (v3 == 2 || *((_DWORD *)a2 + 82) - *((_DWORD *)a2 + 83) > 0) )
{
if ( (*((_BYTE *)a2 + 1472) & 1) != 0 ? *((_QWORD *)a2 + 185) : *((_BYTE *)a2 + 1472) >> 1 )
{
v6 = (std::mutex *)qword_155C990;
std::mutex::lock((std::mutex *)qword_155C990);
v7 = (DS_Dictionary *)operator new(0xF0u);
DS_Dictionary::DS_Dictionary(v7);
if ( !(unsigned __int8)sub_82FA7C((__int64)v7) )
{
v8 = *((char **)v7 + 26);
if ( v8 )
{
v9 = *((char **)v7 + 27);
if ( v8 != v9 )
*((_QWORD *)v7 + 27) = &v9[8 * ~((unsigned __int64)(v9 - 8 - v8) >> 3)];
operator delete(v8);
}
pugi::xml_document::~xml_document(v7);
operator delete(v7);
v7 = (DS_Dictionary *)operator new(0xF0u);
DS_Dictionary::DS_Dictionary(v7);
}
sub_83C2D4((__int64)a2, v15);
v10 = (char *)v15 + 1;
if ( ((__int64)v15[0] & 1) != 0 )
v10 = (const char *)v16;
DS_Dictionary::removeKey(v7, v10);
v11 = (char *)v15 + 1;
if ( ((__int64)v15[0] & 1) != 0 )
v11 = (const char *)v16;
DS_Dictionary::setSubDictForKey(v7, v11, 0, 1);
DS_Dictionary::setIntegerForKey(v7, "t", v3);
DS_Dictionary::setIntegerForKey(v7, "id", *((_DWORD *)a2 + 82) - *((_DWORD *)a2 + 83));
DS_Dictionary::setIntegerForKey(v7, "did", *((_DWORD *)a2 + 230) - *((_DWORD *)a2 + 231));
DS_Dictionary::setBoolForKey(v7, "g", *((_BYTE *)a2 + 649));
if ( v3 == 2 )
{
GJGameLevel::generateAutoSaveUID(v17, a2);
}
else
{
v17[0] = 0;
v17[1] = 0;
v18 = nullptr;
std::string::__init(v17, &byte_11B8890, 0);
}
DS_Dictionary::setStringForKey(v7, "uid", v17);
if ( (v17[0] & 1) != 0 )
operator delete(v18);
DS_Dictionary::setStringForKey(v7, "cs", (char *)a2 + 1472);
DS_Dictionary::setIntegerForKey(v7, "cv", *((_DWORD *)a2 + 380));
DS_Dictionary::setIntegerForKey(v7, "fv", *((_DWORD *)a2 + 381));
DS_Dictionary::setStringForKey(v7, "rs", (char *)a2 + 1496);
DS_Dictionary::setBoolForKey(v7, "ps", *((_BYTE *)a2 + 1528));
DS_Dictionary::setIntegerForKey(v7, "sq", ++dword_155C998);
v12 = sub_7FE4F8((GJAccountManager *)v15);
DS_Dictionary::setIntegerForKey(v7, "ow", v12);
DS_Dictionary::stepOutOfSubDict(v7);
sub_82F964(v7);
v13 = *((char **)v7 + 26);
if ( v13 )
{
v14 = *((char **)v7 + 27);
if ( v13 != v14 )
*((_QWORD *)v7 + 27) = &v14[8 * ~((unsigned __int64)(v14 - 8 - v13) >> 3)];
operator delete(v13);
}
pugi::xml_document::~xml_document(v7);
operator delete(v7);
if ( ((__int64)v15[0] & 1) != 0 )
operator delete(v16);
std::mutex::unlock(v6);
}
}
}
return _stack_chk_guard;
}