//
// PlayLayer::loadPersistentCheckpoint from 0x1405182b0 to 0x140518725 (1141 bytes)
//
// 3 xrefs:
// > EditLevelLayer::playStep3 @ 0x14017b5ba
// > LevelInfoLayer::loadLevelStep @ 0x140422544
// > ??> @ 0x14092add0
//
// 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:33:34 +0000
//
// Hidden C++ exception states: #wind=4
void __fastcall PlayLayer::loadPersistentCheckpoint(__int64 a1, __int64 a2)
{
__int64 v4; // rax
__int64 v5; // r14
int v6; // ebp
cocos2d::CCSprite *v7; // rax
__int64 v8; // rdi
__int64 v9; // rbx
__int64 v10; // rax
cocos2d::CCObject *v11; // rcx
cocos2d::CCObject *v12; // rcx
__int64 v13; // rdi
_QWORD *v14; // r12
_QWORD *v15; // rbx
_QWORD *v16; // r13
__int64 v17; // rdi
int v18; // edx
cocos2d::CCString *v19; // rax
const char *CString; // rax
__int64 v21; // rdx
void *v22; // rax
__int64 v23; // rbx
_QWORD *v24; // rax
unsigned __int64 v25; // r8
__int64 v26; // r9
unsigned __int64 v27; // r10
__int64 v28; // rcx
int v29; // eax
int v30; // edx
void *v31; // [rsp+20h] [rbp-B8h] BYREF
_BYTE v32[16]; // [rsp+28h] [rbp-B0h] BYREF
_BYTE v33[32]; // [rsp+38h] [rbp-A0h] BYREF
_BYTE v34[32]; // [rsp+58h] [rbp-80h] BYREF
_BYTE v35[32]; // [rsp+78h] [rbp-60h] BYREF
v31 = operator new(0x1350u);
v4 = CheckpointObject::CheckpointObject(v31);
v5 = v4;
v6 = 0;
if ( v4 )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v4 + 72LL))(v4) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v5);
}
else
{
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v5 + 8LL))(v5, 1);
v5 = 0;
}
}
cocos2d::ZipUtils::decompressString(v35, a2, 0, 11);
deserializeCheckpoint(v5, v35, a1);
v31 = operator new(0x550u);
v7 = (cocos2d::CCSprite *)GameObject::GameObject((__int64)v31);
v8 = (__int64)v7;
if ( v7 )
{
*((_DWORD *)v7 + 7) = 13;
if ( cocos2d::CCSprite::initWithSpriteFrameName(v7, "checkpoint_01_001.png") )
{
GameObject::commonSetup(v8);
*(_BYTE *)(v8 + 313) = 1;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v8);
}
else
{
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v8 + 8LL))(v8, 1);
v8 = 0;
}
}
*(_DWORD *)(v8 + 1036) = 44;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v8 + 1112LL))(v8);
v9 = *(_QWORD *)v8;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v31, (const struct cocos2d::CCPoint *)(*(_QWORD *)(v5 + 3688) + 320LL));
(*(void (__fastcall **)(__int64, __int64))(v9 + 1216))(v8, v10);
if ( *(_QWORD *)(v5 + 3680) != v8 )
{
cocos2d::CCObject::retain((cocos2d::CCObject *)v8);
v11 = *(cocos2d::CCObject **)(v5 + 3680);
if ( v11 )
cocos2d::CCObject::release(v11);
*(_QWORD *)(v5 + 3680) = v8;
}
PlayLayer::storeCheckpoint(a1, (struct cocos2d::CCObject *)v5);
if ( *(_QWORD *)(a1 + 14832) != v5 )
{
cocos2d::CCObject::retain((cocos2d::CCObject *)v5);
v12 = *(cocos2d::CCObject **)(a1 + 14832);
if ( v12 )
cocos2d::CCObject::release(v12);
*(_QWORD *)(a1 + 14832) = v5;
}
*(_BYTE *)(v8 + 774) = 1;
*(_BYTE *)(v8 + 1007) = 1;
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)(v8 + 320) + 40LL))(v8 + 320, 0);
v13 = *(_QWORD *)(a1 + 2408);
sub_140069360((_QWORD *)(v13 + 880), (_QWORD *)(v5 + 4752));
sub_140373340((_QWORD *)(v13 + 944), (_QWORD *)(v5 + 4816));
GJEffectManager::transferPersistentItems(v13);
v14 = *(_QWORD **)(v5 + 4888);
v15 = (_QWORD *)*v14;
if ( (_QWORD *)*v14 != v14 )
{
v16 = (_QWORD *)(v13 + 1144);
do
{
v17 = *(_QWORD *)sub_140370710(v16, (__int64)v32, (unsigned __int8 *)v15 + 16);
*(_DWORD *)(v17 + 24) = *((_DWORD *)v15 + 6);
*(_QWORD *)(v17 + 32) = v15[4];
*(_BYTE *)(v17 + 40) = *((_BYTE *)v15 + 40);
*(_DWORD *)(v17 + 44) = *((_DWORD *)v15 + 11);
*(_BYTE *)(v17 + 48) = *((_BYTE *)v15 + 48);
*(_QWORD *)(v17 + 56) = v15[7];
*(_BYTE *)(v17 + 64) = *((_BYTE *)v15 + 64);
*(_DWORD *)(v17 + 68) = *((_DWORD *)v15 + 17);
*(_DWORD *)(v17 + 72) = *((_DWORD *)v15 + 18);
*(_DWORD *)(v17 + 76) = *((_DWORD *)v15 + 19);
sub_140099FC0((void **)(v17 + 80), (char **)v15 + 10);
*(_BYTE *)(v17 + 104) = *((_BYTE *)v15 + 104);
v15 = (_QWORD *)*v15;
}
while ( v15 != v14 );
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)a1 + 1456LL))(a1);
*(_BYTE *)(a1 + 13099) = 1;
v18 = *(_DWORD *)(v5 + 4700);
if ( v18 > 0 )
{
*(_DWORD *)(a1 + 12644) = v18;
*(_QWORD *)(a1 + 15384) = *(_QWORD *)(v5 + 4704);
*(_QWORD *)(a1 + 15392) = *(_QWORD *)(v5 + 4712);
*(_DWORD *)(a1 + 12640) = *(_DWORD *)(v5 + 4720);
*(_QWORD *)(a1 + 13920) = *(_QWORD *)(v5 + 4728);
*(_DWORD *)(a1 + 13928) = *(_DWORD *)(v5 + 4736);
*(_DWORD *)(a1 + 13932) = *(_DWORD *)(v5 + 4740);
*(_DWORD *)(a1 + 15304) = *(_DWORD *)(v5 + 4744);
v19 = cocos2d::CCString::createWithFormat("Attempt %i", v18);
CString = cocos2d::CCString::getCString(v19);
(**(void (__fastcall ***)(__int64, const char *))(*(_QWORD *)(a1 + 14984) + 360LL))(
*(_QWORD *)(a1 + 14984) + 360LL,
CString);
}
v21 = *(_QWORD *)(a1 + 2168);
if ( *(_QWORD *)(v21 + 1680) )
{
v22 = (void *)cocos2d::ZipUtils::decompressString(v33, v21 + 1664, 0, 11);
v23 = (__int64)v22;
v31 = v22;
if ( *(_BYTE *)(a1 + 13224) )
{
v24 = (_QWORD *)sub_14003F4F0((__int64)v34, (__int64)v22);
sub_140342F20(a1, v24);
v25 = 0;
v26 = *(_QWORD *)(a1 + 13336);
v27 = (*(_QWORD *)(a1 + 13344) - v26) >> 4;
if ( v27 )
{
v28 = 0;
while ( 1 )
{
v29 = *(_DWORD *)(v26 + v28);
if ( v29 == 98 || v29 == 99 )
v30 = *(_DWORD *)(v26 + v28 + 8);
else
v30 = v6 + *(_DWORD *)(v26 + v28 + 8);
if ( v30 > *(_DWORD *)(a1 + 1004) )
break;
v6 = v30;
++v25;
v28 += 16;
if ( v25 >= v27 )
goto LABEL_34;
}
sub_140353F50((const void **)(a1 + 13336), v25);
}
LABEL_34:
*(_DWORD *)(a1 + 13568) = (__int64)(*(_QWORD *)(a1 + 13344) - *(_QWORD *)(a1 + 13336)) >> 4;
*(_DWORD *)(a1 + 13308) = v6;
}
sub_14003D310(v23);
}
*(_BYTE *)(a1 + 14829) = 1;
sub_14003D310((__int64)v35);
}