//
// PlayLayer::createCheckpoint from 0x1405141a0 to 0x14051476a (1482 bytes)
//
// 4 xrefs:
// > PlayerObject::tryPlaceCheckpoint @ 0x140501da3
// > PlayLayer::markCheckpoint @ 0x140516656
// > PlayLayer::startMusic @ 0x14051b069
// > ??> @ 0x14092aca4
//
// 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:32 +0000
//
// Hidden C++ exception states: #wind=5
__int64 __fastcall PlayLayer::createCheckpoint(__int64 a1)
{
__int64 v2; // rax
__int64 v3; // rsi
__int64 v4; // rax
cocos2d::CCObject *v5; // rbx
cocos2d::CCObject *v6; // rcx
__int64 v7; // rax
cocos2d::CCObject *v8; // rbx
cocos2d::CCObject *v9; // rcx
__int64 v10; // rdx
_QWORD *v11; // rcx
__int64 *v12; // r15
__int64 *i; // r14
__int64 v14; // rcx
_QWORD *v15; // rdi
__int64 v16; // rbx
__int64 v17; // rax
const void **v18; // r15
struct cocos2d::CCObject *Object; // rax
unsigned __int64 v20; // r14
__int64 v21; // rdi
_QWORD *v22; // rbx
cocos2d::CCArray *v23; // rdi
__int64 v24; // rcx
__int64 v25; // rcx
__int64 j; // rbx
_QWORD *v27; // rcx
struct cocos2d::CCObject *v28; // r14
__int64 v29; // rcx
cocos2d::CCObject *v30; // rcx
cocos2d::CCSprite *v31; // rax
__int64 v32; // rdi
float v33; // xmm1_4
__int64 v34; // rbx
const struct cocos2d::CCPoint *v35; // rax
__int64 v36; // rax
cocos2d::CCObject *v37; // rcx
char v39[16]; // [rsp+20h] [rbp-378h] BYREF
_BYTE v40[832]; // [rsp+30h] [rbp-368h] BYREF
void *v41; // [rsp+3A0h] [rbp+8h] BYREF
v41 = operator new(0x1350u);
v2 = CheckpointObject::CheckpointObject(v41);
v3 = v2;
if ( v2 )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v2 + 72LL))(v2) )
{
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v3);
}
else
{
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v3 + 8LL))(v3, 1);
v3 = 0;
}
}
v41 = operator new(0x568u);
v4 = PlayerCheckpoint::PlayerCheckpoint(v41);
v5 = (cocos2d::CCObject *)v4;
if ( v4 )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v4 + 72LL))(v4) )
{
cocos2d::CCObject::autorelease(v5);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v5 + 8LL))(v5, 1);
v5 = nullptr;
}
}
if ( *(cocos2d::CCObject **)(v3 + 3688) != v5 )
{
if ( v5 )
cocos2d::CCObject::retain(v5);
v6 = *(cocos2d::CCObject **)(v3 + 3688);
if ( v6 )
cocos2d::CCObject::release(v6);
*(_QWORD *)(v3 + 3688) = v5;
}
PlayerObject::saveToCheckpoint(*(_QWORD *)(a1 + 3512), (__int64)v5);
if ( *(_BYTE *)(a1 + 1058) )
{
v41 = operator new(0x568u);
v7 = PlayerCheckpoint::PlayerCheckpoint(v41);
v8 = (cocos2d::CCObject *)v7;
if ( v7 )
{
if ( (*(unsigned __int8 (__fastcall **)(__int64))(*(_QWORD *)v7 + 72LL))(v7) )
{
cocos2d::CCObject::autorelease(v8);
}
else
{
(*(void (__fastcall **)(cocos2d::CCObject *, __int64))(*(_QWORD *)v8 + 8LL))(v8, 1);
v8 = nullptr;
}
}
if ( *(cocos2d::CCObject **)(v3 + 3696) != v8 )
{
if ( v8 )
cocos2d::CCObject::retain(v8);
v9 = *(cocos2d::CCObject **)(v3 + 3696);
if ( v9 )
cocos2d::CCObject::release(v9);
*(_QWORD *)(v3 + 3696) = v8;
}
PlayerObject::saveToCheckpoint(*(_QWORD *)(a1 + 3520), (__int64)v8);
}
sub_140514770(v3 + 320, a1 + 424);
*(_DWORD *)(v3 + 4696) = *(_DWORD *)(a1 + 992);
v10 = *(_QWORD *)(a1 + 12896);
if ( v10 )
sub_140515650(v3 + 2064, v10 + 408);
v11 = (_QWORD *)qword_14090BF60;
if ( !qword_14090BF60 )
{
v41 = operator new(0x8A8u);
qword_14090BF60 = FMODAudioEngine::FMODAudioEngine((__int64)v41);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BF60 + 72LL))(qword_14090BF60);
v11 = (_QWORD *)qword_14090BF60;
}
FMODAudioEngine::saveAudioState(v11, v3 + 2784);
v12 = *(__int64 **)(a1 + 13008);
for ( i = *(__int64 **)(a1 + 13000); i != v12; ++i )
{
v14 = *i;
LODWORD(v41) = *(_DWORD *)(*i + 924);
v15 = (_QWORD *)(v14 + 1880);
v16 = *(_QWORD *)sub_14051BC90(v3 + 4632, v39, &v41);
sub_140069360((_QWORD *)(v16 + 24), v15);
sub_140069360((_QWORD *)(v16 + 88), v15 + 8);
}
*(_BYTE *)(v3 + 3704) = *(_BYTE *)(*(_QWORD *)(a1 + 4344) + 457LL) == 0;
memset(v40, 0, sizeof(v40));
v17 = EffectManagerState::EffectManagerState((__int64)v40);
v18 = (const void **)(v3 + 3792);
sub_140515E30(v3 + 3792, v17);
sub_1405034F0((__int64)v40);
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 14904)) )
{
Object = cocos2d::CCArray::lastObject(*(cocos2d::CCArray **)(a1 + 14904));
if ( Object )
{
v20 = (*((_QWORD *)Object + 475) - *((_QWORD *)Object + 474)) / 68LL;
if ( v20 > (*(_QWORD *)(v3 + 3808) - *(_QWORD *)(v3 + 3792)) / 68LL )
{
if ( v20 > 0x3C3C3C3C3C3C3C3LL )
sub_14005A170();
v21 = (*(_QWORD *)(v3 + 3800) - (_QWORD)*v18) / 68LL;
v22 = sub_14003D460(68 * v20);
memmove(v22, *v18, *(_QWORD *)(v3 + 3800) - (_QWORD)*v18);
sub_140378E30(v3 + 3792, (__int64)v22, v21, v20);
}
}
}
GJEffectManager::saveToState(*(_QWORD *)(a1 + 2408), (__int64 *)(v3 + 3792));
v23 = nullptr;
v24 = *(_QWORD *)(a1 + 12880);
if ( v24 )
{
v25 = *(_QWORD *)(v24 + 56);
if ( v25 )
{
for ( j = *(_QWORD *)(v25 + 288); ; j = *(_QWORD *)(j + 288) )
{
v27 = *(_QWORD **)(v25 + 264);
v28 = (struct cocos2d::CCObject *)v27[73];
if ( (*(__int64 (__fastcall **)(_QWORD *))(*v27 + 504LL))(v27) && v28 )
{
if ( !v23 )
v23 = (cocos2d::CCArray *)cocos2d::CCArray::create(v29);
cocos2d::CCArray::addObject(v23, v28);
}
v25 = j;
if ( !j )
break;
}
if ( v23 && *(cocos2d::CCArray **)(v3 + 4624) != v23 )
{
cocos2d::CCObject::retain(v23);
v30 = *(cocos2d::CCObject **)(v3 + 4624);
if ( v30 )
cocos2d::CCObject::release(v30);
*(_QWORD *)(v3 + 4624) = v23;
}
}
}
v41 = operator new(0x550u);
v31 = (cocos2d::CCSprite *)GameObject::GameObject((__int64)v41);
v32 = (__int64)v31;
if ( v31 )
{
*((_DWORD *)v31 + 7) = 13;
if ( cocos2d::CCSprite::initWithSpriteFrameName(v31, "checkpoint_01_001.png") )
{
GameObject::commonSetup(v32);
*(_BYTE *)(v32 + 313) = 1;
cocos2d::CCObject::autorelease((cocos2d::CCObject *)v32);
}
else
{
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v32 + 8LL))(v32, 1);
v32 = 0;
}
}
*(_DWORD *)(v32 + 1036) = 44;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v32 + 1112LL))(v32);
v33 = *(float *)(a1 + 1052);
if ( v33 == 0.0 || v33 == 1.0 )
{
v34 = *(_QWORD *)v32;
v35 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 3512) + 200LL))(*(_QWORD *)(a1 + 3512));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v41, v35);
(*(void (__fastcall **)(__int64, __int64))(v34 + 1216))(v32, v36);
}
else
{
cocos2d::CCPoint::CCPoint(
(cocos2d::CCPoint *)&v41,
(const struct cocos2d::CCPoint *)(*(_QWORD *)(a1 + 3512) + 2712LL));
(*(void (__fastcall **)(__int64, void **))(*(_QWORD *)v32 + 1216LL))(v32, &v41);
}
if ( *(_QWORD *)(v3 + 3680) != v32 )
{
cocos2d::CCObject::retain((cocos2d::CCObject *)v32);
v37 = *(cocos2d::CCObject **)(v3 + 3680);
if ( v37 )
cocos2d::CCObject::release(v37);
*(_QWORD *)(v3 + 3680) = v32;
}
PlayLayer::saveDynamicSaveObjects(a1, v3 + 3720);
PlayLayer::saveActiveSaveObjects(a1, v3 + 3744, v3 + 3768);
return v3;
}