//
// GameManager::returnToLastScene from 0x140189fb0 to 0x14018a360 (944 bytes)
//
// 3 xrefs:
// > EditorPauseLayer::onExitEditor @ 0x1400de369
// > PlayLayer::onQuit @ 0x1403bad5e
// > ??> @ 0x1406cb6ac
//
// 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=6
void GameManager::returnToLastScene(GameManager *a1, GJGameLevel *a2)
{
cocos2d::CCScene *v3; // rbx
cocos2d::CCScene *v4; // rax
SearchType v5; // ecx
GJSearchObject *v6; // rax
struct cocos2d::CCScene *v7; // rax
struct cocos2d::CCTransitionFade *v8; // rbx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
int v11; // eax
struct cocos2d::CCScene *v12; // rax
struct cocos2d::CCTransitionFade *v13; // rbx
__int64 v14; // rcx
cocos2d::CCDirector *v15; // rax
struct cocos2d::CCScene *v16; // rdx
__int64 v17; // rbx
__int64 v18; // rdx
__int64 v19; // rcx
LevelInfoLayer *v20; // rax
__int64 v21; // rdx
const char *v22; // rdi
GJSearchObject *v23; // rax
__int64 v24; // rdx
const char *v25; // rcx
GJSearchObject *v26; // rax
struct cocos2d::CCTransitionFade *v27; // rbx
__int64 v28; // rcx
cocos2d::CCDirector *v29; // rax
GameManager *v30; // rcx
void *v31; // [rsp+20h] [rbp-38h]
void *v32; // [rsp+20h] [rbp-38h]
void *v33; // [rsp+20h] [rbp-38h]
void *v34; // [rsp+20h] [rbp-38h]
void *v35; // [rsp+20h] [rbp-38h]
_QWORD v36[3]; // [rsp+28h] [rbp-30h] BYREF
unsigned __int64 v37; // [rsp+40h] [rbp-18h]
v3 = nullptr;
switch ( a1->m_sceneEnum )
{
case 1:
v4 = CreatorLayer::scene();
goto LABEL_40;
case 2:
v5 = MyLevels;
goto LABEL_4;
case 3:
if ( a2 )
{
if ( a2->m_levelType == Editor )
{
v16 = EditLevelLayer::scene(a2);
}
else
{
v17 = cocos2d::CCScene::create(a1);
*(_QWORD *)(cocos2d::CCApplication::sharedApplication(v19, v18) + 224) = v17;
v20 = LevelInfoLayer::create(a2, 0);
(*(void (__fastcall **)(__int64, LevelInfoLayer *))(*(_QWORD *)v17 + 448LL))(v17, v20);
v16 = (struct cocos2d::CCScene *)v17;
}
}
else
{
if ( !a1->m_searchObjectBool )
goto LABEL_27;
a1->m_searchObjectBool = 0;
v21 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v31 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v21 = qword_1406C2EC0;
}
sub_14003BDB0((__int64)v36, v21 + 640);
v22 = (const char *)v36;
if ( v37 > 0xF )
v22 = (const char *)v36[0];
if ( !qword_1406C2EC0 )
{
v32 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v32);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
v23 = GJSearchObject::createFromKey(v22);
if ( v23 )
v3 = LevelBrowserLayer::scene(v23);
sub_14003A830((__int64)v36);
if ( !v3 )
LABEL_27:
v3 = CreatorLayer::scene();
LABEL_28:
v16 = v3;
}
goto LABEL_41;
case 7:
v24 = qword_1406C2EC0;
if ( !qword_1406C2EC0 )
{
v33 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v33);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
v24 = qword_1406C2EC0;
}
sub_14003BDB0((__int64)v36, v24 + 640);
if ( !qword_1406C2EC0 )
{
v34 = operator new(0x3D0u);
qword_1406C2EC0 = sub_140141280((__int64)v34);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EC0 + 72LL))(qword_1406C2EC0);
}
v25 = (const char *)v36;
if ( v37 > 0xF )
v25 = (const char *)v36[0];
v26 = GJSearchObject::createFromKey(v25);
if ( v26 )
v3 = LevelBrowserLayer::scene(v26);
sub_14003A830((__int64)v36);
if ( v3 )
goto LABEL_28;
v16 = MenuLayer::scene(0);
goto LABEL_41;
case 9:
if ( a2 )
{
v11 = a2->m_levelID.random - a2->m_levelID.seed - 1;
if ( v11 < 0 )
v11 = 0;
LODWORD(v3) = v11;
}
v4 = LevelSelectLayer::scene((int)v3);
goto LABEL_40;
case 0xC:
v12 = SecretLayer2::scene();
v13 = cocos2d::CCTransitionFade::create(0.5, v12);
v15 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v14);
cocos2d::CCDirector::replaceScene(v15, v13);
return;
case 0xE:
v5 = MyLists;
LABEL_4:
v6 = GJSearchObject::create_2(v5);
v7 = LevelBrowserLayer::scene(v6);
v8 = cocos2d::CCTransitionFade::create(0.5, v7);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::pushScene(v10, v8);
goto LABEL_42;
case 0xF:
v4 = LevelAreaInnerLayer::scene(1);
goto LABEL_40;
default:
v4 = MenuLayer::scene(0);
LABEL_40:
v16 = v4;
LABEL_41:
v27 = cocos2d::CCTransitionFade::create(0.5, v16);
v29 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v28);
cocos2d::CCDirector::replaceScene(v29, v27);
LABEL_42:
v30 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v35 = operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00((__int64)v35);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v30 = (GameManager *)qword_1406C2ED8;
}
GameManager::fadeInMenuMusic(v30);
return;
}
}