//
// PlayLayer::loadFromCheckpoint from 0x100120fc8 to 0x1001213d8 (1040 bytes)
//
// 2 xrefs:
// > PlayLayer::loadLastCheckpoint @ 0x100120fac
// > PlayLayer::resetLevel @ 0x10012205c
//
// 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 __fastcall PlayLayer::loadFromCheckpoint(PlayLayer *a1, CheckpointObject *a2)
{
bool *p_m_isPlatformer; // x23
ShaderLayer *m_shaderLayer; // x8
FMODAudioEngine *v6; // x0
FMODAudioEngine *v7; // x0
FMODAudioEngine *v8; // x0
FMODAudioEngine *v9; // x0
float m_levelTime; // s0
std::__vector_base::pointer begin; // x24
std::__vector_base::pointer i; // x25
SequenceTriggerGameObject *v13; // x27
__int64 v14; // x22
PlayerCheckpoint *m_player1Checkpoint; // x1
int v16; // w21
bool v17; // w8
PlayerCheckpoint *m_player2Checkpoint; // x1
bool v19; // w8
cocos2d::CCArray *m_gradientTriggerObjectArray; // x21
__int64 v21; // x22
GradientTriggerObject *v22; // x0
PlayLayer *v23; // x0
cocos2d::CCArray *m_collectibles; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
EffectGameObject **arr; // x21
unsigned __int64 v28; // x22
EffectGameObject *v29; // x20
int j; // w20
cocos2d::CCArray *Group; // x0
cocos2d::ccArray *v32; // x9
__int64 v33; // x8
GameObject **v34; // x22
unsigned __int64 v35; // x23
GameObjectType ActiveMode; // w0
cocos2d::CCDirector *v37; // x0
int m_uniqueID; // [xsp+0h] [xbp-60h] BYREF
char v39; // [xsp+7h] [xbp-59h] BYREF
int *p_m_uniqueID; // [xsp+8h] [xbp-58h] BYREF
if ( a2 )
{
p_m_isPlatformer = &a1->m_isPlatformer;
sub_10011FE0C((__int64)&a1->m_gameState, (__int64)&a2->m_gameState);
m_shaderLayer = a1->m_shaderLayer;
if ( m_shaderLayer )
sub_1001203FC((__int64)&m_shaderLayer->m_state, (__int64)&a2->m_shaderState);
if ( !p_m_isPlatformer[290] || p_m_isPlatformer[291] )
{
if ( *p_m_isPlatformer )
{
v6 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::pauseAllMusic(v6, 0);
}
else
{
GJBaseGameLayer::pauseAudio(a1);
}
v7 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::loadAudioState(v7, &a2->m_audioState);
if ( *p_m_isPlatformer )
{
v8 = FMODAudioEngine::sharedEngine();
if ( !FMODAudioEngine::isAnyPersistentPlaying(v8) )
{
v9 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::fadeInBackgroundMusic(v9, 0.1);
}
}
m_levelTime = a1->m_gameState.m_levelTime;
GJBaseGameLayer::processActivatedAudioTriggers(a1, m_levelTime);
p_m_isPlatformer[2298] = 0;
p_m_isPlatformer[1544] = 1;
}
begin = a1->m_sequenceTriggers.__begin_;
for ( i = a1->m_sequenceTriggers.__end_; begin != i; ++begin )
{
v13 = *begin;
m_uniqueID = (*begin)->m_uniqueID;
p_m_uniqueID = &m_uniqueID;
v14 = sub_100128058(&a2->m_sequenceTriggerStateUnorderedMap, &m_uniqueID, &unk_100637041, &p_m_uniqueID, &v39);
if ( &v13->m_sequenceState != (SequenceTriggerState *)(v14 + 24) )
{
v13->m_sequenceState.m_sequenceTimes.__table_.__p3_.__value_ = *(float *)(v14 + 56);
sub_100126E38((_DWORD)v13 + 1864);
v13->m_sequenceState.m_sequenceIndices.__table_.__p3_.__value_ = *(float *)(v14 + 96);
sub_10001EEF0(
&v13->m_sequenceState.m_sequenceIndices.__table_.__bucket_list_.__ptr_.__value_,
*(__int64 **)(v14 + 80),
nullptr);
}
}
if ( a1->m_gameState.m_isDualMode )
{
a1->m_gameState.m_isDualMode = 0;
GJBaseGameLayer::toggleDualMode(a1, nullptr, 1, nullptr, 1);
}
if ( UILayer::isJumpButtonPressed(a1->m_uiLayer) )
{
m_player1Checkpoint = a2->m_player1Checkpoint;
if ( *p_m_isPlatformer )
{
v16 = 0;
v17 = 0;
}
else
{
v17 = !m_player1Checkpoint->m_controlsDisabled;
v16 = 1;
}
}
else
{
v16 = 0;
v17 = 0;
m_player1Checkpoint = a2->m_player1Checkpoint;
}
m_player1Checkpoint->m_jumpBuffered = v17;
PlayerObject::loadFromCheckpoint(a1->m_player1, m_player1Checkpoint);
if ( a1->m_gameState.m_isDualMode )
{
m_player2Checkpoint = a2->m_player2Checkpoint;
v19 = v16 && !m_player2Checkpoint->m_controlsDisabled;
m_player2Checkpoint->m_jumpBuffered = v19;
PlayerObject::loadFromCheckpoint(a1->m_player2, m_player2Checkpoint);
if ( !PlayerObject::isFlying(a1->m_player1) && !a1->m_player1->m_isBall )
GJBaseGameLayer::enterDualMode(a1, a1->m_gameState.m_lastActivatedPortal1, 1);
}
GJEffectManager::loadFromState(a1->m_effectManager, &a2->m_effectManagerState);
m_gradientTriggerObjectArray = a2->m_gradientTriggerObjectArray;
if ( m_gradientTriggerObjectArray && (unsigned int)sub_10024A36C(a2->m_gradientTriggerObjectArray) )
{
v21 = 0;
do
{
v22 = (GradientTriggerObject *)sub_10024A388(m_gradientTriggerObjectArray, v21);
GJBaseGameLayer::triggerGradientCommand(a1, v22);
v21 = (unsigned int)(v21 + 1);
}
while ( (unsigned int)v21 < (unsigned int)sub_10024A36C(m_gradientTriggerObjectArray) );
}
PlayLayer::processLoadedMoveActions(a1);
PlayLayer::loadDynamicSaveObjects(a1, &a2->m_vectorSavedObjectStateRef);
PlayLayer::loadActiveSaveObjects(v23, &a2->m_vectorActiveSaveObjectState, &a2->m_vectorSpecialSaveObjectState);
((void (__fastcall *)(PlayLayer *, bool))a1->toggleGroundVisibility)(a1, !a2->m_ground2Invisible);
GJBaseGameLayer::togglePlayerStreakBlend(a1, a1->m_gameState.m_playerStreakBlend, 1);
m_collectibles = a1->m_collectibles;
if ( m_collectibles )
{
data = m_collectibles->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (EffectGameObject **)data->arr;
v28 = (unsigned __int64)&arr[num - 1];
do
{
v29 = *arr;
if ( !*arr )
break;
if ( GJEffectManager::hasBeenTriggered(a1->m_effectManager, v29->m_uniqueID, 0) )
{
GameObject::disableObject(v29);
if ( ((unsigned int (__fastcall *)(EffectGameObject *))v29->getType)(v29) == 31 )
GJBaseGameLayer::pickupItem(a1, v29);
}
++arr;
}
while ( (unsigned __int64)arr <= v28 );
}
}
for ( j = 0; j != 10000; ++j )
{
if ( !GJEffectManager::isGroupEnabled(a1->m_effectManager, j) )
{
Group = GJBaseGameLayer::getGroup(a1, j);
if ( Group )
{
v32 = Group->data;
v33 = v32->num;
if ( (_DWORD)v33 )
{
v34 = (GameObject **)v32->arr;
v35 = (unsigned __int64)&v34[v33 - 1];
do
{
if ( !*v34 )
break;
GameObject::groupWasDisabled(*v34++);
}
while ( (unsigned __int64)v34 <= v35 );
}
}
}
}
ActiveMode = PlayerObject::getActiveMode(a1->m_player1);
GJBaseGameLayer::updateDualGround(a1, a1->m_player1, ActiveMode, 1, 0.0);
a1->m_gameState.m_timeWarpRelated = a1->m_gameState.m_timeWarp;
v37 = cocos2d::CCDirector::sharedDirector();
*(float *)(((__int64 (__fastcall *)(cocos2d::CCDirector *))v37->getScheduler)(v37) + 56) = a1->m_gameState.m_timeWarpRelated;
}
}