//
// PlayerObject::tryPlaceCheckpoint from 0x1403a32d0 to 0x1403a383c (1388 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::update @ 0x140238b01
// > GJBaseGameLayer::update @ 0x140238b5a
// > ??> @ 0x1406d6998
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=14
void PlayerObject::tryPlaceCheckpoint(PlayerObject *a1)
{
GameManager *v2; // rcx
PlayLayer *m_playLayer; // rax
__int64 v4; // rax
__int64 v5; // rdi
struct cocos2d::CCObject *v6; // rdi
__int64 v7; // rax
int v8; // ecx
int v9; // edi
__int64 v10; // rcx
__int64 v11; // rax
__int64 v12; // rdi
struct cocos2d::CCObject *Object; // rdi
__int64 v14; // rax
int v15; // edi
__int64 v16; // rax
__int64 v17; // rbp
struct cocos2d::CCObject *v18; // rbp
int v19; // eax
CheckpointObject *Checkpoint; // rax
CheckpointObject *m_pendingCheckpoint; // rdx
PlayLayer *v22; // rcx
void *v23; // [rsp+20h] [rbp-28h]
void *v24; // [rsp+20h] [rbp-28h]
void *v25; // [rsp+20h] [rbp-28h]
void *v26; // [rsp+20h] [rbp-28h]
void *v27; // [rsp+20h] [rbp-28h]
void *v28; // [rsp+20h] [rbp-28h]
void *v29; // [rsp+20h] [rbp-28h]
void *v30; // [rsp+20h] [rbp-28h]
void *v31; // [rsp+20h] [rbp-28h]
void *v32; // [rsp+20h] [rbp-28h]
struct __timeb64 Time; // [rsp+28h] [rbp-20h] BYREF
v2 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v23 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v2 = (GameManager *)qword_1406C2ED8;
}
m_playLayer = v2->m_playLayer;
if ( m_playLayer && m_playLayer->m_isPracticeMode && GameManager::getGameVariable(v2, "0027") && a1->m_uniqueID == 1 )
{
if ( a1->m_isShip || a1->m_isBird || a1->m_isDart || a1->m_isSwing )
{
if ( a1->m_isPlatformer )
{
v11 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v26 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v26);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v11 = qword_1406C2ED8;
}
v12 = *(_QWORD *)(v11 + 520);
if ( !cocos2d::CCArray::count(*(cocos2d::CCArray **)(v12 + 14472)) )
goto LABEL_32;
Object = cocos2d::CCArray::lastObject(*(cocos2d::CCArray **)(v12 + 14472));
if ( !Object )
goto LABEL_32;
v14 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v27 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v27);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v14 = qword_1406C2ED8;
}
if ( *(_DWORD *)(*(_QWORD *)(v14 + 520) + 1000LL) - Object[83].m_uOrderOfArrival > 500 )
{
LABEL_32:
a1->m_checkpointTimeout = 1;
ftime64(&Time);
a1->m_lastCheckpointTime = (double)(Time.millitm + 1000 * (Time.time & 0xFFFFF)) / 1000.0;
v10 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
LABEL_33:
v28 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v28);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v10 = qword_1406C2ED8;
}
LABEL_34:
PlayLayer::markCheckpoint(*(PlayLayer **)(v10 + 520));
}
}
else
{
v15 = 500;
if ( a1->m_pendingCheckpoint )
goto LABEL_49;
v16 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v29 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v29);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v16 = qword_1406C2ED8;
}
v17 = *(_QWORD *)(v16 + 520);
if ( !cocos2d::CCArray::count(*(cocos2d::CCArray **)(v17 + 14472)) )
goto LABEL_45;
v18 = cocos2d::CCArray::lastObject(*(cocos2d::CCArray **)(v17 + 14472));
if ( !v18 )
goto LABEL_45;
if ( !qword_1406C2ED8 )
{
v30 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v30);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
v19 = 500;
if ( a1->m_quickCheckpointMode )
v19 = 100;
if ( *(_DWORD *)(*(_QWORD *)(qword_1406C2ED8 + 520) + 1000LL) - v18[83].m_uOrderOfArrival > v19 )
{
LABEL_45:
if ( !qword_1406C2ED8 )
{
v31 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
Checkpoint = PlayLayer::createCheckpoint(*(PlayLayer **)(qword_1406C2ED8 + 520));
a1->m_pendingCheckpoint = Checkpoint;
cocos2d::CCObject::retain(Checkpoint);
}
if ( a1->m_pendingCheckpoint )
{
LABEL_49:
if ( !qword_1406C2ED8 )
{
v32 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v32);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
}
m_pendingCheckpoint = a1->m_pendingCheckpoint;
v22 = *(PlayLayer **)(qword_1406C2ED8 + 520);
if ( a1->m_quickCheckpointMode )
v15 = 100;
if ( (signed int)(v22->m_gameState.m_currentProgress - m_pendingCheckpoint->m_commandIndex) > v15 )
{
PlayLayer::storeCheckpoint(v22, m_pendingCheckpoint);
cocos2d::CCObject::release(a1->m_pendingCheckpoint);
a1->m_pendingCheckpoint = nullptr;
}
}
}
}
else if ( a1->m_shouldTryPlacingCheckpoint || a1->m_canPlaceCheckpoint )
{
a1->m_shouldTryPlacingCheckpoint = 0;
v4 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v24 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v24);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v4 = qword_1406C2ED8;
}
v5 = *(_QWORD *)(v4 + 520);
if ( !cocos2d::CCArray::count(*(cocos2d::CCArray **)(v5 + 14472)) )
goto LABEL_22;
v6 = cocos2d::CCArray::lastObject(*(cocos2d::CCArray **)(v5 + 14472));
if ( !v6 )
goto LABEL_22;
v7 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v25 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v25);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v7 = qword_1406C2ED8;
}
v8 = *(_DWORD *)(*(_QWORD *)(v7 + 520) + 1000LL) - v6[83].m_uOrderOfArrival;
v9 = 500;
if ( a1->m_quickCheckpointMode )
v9 = 100;
if ( v8 > v9 )
{
LABEL_22:
a1->m_checkpointTimeout = 1;
ftime64(&Time);
a1->m_lastCheckpointTime = (double)(Time.millitm + 1000 * (Time.time & 0xFFFFF)) / 1000.0;
v10 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
goto LABEL_33;
goto LABEL_34;
}
}
}
}