//
// GameLevelManager::replayPlatformerSaveJournal from 0x140223740 to 0x140223c43 (1283 bytes)
//
// 3 xrefs:
// > LoadingLayer::loadAssets @ 0x14046a234
// > ??> @ 0x14091bc98
// > ??> @ 0x14091bca4
//
// 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:28:25 +0000
//
// Hidden C++ exception states: #wind=6
int __fastcall GameLevelManager::replayPlatformerSaveJournal(__int64 a1)
{
__int64 v1; // rsi
_Mtx_t v2; // r14
DS_Dictionary *v3; // r13
const char *v4; // r12
const char *v5; // r15
const char *v6; // rdx
__int64 v7; // rcx
__int64 v8; // rax
int v9; // ebx
unsigned __int64 v10; // rdx
unsigned __int64 i; // rcx
const char *v12; // rax
int IntegerForKey; // edi
__int64 SavedLevel; // rbx
__int64 v15; // rcx
__int64 v16; // rax
cocos2d::CCArray *v17; // r15
unsigned int v18; // esi
struct cocos2d::CCObject *v19; // r14
void **v20; // rax
int v21; // edi
int v22; // edi
__int64 SavedGauntletLevel; // rax
__int64 v24; // rbx
__int64 v25; // rbx
__int64 j; // rcx
void **v27; // rdx
__int64 StringForKey; // rax
__int64 v29; // rbx
__int64 v30; // rdi
const char *v31; // rdx
DS_Dictionary *v33; // [rsp+20h] [rbp-A9h]
const char *v34; // [rsp+20h] [rbp-A9h]
_Mtx_t v36; // [rsp+30h] [rbp-99h]
__int128 v37; // [rsp+38h] [rbp-91h] BYREF
__int64 v38; // [rsp+48h] [rbp-81h]
const char *v39; // [rsp+50h] [rbp-79h] BYREF
const char *v40; // [rsp+58h] [rbp-71h]
_Mtx_t v41; // [rsp+68h] [rbp-61h]
void *Src[2]; // [rsp+70h] [rbp-59h] BYREF
size_t Size; // [rsp+80h] [rbp-49h]
unsigned __int64 v44; // [rsp+88h] [rbp-41h]
_QWORD Buf2[4]; // [rsp+90h] [rbp-39h] BYREF
void *v46[4]; // [rsp+B0h] [rbp-19h] BYREF
_QWORD Buf1[4]; // [rsp+D0h] [rbp+7h] BYREF
v1 = a1;
v2 = qword_14090A8C8;
v36 = qword_14090A8C8;
v41 = qword_14090A8C8;
if ( Mtx_lock(qword_14090A8C8) )
{
std::_Throw_Cpp_error(5);
__debugbreak();
}
if ( *((_DWORD *)v2 + 19) == 0x7FFFFFFF )
{
*((_DWORD *)v2 + 19) = 2147483646;
std::_Throw_Cpp_error(6);
}
v33 = (DS_Dictionary *)operator new(0xF0u);
v3 = DS_Dictionary::DS_Dictionary(v33);
if ( !sub_140222A60((__int64)v3) )
{
if ( v3 )
{
DS_Dictionary::~DS_Dictionary(v3);
j_j_free(v3);
}
return Mtx_unlock(v2);
}
v37 = 0;
v38 = 0;
DS_Dictionary::getAllKeys(v3, &v39);
v4 = v39;
v5 = v40;
v34 = v40;
if ( v39 == v40 )
goto LABEL_56;
do
{
v6 = v4;
if ( *((_QWORD *)v4 + 3) > 0xFu )
v6 = *(const char **)v4;
if ( DS_Dictionary::stepIntoSubDictWithKey(v3, v6) )
{
if ( dword_14090BFC0 <= DS_Dictionary::getIntegerForKey(v3, "sq") )
dword_14090BFC0 = DS_Dictionary::getIntegerForKey(v3, "sq");
v8 = GJAccountManager::sharedState(v7);
v9 = 1640531535 * (*(_DWORD *)(v8 + 364) - *(_DWORD *)(v8 + 360));
v10 = *((_QWORD *)v4 + 2);
for ( i = 0; i < v10; ++i )
{
v12 = v4;
if ( *((_QWORD *)v4 + 3) > 0xFu )
v12 = *(const char **)v4;
v9 = 16777619 * (v9 ^ (unsigned __int8)v12[i]);
}
if ( DS_Dictionary::getIntegerForKey(v3, "ow") != (v9 & 0x7FFFFFFF) )
{
DS_Dictionary::stepOutOfSubDict(v3);
sub_140075F50((__int64 *)&v37, (__int64)v4);
goto LABEL_54;
}
IntegerForKey = DS_Dictionary::getIntegerForKey(v3, "t");
DS_Dictionary::getStringForKey(v3, Src, "cs");
SavedLevel = 0;
if ( IntegerForKey == 2 )
{
DS_Dictionary::getStringForKey(v3, Buf2, "uid");
v16 = LocalLevelManager::sharedState(v15);
v17 = *(cocos2d::CCArray **)(v16 + 368);
if ( v17 && Buf2[2] )
{
v18 = 0;
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v16 + 368)) )
{
while ( 1 )
{
v19 = cocos2d::CCArray::objectAtIndex(v17, v18);
if ( !*((_QWORD *)v19 + 201) )
{
v20 = GameToolbox::gen_random(v46, 0x10u);
sub_140059C40((__int64)v19 + 1592, (__int64)v20);
sub_14003D310((__int64)v46);
}
sub_14003F4F0((__int64)Buf1, (__int64)v19 + 1592);
v21 = sub_14003D160(Buf1, Buf2);
sub_14003D310((__int64)Buf1);
if ( !v21 )
break;
if ( ++v18 >= cocos2d::CCArray::count(v17) )
goto LABEL_30;
}
SavedLevel = (__int64)v19;
}
LABEL_30:
v1 = a1;
}
sub_14003D310((__int64)Buf2);
v5 = v34;
LABEL_46:
if ( !SavedLevel )
{
LABEL_53:
DS_Dictionary::stepOutOfSubDict(v3);
sub_14003D310((__int64)Src);
goto LABEL_54;
}
LABEL_47:
if ( Size )
{
if ( (void **)(SavedLevel + 1632) != Src )
{
v27 = Src;
if ( v44 > 0xF )
v27 = (void **)Src[0];
sub_1400405A0((void **)(SavedLevel + 1632), v27, Size);
}
*(_DWORD *)(SavedLevel + 1696) = DS_Dictionary::getIntegerForKey(v3, "cv");
*(_DWORD *)(SavedLevel + 1700) = DS_Dictionary::getIntegerForKey(v3, "fv");
StringForKey = DS_Dictionary::getStringForKey(v3, v46, "rs");
sub_140059C40(SavedLevel + 1664, StringForKey);
sub_14003D310((__int64)v46);
*(_BYTE *)(SavedLevel + 1704) = DS_Dictionary::getBoolForKey(v3, "ps");
}
goto LABEL_53;
}
v22 = DS_Dictionary::getIntegerForKey(v3, "id");
if ( (int)DS_Dictionary::getIntegerForKey(v3, "did") <= 0 )
{
if ( !DS_Dictionary::getBoolForKey(v3, "g") )
{
LABEL_37:
SavedLevel = GameLevelManager::getSavedLevel(v1);
if ( SavedLevel )
goto LABEL_47;
v24 = *(_QWORD *)(v1 + 944);
if ( v24 )
{
v25 = *(_QWORD *)(v24 + 56);
if ( v25 )
{
for ( j = *(_QWORD *)(v25 + 288); ; j = *(_QWORD *)(j + 288) )
{
SavedLevel = *(_QWORD *)(v25 + 264);
if ( *(_DWORD *)(SavedLevel + 328) - *(_DWORD *)(SavedLevel + 332) == v22 )
break;
v25 = j;
if ( !j )
goto LABEL_45;
}
if ( SavedLevel )
goto LABEL_47;
}
}
LABEL_45:
SavedLevel = GameLevelManager::getSavedGauntletLevel(v1);
goto LABEL_46;
}
SavedGauntletLevel = GameLevelManager::getSavedGauntletLevel(v1);
}
else
{
SavedGauntletLevel = GameLevelManager::getSavedDailyLevel(v1);
}
SavedLevel = SavedGauntletLevel;
if ( SavedGauntletLevel )
goto LABEL_47;
goto LABEL_37;
}
LABEL_54:
v4 += 32;
}
while ( v4 != v5 );
v2 = v36;
LABEL_56:
v30 = *((_QWORD *)&v37 + 1);
v29 = v37;
if ( (_QWORD)v37 != *((_QWORD *)&v37 + 1) )
{
do
{
v31 = (const char *)v29;
if ( *(_QWORD *)(v29 + 24) > 0xFu )
v31 = *(const char **)v29;
DS_Dictionary::removeKey(v3, v31);
v29 += 32;
}
while ( v29 != v30 );
sub_140222B40((__int64)v3);
}
if ( v3 )
{
DS_Dictionary::~DS_Dictionary(v3);
j_j_free(v3);
}
sub_1400760C0((__int64 *)&v39);
sub_1400760C0((__int64 *)&v37);
return Mtx_unlock(v2);
}