//
// GJBaseGameLayer::resetLevelVariables from 0x88a930 to 0x88b23c (2316 bytes)
//
// 4 xrefs:
// > PlayLayer::resetLevel @ 0x5e51f4
// > LevelEditorLayer::onStopPlaytest @ 0x662830
// > LevelEditorLayer::onPlaytest @ 0x664080
// > ??> @ 0x91b18
//
// 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 GJBaseGameLayer::resetLevelVariables(GJBaseGameLayer *a1)
{
std::map,int> *p_m_unkMapPairGJGameEventIntInt; // x20
LevelSettingsObject *m_levelSettings; // x0
cocos2d::CCPoint v4; // x1
std::_rb_tree_base *m_parent; // x19
std::_rb_tree_base *v6; // x0
std::__detail::_Hash_node_base *M_nxt; // x0
std::__detail::_Hash_node_base *v8; // x19
GJBaseGameLayer_vtbl *v9; // x1
GameManager *v10; // x0
GameManager *v11; // x0
FMODAudioEngine *v12; // x0
LevelSettingsObject *v13; // x0
GJGameLevel *m_level; // x1
_BOOL4 m_enablePlayerSqueeze; // w1
PlayerObject *m_player1; // x2
PlayerObject *m_player2; // x1
char v18; // w3
bool m_fixGravityBug; // w5
bool m_reverseSync; // w4
char m_enable22Changes; // w3
bool m_enableImpulseFix; // w0
std::__detail::_Hash_node_base *v23; // x0
std::__detail::_Hash_node_base *v24; // x19
std::__detail::_Hash_node_base *v25; // x0
std::__detail::_Hash_node_base *v26; // x19
_BOOL4 m_isPlatformer; // w0
GJEffectManager *m_effectManager; // x0
std::_rb_tree_base *v29; // x19
std::_rb_tree_base *v30; // x0
ShaderLayer *m_shaderLayer; // x0
EnterEffectInstance *m_start; // x24
EnterEffectInstance *m_finish; // x23
__int64 v34; // x22
DynamicObjectAction *v35; // x1
DynamicObjectAction *v36; // x0
void *v37; // x0
__int64 v38; // x19
void *v39; // x0
EnterEffectInstance *v40; // x25
EnterEffectInstance *v41; // x23
__int64 v42; // x22
void *v43; // x0
__int64 v44; // x19
void *v45; // x0
EnterEffectInstance *v46; // x24
EnterEffectInstance *v47; // x23
__int64 v48; // x22
void *v49; // x0
__int64 v50; // x19
void *v51; // x0
EnterEffectInstance *v52; // x25
EnterEffectInstance *v53; // x23
__int64 v54; // x22
void *v55; // x0
__int64 v56; // x19
void *v57; // x0
EnterEffectInstance *v58; // x24
EnterEffectInstance *v59; // x23
__int64 v60; // x22
void *v61; // x0
__int64 v62; // x19
void *v63; // x0
std::__detail::_Hash_node_base *v64; // x0
std::__detail::_Hash_node_base *v65; // x19
GJBaseGameLayer_vtbl *v66; // x1
void (__fastcall *updateTimeWarp)(GJBaseGameLayer *__hidden, float); // x1
cocos2d::CCSprite *m_background; // x23
void (__fastcall *setPosition)(cocos2d::CCSprite *__hidden, const cocos2d::CCPoint *); // x24
float *v70; // x0
GJGroundLayer *m_groundLayer; // x23
GJGroundLayer *m_groundLayer2; // x2
GJGroundLayer_vtbl *v73; // x1
float v74; // s0
float v75; // s0
GJGroundLayer *v76; // x23
float v77; // s0
float v78; // s1
GJGroundLayer *v79; // x0
bool m_freezeStartCamera; // w1
cocos2d::CCDirector *v81; // x0
__int64 v82; // x0
_BOOL4 m_objectsDeactivated; // w1
std::vector *, std::allocator *>> **v84; // x19
int m_leftSectionIndex; // w26
int m_rightSectionIndex; // w22
__int64 v87; // x24
std::vector *, std::allocator *>> *v88; // x19
unsigned __int64 i; // x25
int m_bottomSectionIndex; // w20
int m_topSectionIndex; // w1
__int64 v92; // x23
__int64 v93; // x22
std::vector *v94; // x27
int v95; // w19
unsigned __int64 v96; // x28
__int64 v97; // x19
GameObject *v98; // x3
int v99; // [xsp+7Ch] [xbp+7Ch]
cocos2d::CCPoint v100[2]; // [xsp+80h] [xbp+80h] BYREF
cocos2d::CCSize WinSize; // 0:kr00_8.8
p_m_unkMapPairGJGameEventIntInt = &a1->m_gameState.m_unkMapPairGJGameEventIntInt;
m_levelSettings = a1->m_levelSettings;
a1->m_gameState.m_pauseCounter = 0;
v4 = (cocos2d::CCPoint)_stack_chk_guard;
a1->m_gameState.m_background = m_levelSettings->m_backgroundIndex;
m_parent = a1->m_gameState.m_unkMapPairGJGameEventIntInt.m_header.m_parent;
a1->m_gameState.m_ground = m_levelSettings->m_groundIndex;
v100[1] = v4;
a1->m_gameState.m_middleground = m_levelSettings->m_middleGroundIndex;
a1->m_gameState.m_unkBool31 = 0;
a1->m_gameState.m_unkBool30 = 0;
while ( m_parent )
{
std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_erase(
(__int64)p_m_unkMapPairGJGameEventIntInt,
&m_parent->m_right->m_isblack);
v6 = m_parent;
m_parent = m_parent->m_left;
operator delete(v6);
}
a1->m_gameState.m_unkMapPairGJGameEventIntInt.m_header.m_parent = nullptr;
a1->m_gameState.m_unkMapPairGJGameEventIntInt.m_header.m_left = &a1->m_gameState.m_unkMapPairGJGameEventIntInt.m_header;
a1->m_gameState.m_unkMapPairGJGameEventIntInt.m_header.m_right = &a1->m_gameState.m_unkMapPairGJGameEventIntInt.m_header;
M_nxt = a1->m_allowedButtons._M_h._M_before_begin._M_nxt;
p_m_unkMapPairGJGameEventIntInt->m_nodecount = 0;
if ( M_nxt )
{
do
{
v8 = M_nxt->_M_nxt;
operator delete(M_nxt);
M_nxt = v8;
}
while ( v8 );
}
memset(a1->m_allowedButtons._M_h._M_buckets, 0, 8 * a1->m_allowedButtons._M_h._M_bucket_count);
a1->m_allowedButtons._M_h._M_before_begin._M_nxt = nullptr;
v9 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_allowedButtons._M_h._M_element_count = 0;
v9->resetSPTriggered(a1);
GJBaseGameLayer::unlinkAllEvents(a1);
highestDeltaX = 0;
highestDeltaY = 0;
v10 = GameManager::sharedState();
GameManager::printGJLog(v10);
v11 = GameManager::sharedState();
GameManager::clearGJLog(v11);
v12 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::updateReverb(v12, Generic, 0);
GJBaseGameLayer::updateBGArtSpeed(a1, 0.1, 0.1);
GJBaseGameLayer::updateMGArtSpeed(a1, 0.3, 0.5);
a1->m_startingFromBeginning = 0;
a1->m_activeSfxTriggers.m_finish = a1->m_activeSfxTriggers.m_start;
GJBaseGameLayer::clearActivatedAudioTriggers(a1);
GJBaseGameLayer::removeTemporaryParticles(a1);
a1->m_gameState.m_points = 0;
a1->m_gameState.m_unkBool32 = 0;
GJBaseGameLayer::updateSpecialLabels(a1);
v13 = a1->m_levelSettings;
a1->m_levelEndAnimationStarted = 0;
if ( v13 )
{
m_level = a1->m_level;
a1->m_effectManager->m_unk798 = !v13->m_allowMultiRotation;
a1->m_enable22Changes = v13->m_enable22Changes;
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;
m_enablePlayerSqueeze = v13->m_enablePlayerSqueeze;
a1->m_fixNegativeScale = v13->m_fixNegativeScale;
m_player1 = a1->m_player1;
if ( m_enablePlayerSqueeze || a1->m_isPlatformer )
{
m_player2 = a1->m_player2;
v18 = 0;
m_player1->m_disablePlayerSqueeze = 0;
}
else
{
m_player2 = a1->m_player2;
m_player1->m_disablePlayerSqueeze = 1;
v18 = 1;
}
m_fixGravityBug = v13->m_fixGravityBug;
m_player2->m_disablePlayerSqueeze = v18;
m_player1->m_fixGravityBug = m_fixGravityBug;
m_reverseSync = v13->m_reverseSync;
m_player2->m_fixGravityBug = m_fixGravityBug;
m_enable22Changes = a1->m_enable22Changes;
m_player1->m_reverseSync = m_reverseSync;
m_player2->m_reverseSync = m_reverseSync;
m_enable22Changes ^= 1u;
m_player1->m_enable22Changes = m_enable22Changes;
m_enableImpulseFix = v13->m_enableImpulseFix;
m_player2->m_enable22Changes = m_enable22Changes;
m_player1->m_enableImpulseFix = m_enableImpulseFix;
m_player2->m_enableImpulseFix = m_enableImpulseFix;
}
GJBaseGameLayer::resetActiveEnterEffects(a1);
GJBaseGameLayer::resetSongTriggerValues(a1);
v23 = a1->m_gameState.m_gameObjectPhysics._M_h._M_before_begin._M_nxt;
if ( v23 )
{
do
{
v24 = v23->_M_nxt;
operator delete(v23);
v23 = v24;
}
while ( v24 );
}
memset(
a1->m_gameState.m_gameObjectPhysics._M_h._M_buckets,
0,
8 * a1->m_gameState.m_gameObjectPhysics._M_h._M_bucket_count);
a1->m_gameState.m_gameObjectPhysics._M_h._M_before_begin._M_nxt = nullptr;
v25 = a1->m_gameState.m_stateObjects._M_h._M_before_begin._M_nxt;
a1->m_gameState.m_gameObjectPhysics._M_h._M_element_count = 0;
if ( v25 )
{
do
{
v26 = v25->_M_nxt;
operator delete(v25);
v25 = v26;
}
while ( v26 );
}
memset(a1->m_gameState.m_stateObjects._M_h._M_buckets, 0, 8 * a1->m_gameState.m_stateObjects._M_h._M_bucket_count);
a1->m_gameState.m_stateObjects._M_h._M_element_count = 0;
m_isPlatformer = a1->m_isPlatformer;
a1->m_gameState.m_stateObjects._M_h._M_before_begin._M_nxt = nullptr;
a1->m_gameState.m_commandIndex = 0;
a1->m_gameState.m_currentProgress = 0;
a1->m_gameState.m_unkUint11 = 0;
a1->m_gameState.m_unkUint5 = 0;
a1->m_gameState.m_unkUint6 = 0;
if ( !m_isPlatformer )
a1->m_queuedButtons.m_finish = a1->m_queuedButtons.m_start;
PlayerObject::releaseAllButtons(a1->m_player1);
PlayerObject::releaseAllButtons(a1->m_player2);
m_effectManager = a1->m_effectManager;
a1->m_extraDelta = 0.0;
a1->m_unk3251 = 1;
a1->m_dualTouchTrigger = 0;
GJEffectManager::resetEffects(m_effectManager);
v29 = a1->m_gameState.m_activatedObjectIDs.m_header.m_parent;
while ( v29 )
{
std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_erase(
(__int64)&a1->m_gameState.m_activatedObjectIDs,
&v29->m_right->m_isblack);
v30 = v29;
v29 = v29->m_left;
operator delete(v30);
}
a1->m_gameState.m_activatedObjectIDs.m_header.m_parent = nullptr;
a1->m_gameState.m_activatedObjectIDs.m_header.m_left = &a1->m_gameState.m_activatedObjectIDs.m_header;
a1->m_gameState.m_activatedObjectIDs.m_header.m_right = &a1->m_gameState.m_activatedObjectIDs.m_header;
m_shaderLayer = a1->m_shaderLayer;
a1->m_gameState.m_activatedObjectIDs.m_nodecount = 0;
if ( m_shaderLayer )
{
ShaderLayer::resetAllShaders(m_shaderLayer);
GJBaseGameLayer::updateShaderLayer(a1, 0.0);
}
GJBaseGameLayer::resetGradientLayers(a1);
m_start = a1->m_gameState.m_moveEffectInstances.m_start;
m_finish = a1->m_gameState.m_moveEffectInstances.m_finish;
v34 = (__int64)m_start;
v35 = a1->m_gameState.m_dynamicMoveActions.m_start;
v36 = a1->m_gameState.m_dynamicRotateActions.m_start;
a1->m_gameState.m_advanceFollowInstances.m_finish = a1->m_gameState.m_advanceFollowInstances.m_start;
a1->m_gameState.m_dynamicMoveActions.m_finish = v35;
a1->m_gameState.m_dynamicRotateActions.m_finish = v36;
if ( m_start != m_finish )
{
do
{
v37 = *(void **)(v34 + 232);
if ( v37 )
operator delete(v37);
v38 = *(_QWORD *)(v34 + 16);
while ( v38 )
{
std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase(
v34,
*(_QWORD **)(v38 + 24));
v39 = (void *)v38;
v38 = *(_QWORD *)(v38 + 16);
operator delete(v39);
}
v34 += 264;
}
while ( m_finish != (EnterEffectInstance *)v34 );
}
v40 = a1->m_gameState.m_rotateEffectInstances.m_start;
v41 = a1->m_gameState.m_rotateEffectInstances.m_finish;
a1->m_gameState.m_moveEffectInstances.m_finish = m_start;
v42 = (__int64)v40;
if ( v40 != v41 )
{
do
{
v43 = *(void **)(v42 + 232);
if ( v43 )
operator delete(v43);
v44 = *(_QWORD *)(v42 + 16);
while ( v44 )
{
std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase(
v42,
*(_QWORD **)(v44 + 24));
v45 = (void *)v44;
v44 = *(_QWORD *)(v44 + 16);
operator delete(v45);
}
v42 += 264;
}
while ( v41 != (EnterEffectInstance *)v42 );
}
v46 = a1->m_gameState.m_scaleEffectInstances.m_start;
v47 = a1->m_gameState.m_scaleEffectInstances.m_finish;
a1->m_gameState.m_rotateEffectInstances.m_finish = v40;
v48 = (__int64)v46;
if ( v46 != v47 )
{
do
{
v49 = *(void **)(v48 + 232);
if ( v49 )
operator delete(v49);
v50 = *(_QWORD *)(v48 + 16);
while ( v50 )
{
std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase(
v48,
*(_QWORD **)(v50 + 24));
v51 = (void *)v50;
v50 = *(_QWORD *)(v50 + 16);
operator delete(v51);
}
v48 += 264;
}
while ( v47 != (EnterEffectInstance *)v48 );
}
v52 = a1->m_gameState.m_fadeEffectInstances.m_start;
v53 = a1->m_gameState.m_fadeEffectInstances.m_finish;
a1->m_gameState.m_scaleEffectInstances.m_finish = v46;
v54 = (__int64)v52;
if ( v52 != v53 )
{
do
{
v55 = *(void **)(v54 + 232);
if ( v55 )
operator delete(v55);
v56 = *(_QWORD *)(v54 + 16);
while ( v56 )
{
std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase(
v54,
*(_QWORD **)(v56 + 24));
v57 = (void *)v56;
v56 = *(_QWORD *)(v56 + 16);
operator delete(v57);
}
v54 += 264;
}
while ( v53 != (EnterEffectInstance *)v54 );
}
v58 = a1->m_gameState.m_tintEffectInstances.m_start;
v59 = a1->m_gameState.m_tintEffectInstances.m_finish;
a1->m_gameState.m_fadeEffectInstances.m_finish = v52;
v60 = (__int64)v58;
if ( v58 != v59 )
{
do
{
v61 = *(void **)(v60 + 232);
if ( v61 )
operator delete(v61);
v62 = *(_QWORD *)(v60 + 16);
while ( v62 )
{
std::_Rb_tree,std::_Select1st>,std::less,std::allocator>>::_M_erase(
v60,
*(_QWORD **)(v62 + 24));
v63 = (void *)v62;
v62 = *(_QWORD *)(v62 + 16);
operator delete(v63);
}
v60 += 264;
}
while ( v59 != (EnterEffectInstance *)v60 );
}
v64 = a1->m_gameState.m_unsortedAreaEffects._M_h._M_before_begin._M_nxt;
a1->m_gameState.m_tintEffectInstances.m_finish = v58;
if ( v64 )
{
do
{
v65 = v64->_M_nxt;
operator delete(v64);
v64 = v65;
}
while ( v65 );
}
memset(
a1->m_gameState.m_unsortedAreaEffects._M_h._M_buckets,
0,
8 * a1->m_gameState.m_unsortedAreaEffects._M_h._M_bucket_count);
a1->m_gameState.m_unsortedAreaEffects._M_h._M_before_begin._M_nxt = nullptr;
v66 = a1->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
a1->m_gameState.m_unsortedAreaEffects._M_h._M_element_count = 0;
updateTimeWarp = v66->updateTimeWarp;
a1->m_skipArtReload = 1;
updateTimeWarp(a1, 1.0);
GJBaseGameLayer::updateMGOffsetY(a1, 0.0, 0.0, 0, 0.0, -1, -1);
m_background = a1->m_background;
setPosition = m_background->setPosition;
v70 = (float *)m_background->getPosition(m_background);
cocos2d::CCPoint::CCPoint(v100, *v70, 0.0);
setPosition(m_background, v100);
GJBaseGameLayer::resetCamera(a1);
m_groundLayer = a1->m_groundLayer;
m_groundLayer2 = a1->m_groundLayer2;
v73 = m_groundLayer->cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
m_groundLayer->m_unk1cc = 0.0;
m_groundLayer2->m_unk1cc = 0.0;
v74 = v73->getScaleX(m_groundLayer);
v75 = GJGroundLayer::scaleGround(m_groundLayer, v74);
v76 = a1->m_groundLayer2;
v77 = ((float (__fastcall *)(GJGroundLayer *, float))v76->getScaleX)(v76, v75);
GJGroundLayer::scaleGround(v76, v77);
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);
GJBaseGameLayer::togglePlayerStreakBlend(a1, 1, 0);
a1->m_gameState.m_timeModRelated = 0.0;
a1->m_gameState.m_unkUint64_1 = 0.0;
cocos2d::CCPoint::operator=(&a1->m_gameState.m_unkPoint34, 0.0, v78);
v79 = a1->m_groundLayer;
a1->m_gameState.m_unkUint16 = 0.0;
GJGroundLayer::toggleVisible02(v79, 1);
GJGroundLayer::toggleVisible02(a1->m_groundLayer2, 1);
a1->m_gameState.m_unkFloat9 = 0.0;
GJGameState::stopTweenAction(&a1->m_gameState, 25);
a1->m_gameState.m_unkBool1 = 0;
a1->m_gameState.m_portalY = 0.0;
m_freezeStartCamera = a1->m_freezeStartCamera;
a1->m_gameState.m_unkBool6 = 0;
a1->m_gameState.m_unkInt12 = 0;
a1->m_unk322a = m_freezeStartCamera;
a1->m_playerDied = 0;
GJBaseGameLayer::clearPickedUpItems(a1);
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);
v81 = cocos2d::CCDirector::sharedDirector();
WinSize = cocos2d::CCDirector::getWinSize(v81);
v82 = ((__int64 (__fastcall *)(PlayerObject *, float, float))a1->m_player1->getPosition)(
a1->m_player1,
WinSize.width,
WinSize.height);
m_objectsDeactivated = a1->m_objectsDeactivated;
a1->m_gameState.m_cameraPosition.y = (float)(*(float *)(v82 + 4) - v100[0].y) + 90.0;
if ( m_objectsDeactivated )
{
v84 = a1->m_sections.m_start;
m_leftSectionIndex = a1->m_leftSectionIndex;
v99 = a1->m_sections.m_finish - v84;
if ( m_leftSectionIndex < v99 )
{
m_rightSectionIndex = a1->m_rightSectionIndex;
if ( m_leftSectionIndex <= m_rightSectionIndex )
{
v87 = m_leftSectionIndex;
v88 = v84[v87];
if ( !v88 )
goto LABEL_73;
LABEL_57:
for ( i = (unsigned __int64)((char *)v88->m_finish - (char *)v88->m_start) >> 3; ; LODWORD(i) = -1 )
{
m_bottomSectionIndex = a1->m_bottomSectionIndex;
if ( (int)i > m_bottomSectionIndex )
{
m_topSectionIndex = a1->m_topSectionIndex;
if ( m_bottomSectionIndex <= m_topSectionIndex )
{
v92 = m_bottomSectionIndex;
v93 = m_bottomSectionIndex;
while ( 1 )
{
v94 = v88->m_start[v92];
if ( v94 )
{
v95 = a1->m_sectionSizes.m_start[v87]->m_start[v93];
if ( v95 > 0 )
{
v96 = 0;
v97 = 8 * ((unsigned int)(v95 - 1) + 1LL);
do
{
v98 = v94->m_start[v96 / 8];
v96 += 8LL;
v98->deactivateObject(v98, 1);
}
while ( v96 != v97 );
m_topSectionIndex = a1->m_topSectionIndex;
}
}
++m_bottomSectionIndex;
++v92;
++v93;
if ( m_topSectionIndex < m_bottomSectionIndex || (int)i <= m_bottomSectionIndex )
break;
v88 = a1->m_sections.m_start[v87];
}
m_rightSectionIndex = a1->m_rightSectionIndex;
}
}
++m_leftSectionIndex;
++v87;
if ( m_rightSectionIndex < m_leftSectionIndex || v99 <= m_leftSectionIndex )
break;
v88 = a1->m_sections.m_start[v87];
if ( v88 )
goto LABEL_57;
LABEL_73:
;
}
}
}
}
GJBaseGameLayer::toggleDualMode(a1, nullptr, 0, nullptr, 0);
}