//
// PlayerObject::tryPlaceCheckpoint from 0x344d44 to 0x344ed2 (398 bytes)
//
// 2 xrefs:
// > PlayerObject::updateCheckpointTest @ 0x344ee2
// > PlayerObject::updateCheckpointTest @ 0x344f0e
//
// 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
//
void PlayerObject::tryPlaceCheckpoint(PlayerObject *a1)
{
double v1; // d0
GameManager *v3; // r0
GameManager *v4; // r0
_DWORD *LastCheckpoint; // r0
float v6; // r1
int v7; // r2
_DWORD *v8; // r5
GameManager *v9; // r0
CheckpointObject *v10; // r5
signed int v11; // r3
int v12; // r2
signed int v13; // r3
int v14; // r2
GameManager *v15; // r0
GameManager *v16; // r0
_DWORD *v17; // r5
GameManager *v18; // r0
CheckpointObject *Checkpoint; // r0
GameManager *v20; // r0
if ( GameManager::sharedState()->m_playLayer )
{
if ( GameManager::sharedState()->m_playLayer->m_isPracticeMode )
{
v3 = GameManager::sharedState();
if ( GameManager::getGameVariable(v3, "0027") && a1->m_uniqueID == 1 )
{
if ( PlayerObject::isFlying(a1) )
{
if ( a1->m_isPlatformer )
{
v4 = GameManager::sharedState();
LastCheckpoint = PlayLayer::getLastCheckpoint(v4->m_playLayer);
v8 = LastCheckpoint;
if ( LastCheckpoint )
{
LastCheckpoint = GameManager::sharedState();
v7 = v8[768];
if ( *(_DWORD *)(LastCheckpoint[91] + 832) - v7 <= 500 )
return;
}
LABEL_31:
a1->m_checkpointTimeout = 1;
sub_33C0D8((int)LastCheckpoint, v6, *(float *)&v7, 1);
a1->m_lastCheckpointTime = v1;
v20 = GameManager::sharedState();
PlayLayer::markCheckpoint(v20->m_playLayer);
return;
}
if ( !a1->m_pendingCheckpoint )
{
v9 = GameManager::sharedState();
v10 = PlayLayer::getLastCheckpoint(v9->m_playLayer);
if ( !v10
|| ((v11 = GameManager::sharedState()->m_playLayer->m_gameState.m_currentProgress - v10->m_commandIndex,
!a1->m_quickCheckpointMode)
? (v12 = 500)
: (v12 = 100),
v11 > v12) )
{
v18 = GameManager::sharedState();
Checkpoint = PlayLayer::createCheckpoint(v18->m_playLayer);
a1->m_pendingCheckpoint = Checkpoint;
cocos2d::CCObject::retain(Checkpoint);
}
}
if ( a1->m_pendingCheckpoint )
{
v13 = GameManager::sharedState()->m_playLayer->m_gameState.m_currentProgress
- a1->m_pendingCheckpoint->m_commandIndex;
if ( a1->m_quickCheckpointMode )
v14 = 100;
else
v14 = 500;
if ( v13 > v14 )
{
v15 = GameManager::sharedState();
PlayLayer::storeCheckpoint(v15->m_playLayer, a1->m_pendingCheckpoint);
cocos2d::CCObject::release(a1->m_pendingCheckpoint);
a1->m_pendingCheckpoint = nullptr;
}
}
}
else if ( a1->m_shouldTryPlacingCheckpoint || a1->m_canPlaceCheckpoint )
{
a1->m_shouldTryPlacingCheckpoint = 0;
v16 = GameManager::sharedState();
LastCheckpoint = PlayLayer::getLastCheckpoint(v16->m_playLayer);
v17 = LastCheckpoint;
if ( !LastCheckpoint )
goto LABEL_31;
LastCheckpoint = GameManager::sharedState();
v7 = a1->m_quickCheckpointMode ? 100 : 500;
if ( *(_DWORD *)(LastCheckpoint[91] + 832) - v17[768] > v7 )
goto LABEL_31;
}
}
}
}
}