//
// GameManager::returnToLastScene from 0x1402872f0 to 0x14028767c (908 bytes)
//
// 3 xrefs:
// > EditorPauseLayer::onExitEditor @ 0x140182c79
// > PlayLayer::onQuit @ 0x14051b2de
// > ??> @ 0x14091d120
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:29:02 +0000
//
// Hidden C++ exception states: #wind=6
char __fastcall GameManager::returnToLastScene(__int64 a1, _DWORD *a2)
{
struct cocos2d::CCScene *v2; // rbx
__int64 v3; // rax
int v4; // ecx
__int64 v5; // rax
struct cocos2d::CCScene *v6; // rax
struct cocos2d::CCScene *v7; // rbx
__int64 v8; // rcx
cocos2d::CCDirector *v9; // rax
int v10; // eax
struct cocos2d::CCScene *v11; // rax
struct cocos2d::CCScene *v12; // rbx
__int64 v13; // rcx
cocos2d::CCDirector *v14; // rax
__int64 v16; // rdx
_BYTE *v17; // rdi
__int64 v18; // rax
struct cocos2d::CCScene *v19; // rdx
__int64 v20; // rdx
_BYTE *v21; // rcx
__int64 v22; // rax
struct cocos2d::CCScene *v23; // rbx
__int64 v24; // rcx
cocos2d::CCDirector *v25; // rax
__int64 v26; // rcx
void *v27; // [rsp+20h] [rbp-38h]
void *v28; // [rsp+20h] [rbp-38h]
void *v29; // [rsp+20h] [rbp-38h]
void *v30; // [rsp+20h] [rbp-38h]
void *v31; // [rsp+20h] [rbp-38h]
_QWORD v32[3]; // [rsp+28h] [rbp-30h] BYREF
unsigned __int64 v33; // [rsp+40h] [rbp-18h]
v2 = nullptr;
switch ( *(_DWORD *)(a1 + 740) )
{
case 1:
v3 = (__int64)CreatorLayer::scene();
goto LABEL_40;
case 2:
v4 = 98;
goto LABEL_4;
case 3:
if ( a2 )
{
if ( a2[305] == 2 )
v3 = EditLevelLayer::scene((__int64)a2, (__int64)a2, (__int64)a2, 0x140000000LL);
else
v3 = LevelInfoLayer::scene(a2, a2);
LABEL_40:
v19 = (struct cocos2d::CCScene *)v3;
}
else
{
if ( !*(_BYTE *)(a1 + 744) )
goto LABEL_27;
*(_BYTE *)(a1 + 744) = 0;
v16 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v27 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v27);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v16 = *(_QWORD *)&qword_14090BFB0;
}
sub_14003F4F0((__int64)v32, v16 + 1272);
v17 = v32;
if ( v33 > 0xF )
v17 = (_BYTE *)v32[0];
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v28 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v28);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
}
v18 = GJSearchObject::createFromKey(v17);
if ( v18 )
v2 = (struct cocos2d::CCScene *)LevelBrowserLayer::scene(v18);
sub_14003D310((__int64)v32);
if ( !v2 )
LABEL_27:
v2 = (struct cocos2d::CCScene *)CreatorLayer::scene();
LABEL_28:
v19 = v2;
}
LABEL_41:
v23 = cocos2d::CCTransitionFade::create(0.5, v19);
v25 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v24);
cocos2d::CCDirector::replaceScene(v25, v23);
LABEL_42:
v26 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v31 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager((__int64)v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v26 = qword_14090BFD0;
}
return GameManager::fadeInMenuMusic(v26);
case 7:
v20 = *(_QWORD *)&qword_14090BFB0;
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v29 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v29);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
v20 = *(_QWORD *)&qword_14090BFB0;
}
sub_14003F4F0((__int64)v32, v20 + 1272);
if ( !*(_QWORD *)&qword_14090BFB0 )
{
v30 = operator new(0x690u);
*(_QWORD *)&qword_14090BFB0 = GameLevelManager::GameLevelManager((__int64)v30);
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)&qword_14090BFB0 + 72LL))(*(_QWORD *)&qword_14090BFB0);
}
v21 = v32;
if ( v33 > 0xF )
v21 = (_BYTE *)v32[0];
v22 = GJSearchObject::createFromKey(v21);
if ( v22 )
v2 = (struct cocos2d::CCScene *)LevelBrowserLayer::scene(v22);
sub_14003D310((__int64)v32);
if ( v2 )
goto LABEL_28;
v19 = (struct cocos2d::CCScene *)MenuLayer::scene(0);
goto LABEL_41;
case 9:
if ( a2 )
{
v10 = a2[82] - a2[83] - 1;
if ( v10 < 0 )
v10 = 0;
LODWORD(v2) = v10;
}
v3 = LevelSelectLayer::scene((unsigned int)v2, a2, a2);
goto LABEL_40;
case 0xC:
v11 = (struct cocos2d::CCScene *)SecretLayer2::scene(a1, a2, a2);
v12 = cocos2d::CCTransitionFade::create(0.5, v11);
v14 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v13);
return cocos2d::CCDirector::replaceScene(v14, v12);
case 0xE:
v4 = 102;
LABEL_4:
v5 = GJSearchObject::create_2(v4);
v6 = (struct cocos2d::CCScene *)LevelBrowserLayer::scene(v5);
v7 = cocos2d::CCTransitionFade::create(0.5, v6);
v9 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v8);
cocos2d::CCDirector::pushScene(v9, v7);
goto LABEL_42;
case 0xF:
LOBYTE(a1) = 1;
v3 = LevelAreaInnerLayer::scene(a1, a2, a2);
goto LABEL_40;
default:
v3 = MenuLayer::scene(0);
goto LABEL_40;
}
}