//
// GJBaseGameLayer::resetLevelVariables from 0x14023b040 to 0x14023bad7 (2711 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::onPlaytest @ 0x1402dfdba
// > LevelEditorLayer::onStopPlaytest @ 0x1402e0863
// > PlayLayer::resetLevel @ 0x1403b9059
// > ??> @ 0x1406ce25c
//
// 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=3
void GJBaseGameLayer::resetLevelVariables(GJBaseGameLayer *a1)
{
float v1; // xmm0_4
LevelSettingsObject *m_levelSettings; // rdx
std::_Tree_val
, std::vector>>>::_Nodeptr Myhead; // rbx
__int64 v5; // rcx
FMODAudioEngine *v6; // rcx
__int64 v7; // rdx
std::_Simple_types::value_type *Myfirst; // rax
std::_Simple_types::value_type *v9; // rax
unsigned int v10; // edi
struct cocos2d::CCObject *v11; // rbx
LevelSettingsObject *v12; // rax
LevelSettingsObject *v13; // rcx
GJGameLevel *m_level; // rdx
bool *p_m_isPlatformer; // rbx
bool v16; // cl
bool v17; // cl
std::_Simple_types::value_type *v18; // rax
ShaderLayer *m_shaderLayer; // rcx
std::_Simple_types::value_type *v20; // rax
std::_Simple_types::value_type *v21; // rax
std::_Simple_types::value_type *v22; // rax
std::_Vector_val>::pointer v23; // rbx
std::_Vector_val>::pointer Mylast; // rdi
std::unordered_map *p_m_tweenActions; // rdi
cocos2d::CCSprite *m_background; // rcx
cocos2d::CCSprite_vtbl *v27; // rbx
float *v28; // rax
const cocos2d::CCPoint *v29; // rax
double v30; // xmm0_8
PlayerObject *m_player1; // rbx
PlayerObject *m_player2; // rbx
_BOOL8 v33; // rdx
GJGroundLayer *m_groundLayer; // rcx
GJGroundLayer *m_groundLayer2; // rcx
__int64 v36; // rcx
cocos2d::CCDirector *v37; // rax
const cocos2d::CCPoint *v38; // rax
__int64 m_leftSectionIndex; // rdx
__int64 v40; // r12
__int64 v41; // rax
std::_Simple_types *, std::allocator *>> *>::value_type v42; // rcx
__int64 v43; // rax
int m_bottomSectionIndex; // r15d
__int64 v45; // r14
__int64 v46; // r13
std::_Simple_types *>::value_type v47; // rdi
__int64 v48; // rbx
__int64 v49; // rbp
__int64 v50; // [rsp+70h] [rbp+8h] BYREF
float v51; // [rsp+7Ch] [rbp+14h]
__int64 v52; // [rsp+80h] [rbp+18h]
a1->m_gameState.m_pauseCounter = 0;
m_levelSettings = a1->m_levelSettings;
a1->m_gameState.m_background = m_levelSettings->m_backgroundIndex;
a1->m_gameState.m_ground = m_levelSettings->m_groundIndex;
a1->m_gameState.m_middleground = m_levelSettings->m_middleGroundIndex;
a1->m_gameState.m_unkBool31 = 0;
a1->m_gameState.m_unkBool30 = 0;
sub_1400CDCD0(&a1->m_gameState.m_unkMapPairGJGameEventIntInt._Mypair._Myval2._Myval2._Myhead);
a1->resetSPTriggered(a1);
Myhead = a1->m_gameState.m_unkMapPairGJGameEventIntVectorEventTriggerInstance._Mypair._Myval2._Myval2._Myhead;
sub_140250530(
&a1->m_gameState.m_unkMapPairGJGameEventIntVectorEventTriggerInstance,
&a1->m_gameState.m_unkMapPairGJGameEventIntVectorEventTriggerInstance,
Myhead->_Parent);
Myhead->_Parent = Myhead;
Myhead->_Left = Myhead;
Myhead->_Right = Myhead;
a1->m_gameState.m_unkMapPairGJGameEventIntVectorEventTriggerInstance._Mypair._Myval2._Myval2._Mysize = 0;
v5 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v50 = (__int64)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v50);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v5 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v50 = (__int64)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(v50);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v5 = qword_1406C2ED8;
}
}
cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(v5 + 1184));
v6 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v50 = (__int64)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine((FMODAudioEngine *)v50);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v6 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::updateReverb(v6, Generic, 0);
a1->m_gameState.m_unkFloat5 = 0.1;
a1->m_gameState.m_unkFloat6 = 0.1;
a1->m_gameState.m_unkFloat7 = 0.30000001;
a1->m_gameState.m_unkFloat8 = 0.5;
a1->m_startingFromBeginning = 0;
Myfirst = a1->m_activeSfxTriggers._Mypair._Myval2._Myfirst;
if ( Myfirst != a1->m_activeSfxTriggers._Mypair._Myval2._Mylast )
a1->m_activeSfxTriggers._Mypair._Myval2._Mylast = Myfirst;
sub_140249D70(&a1->m_gameState.m_songChannelStates, v7);
sub_140249C30(&a1->m_gameState.m_songTriggerStateVectors);
v9 = a1->m_gameState.m_sfxTriggerStates._Mypair._Myval2._Myfirst;
if ( v9 != a1->m_gameState.m_sfxTriggerStates._Mypair._Myval2._Mylast )
a1->m_gameState.m_sfxTriggerStates._Mypair._Myval2._Mylast = v9;
v10 = 0;
while ( v10 < cocos2d::CCArray::count(a1->m_temporaryParticles) )
{
v11 = cocos2d::CCArray::objectAtIndex(a1->m_temporaryParticles, v10);
if ( ((unsigned __int8 (__fastcall *)(struct cocos2d::CCObject *))v11->__vftable[21].~CCObject)(v11) )
{
v11->__vftable[7].~CCObject(v11);
LODWORD(v50) = v11->m_uID;
sub_14005D780(&a1->m_customParticlesUIDs._Traitsobj._Mypair._Myval2._Myval2, (unsigned __int8 *)&v50);
cocos2d::CCArray::fastRemoveObjectAtIndex(a1->m_temporaryParticles, v10);
}
else
{
++v10;
}
}
a1->m_gameState.m_points = 0;
a1->m_gameState.m_unkBool32 = 0;
GJBaseGameLayer::updateSpecialLabels(a1);
a1->m_levelEndAnimationStarted = 0;
v12 = a1->m_levelSettings;
if ( v12 )
{
a1->m_effectManager->m_unk798 = !v12->m_allowMultiRotation;
v13 = a1->m_levelSettings;
a1->m_enable22Changes = v13->m_enable22Changes;
m_level = a1->m_level;
if ( m_level
&& m_level->m_levelType == Main
&& (a1->m_isPlatformer || m_level->m_levelID.random - m_level->m_levelID.seed == 22) )
{
a1->m_enable22Changes = 1;
}
a1->m_allowStaticRotate = v13->m_allowStaticRotate;
a1->m_fixNegativeScale = v13->m_fixNegativeScale;
p_m_isPlatformer = &a1->m_isPlatformer;
v16 = !v13->m_enablePlayerSqueeze && !*p_m_isPlatformer;
a1->m_player1->m_disablePlayerSqueeze = v16;
v17 = !a1->m_levelSettings->m_enablePlayerSqueeze && !*p_m_isPlatformer;
a1->m_player2->m_disablePlayerSqueeze = v17;
a1->m_player1->m_fixGravityBug = a1->m_levelSettings->m_fixGravityBug;
a1->m_player2->m_fixGravityBug = a1->m_levelSettings->m_fixGravityBug;
a1->m_player1->m_reverseSync = a1->m_levelSettings->m_reverseSync;
a1->m_player2->m_reverseSync = a1->m_levelSettings->m_reverseSync;
a1->m_player1->m_enable22Changes = !a1->m_enable22Changes;
a1->m_player2->m_enable22Changes = !a1->m_enable22Changes;
a1->m_player1->m_enableImpulseFix = a1->m_levelSettings->m_enableImpulseFix;
a1->m_player2->m_enableImpulseFix = a1->m_levelSettings->m_enableImpulseFix;
}
else
{
p_m_isPlatformer = &a1->m_isPlatformer;
}
GJBaseGameLayer::resetActiveEnterEffects(a1);
sub_14005E2A0(&a1->m_gameState.m_proximityVolumeRelated._Mypair._Myval2._Myval2._Myhead);
a1->m_gameState.m_levelTime = 0.0;
sub_14024A9F0(&a1->m_gameState.m_gameObjectPhysics);
sub_14005D290(&a1->m_gameState.m_stateObjects._Traitsobj._Mypair._Myval2._Myval2);
a1->m_gameState.m_commandIndex = 0;
a1->m_gameState.m_currentProgress = 0;
a1->m_gameState.m_unkUint11 = 0;
*(_QWORD *)&a1->m_gameState.m_unkUint5 = 0;
if ( !*p_m_isPlatformer )
{
v18 = a1->m_queuedButtons._Mypair._Myval2._Myfirst;
if ( v18 != a1->m_queuedButtons._Mypair._Myval2._Mylast )
a1->m_queuedButtons._Mypair._Myval2._Mylast = v18;
}
PlayerObject::releaseAllButtons(a1->m_player1);
PlayerObject::releaseAllButtons(a1->m_player2);
a1->m_extraDelta = 0.0;
a1->m_unk3251 = 1;
a1->m_dualTouchTrigger = 0;
GJEffectManager::resetEffects(a1->m_effectManager);
sub_1400CDCD0(&a1->m_gameState.m_activatedObjectIDs._Mypair._Myval2._Myval2._Myhead);
m_shaderLayer = a1->m_shaderLayer;
if ( m_shaderLayer )
{
ShaderLayer::resetAllShaders(m_shaderLayer);
GJBaseGameLayer::updateShaderLayer(a1, 0.0);
}
GJBaseGameLayer::resetGradientLayers(a1);
v20 = a1->m_gameState.m_advanceFollowInstances._Mypair._Myval2._Myfirst;
if ( v20 != a1->m_gameState.m_advanceFollowInstances._Mypair._Myval2._Mylast )
a1->m_gameState.m_advanceFollowInstances._Mypair._Myval2._Mylast = v20;
v21 = a1->m_gameState.m_dynamicMoveActions._Mypair._Myval2._Myfirst;
if ( v21 != a1->m_gameState.m_dynamicMoveActions._Mypair._Myval2._Mylast )
a1->m_gameState.m_dynamicMoveActions._Mypair._Myval2._Mylast = v21;
v22 = a1->m_gameState.m_dynamicRotateActions._Mypair._Myval2._Myfirst;
if ( v22 != a1->m_gameState.m_dynamicRotateActions._Mypair._Myval2._Mylast )
a1->m_gameState.m_dynamicRotateActions._Mypair._Myval2._Mylast = v22;
v23 = a1->m_gameState.m_moveEffectInstances._Mypair._Myval2._Myfirst;
Mylast = a1->m_gameState.m_moveEffectInstances._Mypair._Myval2._Mylast;
if ( v23 != Mylast )
{
do
{
sub_14005E430((__int64)&v23->m_easeIndices);
sub_1402508A0(v23, v23);
++v23;
}
while ( v23 != Mylast );
a1->m_gameState.m_moveEffectInstances._Mypair._Myval2._Mylast = a1->m_gameState.m_moveEffectInstances._Mypair._Myval2._Myfirst;
}
sub_14024A170(&a1->m_gameState.m_rotateEffectInstances);
sub_14024A170(&a1->m_gameState.m_scaleEffectInstances);
sub_14024A170(&a1->m_gameState.m_fadeEffectInstances);
sub_14024A170(&a1->m_gameState.m_tintEffectInstances);
sub_14005E0D0(&a1->m_gameState.m_unsortedAreaEffects._Traitsobj._Mypair._Myval2._Myval2);
a1->m_skipArtReload = 1;
((void (__fastcall *)(GJBaseGameLayer *))a1->updateTimeWarp)(a1);
*(_QWORD *)&a1->m_gameState.m_unkInt3 = 0;
LODWORD(v50) = 20;
p_m_tweenActions = &a1->m_gameState.m_tweenActions;
sub_14024AC30(&a1->m_gameState.m_tweenActions, &v50);
LODWORD(a1->m_gameState.m_middleGroundOffsetY) = a1->m_gameState.m_unkInt3;
m_background = a1->m_background;
v27 = m_background->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v28 = (float *)m_background->getPosition_0(m_background);
cocos2d::CCPoint::CCPoint(v1, *v28);
v27->setPosition_0(a1->m_background, v29);
GJBaseGameLayer::resetCamera(a1);
a1->m_groundLayer->m_unk1cc = 0.0;
a1->m_groundLayer2->m_unk1cc = 0.0;
v30 = ((double (__fastcall *)(GJGroundLayer *))a1->m_groundLayer->getScaleX)(a1->m_groundLayer);
GJGroundLayer::scaleGround(a1->m_groundLayer, *(float *)&v30);
*(float *)&v30 = a1->m_groundLayer2->getScaleX(a1->m_groundLayer2);
GJGroundLayer::scaleGround(a1->m_groundLayer2, *(float *)&v30);
GJGroundLayer::updateShadowXPos(a1->m_groundLayer, 0.0, 0.0);
GJGroundLayer::updateShadows(a1->m_groundLayer);
GJGroundLayer::updateShadowXPos(a1->m_groundLayer2, 0.0, 0.0);
GJGroundLayer::updateShadows(a1->m_groundLayer2);
if ( !a1->m_gameState.m_playerStreakBlend )
{
a1->m_gameState.m_playerStreakBlend = 1;
m_player1 = a1->m_player1;
v50 = 0x100000302LL;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))m_player1->m_regularTrail->setBlendFunc)(
&m_player1->m_regularTrail->cocos2d::CCTextureProtocol,
0x100000302LL);
m_player1->m_waveTrail->m_isSolid = 0;
cocos2d::CCDrawNode::setBlendFunc(m_player1->m_waveTrail, (const struct cocos2d::_ccBlendFunc *)&v50);
m_player2 = a1->m_player2;
v50 = 0x100000302LL;
((void (__fastcall *)(cocos2d::CCTextureProtocol *, __int64))m_player2->m_regularTrail->setBlendFunc)(
&m_player2->m_regularTrail->cocos2d::CCTextureProtocol,
0x100000302LL);
m_player2->m_waveTrail->m_isSolid = 0;
cocos2d::CCDrawNode::setBlendFunc(m_player2->m_waveTrail, (const struct cocos2d::_ccBlendFunc *)&v50);
}
a1->m_gameState.m_timeModRelated = 0.0;
a1->m_gameState.m_unkUint64_1 = 0.0;
cocos2d::CCPoint::operator=(&a1->m_gameState.m_unkPoint34, &dword_1406C1D28);
a1->m_gameState.m_unkUint16 = 0.0;
m_groundLayer = a1->m_groundLayer;
if ( !m_groundLayer->m_showGround2 )
{
m_groundLayer->m_showGround2 = 1;
LOBYTE(v33) = m_groundLayer->m_showGround1;
m_groundLayer->setVisible(m_groundLayer, v33);
p_m_tweenActions = &a1->m_gameState.m_tweenActions;
}
m_groundLayer2 = a1->m_groundLayer2;
if ( !m_groundLayer2->m_showGround2 )
{
m_groundLayer2->m_showGround2 = 1;
LOBYTE(v33) = m_groundLayer2->m_showGround1;
m_groundLayer2->setVisible(m_groundLayer2, v33);
}
a1->m_gameState.m_unkFloat9 = 0.0;
LODWORD(v50) = 25;
sub_14024AC30(p_m_tweenActions, &v50);
a1->m_gameState.m_unkBool1 = 0;
a1->m_gameState.m_unkBool6 = 0;
a1->m_gameState.m_portalY = 0.0;
a1->m_gameState.m_unkInt12 = 0;
a1->m_unk322a = a1->m_freezeStartCamera;
a1->m_playerDied = 0;
cocos2d::CCDictionary::removeAllObjects(a1->m_collectedItems);
a1->m_gameState.m_unkBool10 = 0;
a1->m_gameState.m_unkBool11 = 0;
a1->m_resetActiveObjects = 0;
a1->m_gameState.m_levelFlipping = 0.0;
a1->m_cameraFlip = 1.0;
cocos2d::CCNode::stopActionByTag(a1, 14);
a1->m_gameState.m_lastActivatedPortal1 = nullptr;
a1->m_gameState.m_lastActivatedPortal2 = nullptr;
GJBaseGameLayer::resetPlayer(a1);
GJBaseGameLayer::resetSpawnChannelIndex(a1);
cocos2d::CCNode::stopAllActions(a1->m_flashNode);
a1->m_flashNode->setVisible(a1->m_flashNode, 0);
v37 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v36);
cocos2d::CCDirector::getWinSize(v37);
v38 = a1->m_player1->getPosition_0(a1->m_player1);
a1->m_gameState.m_cameraPosition.y = (float)(v38->y - v51) + 90.0;
if ( a1->m_objectsDeactivated )
{
m_leftSectionIndex = a1->m_leftSectionIndex;
LODWORD(v50) = m_leftSectionIndex;
if ( (int)m_leftSectionIndex <= a1->m_rightSectionIndex )
{
v40 = m_leftSectionIndex;
v41 = (int)(a1->m_sections._Mypair._Myval2._Mylast - a1->m_sections._Mypair._Myval2._Myfirst);
v52 = (int)v41;
do
{
if ( v40 >= v41 )
break;
v42 = a1->m_sections._Mypair._Myval2._Myfirst[v40];
if ( v42 )
v43 = v42->_Mypair._Myval2._Mylast - v42->_Mypair._Myval2._Myfirst;
else
LODWORD(v43) = -1;
m_bottomSectionIndex = a1->m_bottomSectionIndex;
if ( m_bottomSectionIndex <= a1->m_topSectionIndex )
{
v45 = a1->m_bottomSectionIndex;
v46 = (int)v43;
do
{
if ( v45 >= v46 )
break;
v47 = a1->m_sections._Mypair._Myval2._Myfirst[v40]->_Mypair._Myval2._Myfirst[v45];
if ( v47 )
{
v48 = 0;
v49 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v40]->_Mypair._Myval2._Myfirst[v45];
if ( v49 > 0 )
{
do
{
LOBYTE(m_leftSectionIndex) = 1;
v47->_Mypair._Myval2._Myfirst[v48]->deactivateObject(
v47->_Mypair._Myval2._Myfirst[v48],
m_leftSectionIndex);
++v48;
}
while ( v48 < v49 );
}
}
++m_bottomSectionIndex;
++v45;
}
while ( m_bottomSectionIndex <= a1->m_topSectionIndex );
LODWORD(m_leftSectionIndex) = v50;
}
m_leftSectionIndex = (unsigned int)(m_leftSectionIndex + 1);
LODWORD(v50) = m_leftSectionIndex;
++v40;
v41 = v52;
}
while ( (int)m_leftSectionIndex <= a1->m_rightSectionIndex );
}
}
GJBaseGameLayer::toggleDualMode(a1, nullptr, 0, nullptr, 0);
}