//
// LevelEditorLayer::onStopPlaytest from 0x1402e0630 to 0x1402e0e22 (2034 bytes)
//
// 5 xrefs:
// > EditorUI::onPause @ 0x1400e1a49
// > EditorUI::onStopPlaytest @ 0x14011255a
// > EditorUI::keyDown @ 0x140126751
// > LevelEditorLayer::postUpdate @ 0x1402e10c0
// > ??> @ 0x1406d35c0
//
// 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=4
void LevelEditorLayer::onStopPlaytest(LevelEditorLayer *a1)
{
__int64 v2; // rax
UILayer *m_uiLayer; // rbx
cocos2d::CCArray *m_uiObjects; // r14
unsigned int v5; // r13d
cocos2d::ccArray *data; // r14
__int64 num; // rax
GameObject **arr; // r14
GameObject **i; // rbp
GameObject *v10; // rdi
GameObject_vtbl *v11; // rbx
__int64 v12; // rax
_BOOL8 v13; // rdx
std::_Simple_types::value_type *Myfirst; // rax
int v15; // ebp
__int64 v16; // rdi
std::_Simple_types::value_type v17; // rbx
__int64 v18; // rcx
cocos2d::CCDirector *v19; // rax
__int64 v20; // rcx
StartPosObject *m_startPosObject; // rcx
PlayerObject *m_player1; // rcx
cocos2d::CCSprite_vtbl *v23; // rbx
__int64 v24; // rax
_BOOL8 v25; // rdx
__int64 v26; // r8
std::_Vector_val *, std::allocator *>> *>>::pointer v27; // rdx
__int64 v28; // r12
_QWORD *p_Myfirst; // rcx
__int64 v30; // rax
__int64 v31; // r14
std::_Simple_types *>::value_type v32; // r15
__int64 v33; // rdi
__int64 v34; // rbp
std::_Simple_types::value_type v35; // rbx
__int64 v36; // r10
unsigned __int64 v37; // r9
__int64 v38; // r11
cocos2d::CCArray *m_objects; // rbp
GameObject *v40; // rdi
GameObject_vtbl *v41; // rbx
__int64 v42; // rax
std::_List_val>>>::_Nodeptr Myhead; // r14
_QWORD *j; // rbx
LabelGameObject **v45; // rdi
LabelGameObject **k; // rbp
std::_List_val>>>::_Nodeptr v47; // r14
_QWORD *m; // rbx
LabelGameObject **v49; // rdi
LabelGameObject **n; // rbp
__int64 v51; // rbx
FMODAudioEngine *v52; // rcx
EditorUI *m_editorUI; // rcx
char v54[16]; // [rsp+30h] [rbp-68h] BYREF
FMODAudioEngine *v55; // [rsp+A0h] [rbp+8h] BYREF
cocos2d::CCPoint v56; // [rsp+A8h] [rbp+10h] BYREF
cocos2d::CCPoint v57; // [rsp+B0h] [rbp+18h] BYREF
__int64 v58; // [rsp+B8h] [rbp+20h]
v2 = cocos2d::CCDirector::sharedDirector(a1);
*(_BYTE *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v2 + 176LL))(v2) + 92) = 0;
m_uiLayer = a1->m_uiLayer;
*(_QWORD *)&m_uiLayer->m_p1TouchId = -1;
*(_WORD *)&m_uiLayer->m_p1Jumping = 0;
m_uiLayer->m_checkpointBtnDown = 0;
UILayer::resetUINodeState(m_uiLayer);
UILayer::toggleMenuVisibility(m_uiLayer, 0);
m_uiLayer->setVisible(m_uiLayer, 0);
*(_BYTE *)(cocos2d::CCEGLView::sharedOpenGLView() + 237) = 0;
m_uiObjects = a1->m_uiObjects;
v5 = 0;
if ( m_uiObjects )
{
data = m_uiObjects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = (GameObject **)data->arr;
for ( i = &arr[num - 1]; arr <= i; ++arr )
{
v10 = *arr;
if ( !*arr )
break;
LODWORD(v55) = v10->m_uniqueID;
sub_14024F3B0(
&a1->m_uiObjectPositions._Traitsobj._Mypair._Myval2._Myval2,
(__int64)v54,
(unsigned __int8 *)&v55);
v11 = v10->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(&v56);
((void (__fastcall *)(GameObject *, __int64))v11->setStartPos)(v10, v12);
LOBYTE(v13) = 1;
v10->deactivateObject(v10, v13);
v10->m_outerSectionIndex = 0;
v10->m_isUIObject = 0;
a1->addToSection(a1, v10);
cocos2d::CCDictionary::setObject(a1->m_objectsToDeactivate, v10, (unsigned int)v10->m_uniqueID);
v10->m_unk3ee = 1;
}
}
}
cocos2d::CCArray::removeAllObjects(a1->m_uiObjects);
sub_14005D290(&a1->m_uiObjectPositions._Traitsobj._Mypair._Myval2._Myval2);
Myfirst = a1->m_calcCollisionBlockObjects2._Mypair._Myval2._Myfirst;
if ( Myfirst != a1->m_calcCollisionBlockObjects2._Mypair._Myval2._Mylast )
a1->m_calcCollisionBlockObjects2._Mypair._Myval2._Mylast = Myfirst;
a1->m_calcCollisionBlockObjects2Size = 0;
v15 = 0;
if ( a1->m_areaObjectsCount > 0 )
{
v16 = 0;
do
{
v17 = a1->m_areaObjects._Mypair._Myval2._Myfirst[v16];
v17->m_isDirty = 1;
*(_WORD *)&v17->m_isObjectRectDirty = 257;
if ( GJBaseGameLayer::resetAreaObjectValues(a1, v17, 0) )
a1->updateObjectSection(a1, v17);
((void (__fastcall *)(std::_Simple_types::value_type))v17->setRRotation)(v17);
((void (__fastcall *)(std::_Simple_types::value_type))v17->setRScale)(v17);
++v15;
++v16;
}
while ( v15 < a1->m_areaObjectsCount );
}
LevelEditorLayer::quickUpdateAllPositions(a1);
GJBaseGameLayer::resetLevelVariables(a1);
GJBaseGameLayer::syncBGTextures(a1);
if ( a1->m_collisionBlocksAdded )
{
a1->m_collisionBlocksAdded = 0;
GJBaseGameLayer::removeObjectFromSection(a1, a1->m_player1CollisionBlock);
GJBaseGameLayer::removeObjectFromSection(a1, a1->m_player2CollisionBlock);
}
if ( a1->m_playTestSmoothFix )
{
v19 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v18);
cocos2d::CCDirector::resetSmoothFixCounter(v19);
*(_BYTE *)(cocos2d::CCDirector::sharedDirector(v20) + 170) = 0;
}
m_startPosObject = a1->m_startPosObject;
if ( m_startPosObject )
{
cocos2d::CCObject::release(m_startPosObject);
a1->m_startPosObject = nullptr;
}
a1->m_playtestTimeWarp = 1.0;
((void (__fastcall *)(LevelEditorLayer *))a1->updateTimeWarp)(a1);
a1->m_playtestCameraZoom = 1.0;
a1->m_playbackMode = Not;
PlayerObject::releaseAllButtons(a1->m_player1);
cocos2d::CCNode::pauseSchedulerAndActions(a1->m_player1);
LevelEditorLayer::updatePreviewParticles(a1);
GJBaseGameLayer::toggleDualMode(a1, nullptr, 0, a1->m_player1, 1);
m_player1 = a1->m_player1;
if ( m_player1->m_isDead || a1->m_gameState.m_isDualMode && (m_player1 = a1->m_player2, m_player1->m_isDead) )
{
v23 = a1->m_playtestDeathSprite->__vftable;
v24 = (__int64)m_player1->getPosition_0(m_player1);
v23->setPosition_0(a1->m_playtestDeathSprite, (const cocos2d::CCPoint *)v24);
LOBYTE(v25) = 1;
a1->m_playtestDeathSprite->setVisible(a1->m_playtestDeathSprite, v25);
}
a1->m_player1->setVisible(a1->m_player1, 0);
a1->m_player2->setVisible(a1->m_player2, 0);
v26 = 0;
LODWORD(v55) = 0;
v27 = a1->m_sections._Mypair._Myval2._Myfirst;
if ( a1->m_sections._Mypair._Myval2._Mylast - v27 )
{
v28 = 0;
do
{
p_Myfirst = &v27[v28]->_Mypair._Myval2._Myfirst;
if ( p_Myfirst )
v30 = (__int64)(p_Myfirst[1] - *p_Myfirst) >> 3;
else
LODWORD(v30) = -1;
v31 = 0;
v58 = (int)v30;
if ( (int)v30 > 0 )
{
do
{
v32 = a1->m_sections._Mypair._Myval2._Myfirst[v28]->_Mypair._Myval2._Myfirst[v31];
if ( v32 )
{
v33 = 0;
v34 = a1->m_sectionSizes._Mypair._Myval2._Myfirst[v28]->_Mypair._Myval2._Myfirst[v31];
if ( v34 > 0 )
{
do
{
v35 = v32->_Mypair._Myval2._Myfirst[v33];
((void (__fastcall *)(std::_Simple_types::value_type, std::_Vector_val *, std::allocator *>> *>>::pointer, __int64))v35->updateStartValues)(
v35,
v27,
v26);
v35->resetObject(v35);
v35->getPosition_0(v35);
cocos2d::CCPoint::CCPoint(&v57);
((void (__fastcall *)(std::_Simple_types::value_type, cocos2d::CCPoint *))v35->getRealPosition)(
v35,
&v56);
if ( v57.x != v56.x || v57.y != v56.y )
v35->setPosition_0(v35, &v56);
*(_WORD *)&v35->m_isObjectRectDirty = 257;
v35->m_isDirty = 1;
++v33;
}
while ( v33 < v34 );
}
}
++v31;
}
while ( v31 < v58 );
LODWORD(v26) = (_DWORD)v55;
}
v26 = (unsigned int)(v26 + 1);
LODWORD(v55) = v26;
++v28;
v27 = a1->m_sections._Mypair._Myval2._Myfirst;
}
while ( (int)v26 < (unsigned __int64)(a1->m_sections._Mypair._Myval2._Mylast - v27) );
}
v36 = 0;
v37 = 0;
v38 = 10000;
do
{
a1->m_toggledGroupStates._Mypair._Myval2._Myfirst[v36] = 0;
a1->m_toggledGroups._Myvec._Mypair._Myval2._Myfirst[v37 >> 5] &= ~(1 << (v37 & 0x1F));
++v37;
++v36;
--v38;
}
while ( v38 );
m_objects = a1->m_objects;
if ( cocos2d::CCArray::count(m_objects) )
{
do
{
v40 = (GameObject *)cocos2d::CCArray::objectAtIndex(m_objects, v5);
v40->m_positionX = v40->m_startPosition.x;
v40->m_positionY = v40->m_startPosition.y;
v41 = v40->CCSpritePlus::cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v42 = ((__int64 (__fastcall *)(GameObject *, FMODAudioEngine **))v40->getRealPosition)(v40, &v55);
v41->setPosition_0(v40, (const cocos2d::CCPoint *)v42);
a1->updateObjectSection(a1, v40);
++v5;
}
while ( v5 < cocos2d::CCArray::count(m_objects) );
}
LevelEditorLayer::updateAnimateOnTriggerObjects(a1, 1);
GJEffectManager::reset(a1->m_effectManager);
Myhead = a1->m_labelObjects._List._Mypair._Myval2._Myhead;
for ( j = *(_QWORD **)Myhead; j != (_QWORD *)Myhead; j = (_QWORD *)*j )
{
v45 = (LabelGameObject **)j[3];
for ( k = (LabelGameObject **)j[4]; v45 != k; ++v45 )
LabelGameObject::updatePreviewLabel(*v45);
}
v47 = a1->m_timeLabelObjects._List._Mypair._Myval2._Myhead;
for ( m = *(_QWORD **)v47; m != (_QWORD *)v47; m = (_QWORD *)*m )
{
v49 = (LabelGameObject **)m[3];
for ( n = (LabelGameObject **)m[4]; v49 != n; ++v49 )
LabelGameObject::updatePreviewLabel(*v49);
}
v51 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v55 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v55);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v51 = qword_1406C2E88;
}
if ( *(_BYTE *)(v51 + 609) )
{
*(_BYTE *)(v51 + 609) = 0;
FMOD::ChannelControl::setPaused(*(FMOD::ChannelControl **)(v51 + 552), 0);
FMOD::ChannelControl::setPaused(*(FMOD::ChannelControl **)(v51 + 584), 0);
v51 = qword_1406C2E88;
}
if ( !v51 )
{
v55 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v55);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v51 = qword_1406C2E88;
}
if ( *(_QWORD *)(v51 + 552) )
FMOD::ChannelControl::stop(*(FMOD::ChannelControl **)(v51 + 552));
sub_14005E0D0((_QWORD *)(v51 + 1064));
sub_14005E0D0((_QWORD *)(v51 + 1128));
sub_14005E0D0((_QWORD *)(v51 + 1192));
v52 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v55 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v55);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v52 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::stopAllEffects(v52);
if ( a1->m_playtestOrderChanged )
a1->m_spawnOrderObjectsChanged = 1;
m_editorUI = a1->m_editorUI;
if ( m_editorUI )
EditorUI::updateSlider(m_editorUI);
a1->m_skipArtReload = 0;
}