//
// PlayLayer::resetLevel from 0x100121b78 to 0x100122510 (2456 bytes)
//
// 1 xrefs:
// > ??> @ 0x10078fea0
//
// 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::resetLevel(PlayLayer *a1)
{
bool *p_m_isPlatformer; // x23
bool m_freezeStartCamera; // w8
bool m_ignoreDamage; // w9
FMODAudioEngine *v5; // x0
FMODAudioEngine *v6; // x0
std::string::size_type m_replayRandSeed; // x0
EndPortalObject *m_endPortal; // x0
__n128 v9; // q0
EndPortalObject *v10; // x20
__n128 v11; // q1
double m_attemptTime; // d0
__int64 v13; // x20
GameObject *v14; // x21
int m_outerSectionIndex; // w8
double m_positionX; // d2
double v17; // d0
double v18; // d1
float m_sectionXFactor; // s1
double m_positionY; // d2
float m_sectionYFactor; // s0
int v22; // w8
int m_middleSectionIndex; // w8
float v24; // s10
float v25; // s10
CheckpointObject *LastCheckpoint; // x20
StartPosObject *m_startPosObject; // x8
CheckpointObject *m_currentCheckpoint; // x1
LevelSettingsObject **p_m_startSettings; // x8
PlayerObject *m_player1; // x21
__int64 *v31; // x0
double v32; // d0
PlayerObject *m_player2; // x21
__int64 *v34; // x1
double v35; // d0
GameStatsManager *v36; // x0
GJGameLevel *m_level; // x21
int v38; // w22
float v39; // s0
bool v40; // w21
bool isJumpButtonPressed; // w0
cocos2d::CCArray *m_batchNodes; // x8
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCNode **arr; // x22
unsigned __int64 v46; // x24
PlayerObject *v47; // x21
const cocos2d::CCPoint *v48; // x0
PlayerObject *v49; // x21
const cocos2d::CCPoint *v50; // x0
cocos2d::CCDelayTime *v51; // x20
cocos2d::CCAction *v52; // x0
std::string v53; // [xsp+18h] [xbp-78h] BYREF
__int64 v54; // [xsp+30h] [xbp-60h] BYREF
__int64 v55; // [xsp+38h] [xbp-58h] BYREF
cocos2d::SEL_CallFunc v56; // 0:x1.16
p_m_isPlatformer = &a1->m_isPlatformer;
m_freezeStartCamera = a1->m_freezeStartCamera;
if ( !m_freezeStartCamera && (*p_m_isPlatformer || a1->m_isPracticeMode) )
goto LABEL_10;
m_ignoreDamage = a1->m_ignoreDamage;
if ( a1->m_isIgnoreDamageEnabled )
{
a1->m_isIgnoreDamageEnabled = m_ignoreDamage;
if ( !m_ignoreDamage )
{
a1->m_ignoreDamage = 0;
a1->m_player1->m_maybeCanRunIntoBlocks = 0;
a1->m_player2->m_maybeCanRunIntoBlocks = 0;
PlayLayer::updateTestModeLabel(a1);
m_freezeStartCamera = p_m_isPlatformer[355];
}
}
else
{
a1->m_isIgnoreDamageEnabled = m_ignoreDamage;
}
if ( !m_freezeStartCamera )
{
LABEL_10:
v5 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopAllEffects(v5);
if ( !p_m_isPlatformer[290] || p_m_isPlatformer[291] )
{
if ( *p_m_isPlatformer )
{
v6 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::pauseAllMusic(v6, 0);
}
else
{
GJBaseGameLayer::pauseAudio(a1);
}
}
}
GJBaseGameLayer::preResumeGame(a1);
qword_100885CD8 = clock();
GJBaseGameLayer::resetLevelVariables(a1);
if ( p_m_isPlatformer[1572] && (!p_m_isPlatformer[1570] || !p_m_isPlatformer[290]) && !p_m_isPlatformer[380] )
PlayLayer::toggleDebugDraw(a1);
a1->m_gameState.m_commandIndex = 0;
a1->m_gameState.m_currentProgress = 0;
p_m_isPlatformer[179] = 1;
a1->m_activatedCheckpoint = nullptr;
p_m_isPlatformer[2286] = 0;
*(_QWORD *)&a1->m_unk32ec = 0;
a1->m_unk32d0 = 0;
if ( !p_m_isPlatformer[194] || (m_replayRandSeed = a1->m_replayRandSeed) == 0 )
{
gettimeofday((timeval *)&v53, nullptr);
m_replayRandSeed = v53.__r_.__value_.__r.__words[0] * SLODWORD(v53.__r_.__value_.__r.__words[1]);
}
a1->m_randomSeed = m_replayRandSeed;
GameToolbox::fast_srand(m_replayRandSeed);
a1->m_activeObjectsCount = 0;
p_m_isPlatformer[1632] = 0;
a1->m_unk36c8 = 0;
UILayer::toggleMenuVisibility(a1->m_uiLayer, 1);
*(_WORD *)(p_m_isPlatformer + 2055) = 0;
p_m_isPlatformer[1074] = 0;
m_endPortal = a1->m_endPortal;
if ( m_endPortal )
{
p_m_isPlatformer[1818] = 0;
*(_WORD *)&m_endPortal->m_flippedX = 0;
v9 = ((__n128 (__fastcall *)(EndPortalObject *, float))m_endPortal->setScaleX)(m_endPortal, 1.0);
v9.n128_u32[0] = LODWORD(a1->m_endXPosition);
LODWORD(a1->m_levelLength) = v9.n128_u32[0];
v10 = a1->m_endPortal;
v11.n128_u32[0] = 1130430464;
sub_100022980(v9, v11, &v53);
((void (__fastcall *)(EndPortalObject *, std::string *))v10->setStartPos)(v10, &v53);
GJBaseGameLayer::reorderObjectSection(a1, a1->m_endPortal);
((void (__fastcall *)(EndPortalObject *, __int64))a1->m_endPortal->deactivateObject)(a1->m_endPortal, 1);
}
p_m_isPlatformer[2062] = 0;
p_m_isPlatformer[2046] = 0;
*(_QWORD *)&a1->m_orbs = 0;
a1->m_secretKey = 0;
std::string::assign((std::string *)&a1->m_recordString, "");
a1->m_unk3900 = 0.0;
a1->m_activeGravityEffects = 0;
UILayer::enableMenu(a1->m_uiLayer);
GJBaseGameLayer::resetActiveEnterEffects(a1);
m_attemptTime = a1->m_attemptTime;
if ( m_attemptTime > a1->m_bestAttemptTime )
a1->m_bestAttemptTime = m_attemptTime;
a1->m_clicks = 0;
a1->m_attemptTime = 0.0;
*(_OWORD *)&a1->m_currentTime = 0u;
((void (__fastcall *)(PlayLayer *, _QWORD))a1->toggleGlitter)(a1, 0);
if ( (unsigned int)sub_10024A36C(a1->m_objects) )
{
v13 = 0;
do
{
v14 = (GameObject *)sub_10024A388(a1->m_objects, v13);
((void (__fastcall *)(std::string *__return_ptr))v14->getRealPosition)(&v53);
((void (__fastcall *)(GameObject *))v14->resetObject)(v14);
m_outerSectionIndex = v14->m_outerSectionIndex;
if ( (m_outerSectionIndex & 0x80000000) == 0 )
{
m_positionX = v14->m_positionX;
v17 = 0.0;
v18 = 0.0;
if ( m_positionX > 0.0 )
{
m_sectionXFactor = a1->m_sectionXFactor;
if ( m_positionX >= 10000000.0 )
v18 = (float)(m_sectionXFactor * 10000000.0);
else
v18 = m_positionX * m_sectionXFactor;
}
m_positionY = v14->m_positionY;
if ( m_positionY > 0.0 )
{
m_sectionYFactor = a1->m_sectionYFactor;
if ( m_positionY >= 10000000.0 )
v17 = (float)(m_sectionYFactor * 10000000.0);
else
v17 = m_positionY * m_sectionYFactor;
}
if ( m_outerSectionIndex != (int)v18 || v14->m_middleSectionIndex != (int)v17 )
{
GJBaseGameLayer::reorderObjectSection(a1, v14);
v22 = v14->m_outerSectionIndex;
if ( v22 > a1->m_rightSectionIndex
|| v22 < a1->m_leftSectionIndex
|| (m_middleSectionIndex = v14->m_middleSectionIndex, m_middleSectionIndex > a1->m_topSectionIndex)
|| m_middleSectionIndex < a1->m_bottomSectionIndex )
{
((void (__fastcall *)(GameObject *, __int64))v14->deactivateObject)(v14, 1);
}
}
}
v24 = *(float *)&v53.__r_.__value_.__l.__data_;
((void (__fastcall *)(__int64 *__return_ptr, GameObject *))v14->getRealPosition)(&v55, v14);
if ( v24 != *(float *)&v55
|| (v25 = *((float *)v53.__r_.__value_.__r.__words + 1),
((void (__fastcall *)(__int64 *__return_ptr, GameObject *))v14->getRealPosition)(&v54, v14),
v25 != *((float *)&v54 + 1)) )
{
v14->m_isDirty = 1;
((void (__fastcall *)(GameObject *, __int64))v14->setObjectRectDirty)(v14, 1);
((void (__fastcall *)(GameObject *, __int64))v14->setOrientedRectDirty)(v14, 1);
}
v13 = (unsigned int)(v13 + 1);
}
while ( (unsigned int)v13 < (unsigned int)sub_10024A36C(a1->m_objects) );
}
AudioEffectsLayer::resetAudioVars(a1->m_audioEffectsLayer);
PlayLayer::loadDefaultColors(a1);
LastCheckpoint = PlayLayer::loadLastCheckpoint(a1);
if ( !p_m_isPlatformer[194] )
{
GJEffectManager::getPersistentStateString((__int64 *)a1->m_effectManager, &v53);
std::string::operator=((std::string *)&a1->m_persistentStateString, &v53);
if ( SHIBYTE(v53.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v53.__r_.__value_.__l.__data_);
}
GJEffectManager::resetUsedItemState(a1->m_effectManager);
if ( LastCheckpoint )
{
p_m_isPlatformer[395] = 0;
if ( !p_m_isPlatformer[194] )
GJBaseGameLayer::resetRecord(a1, a1->m_gameState.m_unkUint4, 0);
}
else
{
*(_OWORD *)&a1->m_timePlayed = 0u;
GJBaseGameLayer::resetRecord(a1, 0, 0);
a1->m_unk32e0 = a1->m_randomSeed;
m_startPosObject = a1->m_startPosObject;
if ( m_startPosObject )
{
m_currentCheckpoint = a1->m_currentCheckpoint;
if ( m_currentCheckpoint )
{
PlayLayer::loadFromCheckpoint(a1, m_currentCheckpoint);
goto LABEL_61;
}
p_m_startSettings = &m_startPosObject->m_startSettings;
}
else
{
p_m_startSettings = &a1->m_levelSettings;
}
GJBaseGameLayer::setupLevelStart(a1, *p_m_startSettings);
}
LABEL_61:
m_player1 = a1->m_player1;
v31 = (__int64 *)((__int64 (__fastcall *)(PlayerObject *))m_player1->getPosition)(m_player1);
sub_1000229B8((__int64 *)&v53, v31);
v32 = sub_1000229D0(&m_player1->m_position, (double *)&v53);
m_player2 = a1->m_player2;
if ( a1->m_gameState.m_isDualMode )
{
v34 = (__int64 *)((__int64 (__fastcall *)(PlayerObject *, double))m_player2->getPosition)(a1->m_player2, v32);
}
else
{
((void (__fastcall *)(PlayerObject *, cocos2d::CCPoint *, double))m_player2->setPosition)(
a1->m_player2,
&stru_10086B290,
v32);
m_player2 = a1->m_player2;
v34 = (__int64 *)&stru_10086B290;
}
sub_1000229B8((__int64 *)&v53, v34);
v35 = sub_1000229D0(&m_player2->m_position, (double *)&v53);
if ( !LastCheckpoint )
{
v47 = a1->m_player1;
v48 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(PlayerObject *, double))v47->getPosition)(v47, v35);
GameObject::setLastPosition(v47, v48);
v49 = a1->m_player2;
v50 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(PlayerObject *))v49->getPosition)(v49);
GameObject::setLastPosition(v49, v50);
if ( a1->m_startPosObject )
{
if ( !a1->m_currentCheckpoint )
GJBaseGameLayer::loadStartPosObject(a1);
}
}
GJBaseGameLayer::updatePlayerCollisionBlocks(a1);
if ( !p_m_isPlatformer[356] )
{
PlayerObject::playSpawnEffect(a1->m_player1);
if ( a1->m_gameState.m_isDualMode )
PlayerObject::playSpawnEffect(a1->m_player2);
}
GJBaseGameLayer::stopCameraShake(a1);
if ( !((unsigned __int64)LastCheckpoint | (unsigned __int64)a1->m_startPosObject) )
{
a1->m_startingFromBeginning = 1;
GJBaseGameLayer::checkSpawnObjects(a1);
goto LABEL_75;
}
if ( !LastCheckpoint )
{
LABEL_75:
GJBaseGameLayer::updateProximityVolumeEffects(a1);
GJBaseGameLayer::updateLevelColors(a1);
GJBaseGameLayer::updateCamera(a1, 0.0);
((void (__fastcall *)(PlayLayer *, float))a1->updateVisibility)(a1, 0.0);
GJBaseGameLayer::updateGradientLayers(a1);
GJBaseGameLayer::updateShaderLayer(a1, 0.0);
PlayLayer::updateAttempts(a1);
a1->m_savedAttempts = a1->m_attempts;
std::string::operator=(
(std::string *)&a1->m_savedPersistentStateString,
(const std::string *)&a1->m_persistentStateString);
goto LABEL_76;
}
if ( LastCheckpoint->m_respawnID >= 1 )
{
memset(&v53, 0, sizeof(v53));
((void (__fastcall *)(PlayLayer *, double))a1->spawnGroup)(a1, 0.0);
if ( v53.__r_.__value_.__r.__words[0] )
{
v53.__r_.__value_.__l.__size_ = v53.__r_.__value_.__r.__words[0];
operator delete(v53.__r_.__value_.__l.__data_);
}
}
GJBaseGameLayer::gameEventTriggered(a1, CheckpointRespawn, 0, 0);
GJBaseGameLayer::updateProximityVolumeEffects(a1);
GJBaseGameLayer::updateLevelColors(a1);
GJBaseGameLayer::updateCamera(a1, 0.0);
((void (__fastcall *)(PlayLayer *, float))a1->updateVisibility)(a1, 0.0);
GJBaseGameLayer::updateGradientLayers(a1);
GJBaseGameLayer::updateShaderLayer(a1, 0.0);
PlayLayer::updateAttempts(a1);
LABEL_76:
v36 = GameStatsManager::sharedState();
GameStatsManager::incrementStat_1(v36, "2");
m_level = a1->m_level;
v38 = m_level->m_attempts.random - m_level->m_attempts.seed + 1;
m_level->m_attempts.value = v38;
v39 = vcvts_n_f32_s32(rand(), 0x1Fu) * 1000.0;
m_level->m_attempts.seed = (int)v39;
m_level->m_attempts.random = v38 + (int)v39;
PlayLayer::updateProgressbar(a1);
GJBaseGameLayer::refreshCounterLabels(a1);
v40 = p_m_isPlatformer[394];
if ( *p_m_isPlatformer )
{
p_m_isPlatformer[394] = 0;
}
else if ( !LastCheckpoint && p_m_isPlatformer[394] && !a1->m_startPosObject )
{
PlayLayer::startMusic(a1);
}
if ( GameManager::sharedState()->m_recordGameplay && !p_m_isPlatformer[290] && !p_m_isPlatformer[354] )
{
cocos2d::CCNode::stopActionByTag(a1, 31);
p_m_isPlatformer[2075] = 0;
}
GJBaseGameLayer::removeReleasedButtons(a1);
isJumpButtonPressed = UILayer::isJumpButtonPressed(a1->m_uiLayer);
GJBaseGameLayer::queueButton(a1, 1, isJumpButtonPressed, 0, 0.0);
if ( !p_m_isPlatformer[290] && !p_m_isPlatformer[1784] )
p_m_isPlatformer[1634] = 0;
p_m_isPlatformer[355] = 0;
p_m_isPlatformer[343] = 0;
GJBaseGameLayer::syncBGTextures(a1);
qword_100885CE0 = clock();
qword_100885CE8 = qword_100885CE0 - qword_100885CD8;
m_batchNodes = a1->m_batchNodes;
if ( m_batchNodes )
{
data = m_batchNodes->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (cocos2d::CCNode **)data->arr;
v46 = (unsigned __int64)&arr[num - 1];
do
{
if ( !*arr )
break;
cocos2d::CCNode::qsortAllChildrenWithIndex(*arr++);
}
while ( (unsigned __int64)arr <= v46 );
}
}
GJBaseGameLayer::sortSectionVector(a1);
if ( *p_m_isPlatformer && (v40 || p_m_isPlatformer[1782]) )
{
p_m_isPlatformer[1782] = 0;
if ( !LastCheckpoint )
{
v51 = cocos2d::CCDelayTime::create(0.2);
v56.ptr = (void (*)(void))PlayLayer::startGameDelayed;
v56.adj = 0;
cocos2d::CCCallFunc::create(a1, v56);
v52 = (cocos2d::CCAction *)sub_10018A494(v51);
cocos2d::CCNode::runAction(a1, v52);
a1->m_startingFromBeginning = 0;
p_m_isPlatformer[1544] = 1;
return;
}
p_m_isPlatformer[394] = 1;
a1->m_startingFromBeginning = 0;
p_m_isPlatformer[1544] = 1;
}
else
{
a1->m_startingFromBeginning = 0;
p_m_isPlatformer[1544] = 1;
if ( !LastCheckpoint )
return;
}
sub_1000229D0(&a1->m_gameState.m_cameraPosition2, (double *)&LastCheckpoint->m_gameState.m_cameraPosition2);
sub_1000229D0(&a1->m_gameState.m_cameraStepDiff, (double *)&LastCheckpoint->m_gameState.m_cameraStepDiff);
sub_1000229D0(&a1->m_gameState.m_unkPoint4, (double *)&LastCheckpoint->m_gameState.m_unkPoint4);
}