//
// PlayLayer::onQuit from 0x1403babb0 to 0x1403bada8 (504 bytes)
//
// 7 xrefs:
// > EndLevelLayer::onMenu @ 0x140135134
// > PauseLayer::onQuit @ 0x14037ec46
// > PlayLayer::setupHasCompleted @ 0x1403a77a5
// > PlayLayer::levelComplete @ 0x1403a88b2
// > RetryLevelLayer::onMenu @ 0x1403cbedb
// > PlayLayer::setupHasCompleted @ 0x1403a7712
// > ??> @ 0x1406d7118
//
// 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=5
void PlayLayer::onQuit(PlayLayer *a1)
{
__int64 v2; // rax
__int64 v3; // rcx
__int64 v4; // rcx
__int64 v5; // rax
GameManager *v6; // rcx
__int64 v7; // rcx
cocos2d::CCEGLView *v8; // rax
GJBaseGameLayer *v9; // rcx
FMODAudioEngine *v10; // rcx
GameManager *v11; // rcx
GameManager *v12; // rcx
void *v13; // [rsp+30h] [rbp+8h]
void *v14; // [rsp+30h] [rbp+8h]
FMODAudioEngine *v15; // [rsp+30h] [rbp+8h]
void *v16; // [rsp+30h] [rbp+8h]
void *v17; // [rsp+30h] [rbp+8h]
v2 = cocos2d::CCDirector::sharedDirector(a1);
*(_DWORD *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v2 + 112LL))(v2) + 56) = 1065353216;
*(_BYTE *)(cocos2d::CCDirector::sharedDirector(v3) + 170) = 0;
v5 = qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v13 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v13);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v5 = qword_1406C2ED8;
}
if ( *(_BYTE *)(v5 + 1008) )
{
*(_BYTE *)(v5 + 1008) = 0;
if ( *(int *)(cocos2d::CCDirector::sharedDirector(v4) + 172) >= 10 )
{
v6 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v14 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v14);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v6 = (GameManager *)qword_1406C2ED8;
}
GameManager::setGameVariable(v6, "0023", 0);
}
}
*(_BYTE *)(cocos2d::CCEGLView::sharedOpenGLView(v4) + 237) = 0;
v8 = (cocos2d::CCEGLView *)cocos2d::CCEGLView::sharedOpenGLView(v7);
cocos2d::CCEGLView::showCursor(v8, 1);
a1->m_uiLayer->m_pauseBtn->setEnabled(a1->m_uiLayer->m_pauseBtn, 0);
cocos2d::CCNode::stopActionByTag(a1, 31);
cocos2d::CCNode::stopAllActions(a1);
cocos2d::CCNode::unscheduleAllSelectors(a1);
GJBaseGameLayer::resetAudio(v9);
v10 = (FMODAudioEngine *)qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v15 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v15);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v10 = (FMODAudioEngine *)qword_1406C2E88;
}
FMODAudioEngine::unloadAllEffects(v10);
v11 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v16 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v16);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v11 = (GameManager *)qword_1406C2ED8;
}
GameManager::returnToLastScene(v11, a1->m_level);
v12 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v17 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v12 = (GameManager *)qword_1406C2ED8;
}
GameManager::fadeInMenuMusic(v12);
}