//
// GameManager::returnToLastScene from 0x100376970 to 0x100376c65 (757 bytes)
//
// 5 xrefs:
// > PlayLayer::onQuit @ 0x100080525
// > EditorPauseLayer::onSaveAndExit @ 0x10027e3fa
// > EditorPauseLayer::onExitNoSave @ 0x10027e614
// > EditorPauseLayer::onExitEditor @ 0x10027f458
// > EditorPauseLayer::FLAlert_Clicked @ 0x10027f4de
//
// 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 12:29:04 +0000
//
void __fastcall GameManager::returnToLastScene(_BYTE *a1, _DWORD *a2, double a3)
{
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // rdi
int v7; // eax
unsigned int v8; // ebx
__int64 v9; // rbx
__int64 v10; // rax
char *v11; // rax
__int64 v12; // rax
__int64 v13; // rax
char *v14; // rsi
__int64 v15; // rdi
__int64 v16; // rax
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rax
char *v20; // rax
__int64 v21; // rdi
__int64 SearchScene; // rbx
__int64 v23; // r14
__int64 v24; // rdi
__int64 v25; // rbx
__int64 v26; // rax
__int64 v27; // rax
void *v28; // r14
__int128 v29; // [rsp+0h] [rbp-30h] BYREF
void *__p; // [rsp+10h] [rbp-20h]
switch ( *((_DWORD *)a1 + 177) )
{
case 1:
v3 = cocos2d::CCDirector::sharedDirector(a1, a2);
v4 = (__int64)CreatorLayer::scene((__int64)a1, (__int64)a2);
goto LABEL_20;
case 2:
v5 = cocos2d::CCDirector::sharedDirector(a1, a2);
v6 = 98;
goto LABEL_11;
case 3:
if ( a2 )
{
a1 = a2;
if ( a2[285] == 2 )
{
v16 = EditLevelLayer::scene((__int64)a2, (__int64)a2);
}
else
{
a2 = nullptr;
v16 = (__int64)LevelInfoLayer::scene((__int64)a1, 0);
}
goto LABEL_41;
}
if ( a1[712] != 1 )
goto LABEL_40;
a1[712] = 0;
v25 = GameLevelManager::sharedState(a3);
v26 = GameLevelManager::sharedState(a3);
if ( (*(_BYTE *)(v26 + 1160) & 1) != 0 )
{
sub_10001AD30(&v29, *(const void **)(v26 + 1176), *(_QWORD *)(v26 + 1168));
}
else
{
v27 = v26 + 1160;
__p = *(void **)(v27 + 16);
v29 = *(_OWORD *)v27;
}
a2 = (v29 & 1) != 0 ? __p : (_DWORD *)((char *)&v29 + 1);
a1 = (_BYTE *)v25;
SearchScene = GameLevelManager::getSearchScene(v25, a2);
if ( (v29 & 1) != 0 )
{
a1 = __p;
operator delete(__p);
}
if ( !SearchScene )
{
LABEL_40:
v16 = (__int64)CreatorLayer::scene((__int64)a1, (__int64)a2);
goto LABEL_41;
}
goto LABEL_42;
case 7:
v17 = GameLevelManager::sharedState(a3);
v18 = GameLevelManager::sharedState(a3);
if ( (*(_BYTE *)(v18 + 1160) & 1) != 0 )
{
sub_10001AD30(&v29, *(const void **)(v18 + 1176), *(_QWORD *)(v18 + 1168));
if ( (v29 & 1) == 0 )
goto LABEL_18;
}
else
{
v19 = v18 + 1160;
__p = *(void **)(v19 + 16);
v29 = *(_OWORD *)v19;
if ( (v29 & 1) == 0 )
{
LABEL_18:
a2 = (_DWORD *)((char *)&v29 + 1);
goto LABEL_23;
}
}
a2 = __p;
LABEL_23:
a1 = (_BYTE *)v17;
SearchScene = GameLevelManager::getSearchScene(v17, a2);
if ( (v29 & 1) != 0 )
{
a1 = __p;
operator delete(__p);
}
if ( !SearchScene )
{
a1 = nullptr;
v16 = MenuLayer::scene(0);
LABEL_41:
SearchScene = v16;
}
LABEL_42:
v23 = cocos2d::CCDirector::sharedDirector(a1, a2);
v24 = SearchScene;
LABEL_43:
v20 = cocos2d::CCTransitionFade::create_1(v24, 0.5);
v21 = v23;
LABEL_44:
cocos2d::CCDirector::replaceScene(v21, v20);
v15 = qword_100BE3098;
if ( !qword_100BE3098 )
{
LABEL_45:
v28 = operator new(0x6B8u);
sub_100377960(v28);
qword_100BE3098 = (__int64)v28;
(*(void (__fastcall **)(void *))(*(_QWORD *)v28 + 80LL))(v28);
v15 = qword_100BE3098;
}
LABEL_46:
GameManager::fadeInMenuMusic(v15, COERCE_DOUBLE(1056964608));
return;
case 9:
if ( a2 )
{
v7 = a2[82] - a2[83];
v8 = 0;
if ( v7 >= 2 )
v8 = v7 - 1;
}
else
{
v8 = 0;
}
v23 = cocos2d::CCDirector::sharedDirector(a1, a2);
v24 = LevelSelectLayer::scene(v8);
goto LABEL_43;
case 0xC:
v9 = cocos2d::CCDirector::sharedDirector(a1, a2);
v10 = SecretLayer2::scene();
v11 = cocos2d::CCTransitionFade::create_1(v10, 0.5);
cocos2d::CCDirector::replaceScene(v9, v11);
return;
case 0xE:
v5 = cocos2d::CCDirector::sharedDirector(a1, a2);
v6 = 102;
LABEL_11:
v12 = GJSearchObject::create_2(v6);
v13 = LevelBrowserLayer::scene(v12);
v14 = cocos2d::CCTransitionFade::create_1(v13, 0.5);
cocos2d::CCDirector::pushScene(v5, v14);
v15 = qword_100BE3098;
if ( !qword_100BE3098 )
goto LABEL_45;
goto LABEL_46;
case 0xF:
v3 = cocos2d::CCDirector::sharedDirector(a1, a2);
v4 = LevelAreaInnerLayer::scene(1, (__int64)a2);
goto LABEL_20;
default:
v3 = cocos2d::CCDirector::sharedDirector(a1, a2);
v4 = MenuLayer::scene(0);
LABEL_20:
v20 = cocos2d::CCTransitionFade::create_1(v4, 0.5);
v21 = v3;
goto LABEL_44;
}
}