//
// GameManager::returnToLastScene from 0x10038bf20 to 0x10038c215 (757 bytes)
//
// 5 xrefs:
// > PlayLayer::onQuit @ 0x1000b2fbc
// > EditorPauseLayer::onSaveAndExit @ 0x1002938ce
// > EditorPauseLayer::onExitNoSave @ 0x100293ad6
// > EditorPauseLayer::onExitEditor @ 0x100294e4a
// > EditorPauseLayer::FLAlert_Clicked @ 0x100294eb0
//
// 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
//
void __fastcall GameManager::returnToLastScene(GameManager *a1, GJGameLevel *a2)
{
double v2; // xmm0_8
cocos2d::CCDirector *v3; // rbx
cocos2d::CCScene *v4; // rax
cocos2d::CCDirector *v5; // rbx
SearchType v6; // edi
int v7; // eax
int v8; // ebx
cocos2d::CCDirector *v9; // rbx
cocos2d::CCScene *v10; // rax
cocos2d::CCTransitionFade *v11; // rax
GJSearchObject *v12; // rax
cocos2d::CCScene *v13; // rax
cocos2d::CCTransitionFade *v14; // rsi
GameManager *v15; // rdi
cocos2d::CCScene *v16; // rax
GameLevelManager *v17; // rbx
GameLevelManager *v18; // rax
std::string *v19; // rax
const char *v20; // rsi
cocos2d::CCTransitionFade *v21; // rax
cocos2d::CCDirector *v22; // rdi
cocos2d::CCScene *SearchScene; // rbx
cocos2d::CCDirector *v24; // r14
cocos2d::CCScene *v25; // rdi
GameLevelManager *v26; // rbx
GameLevelManager *v27; // rax
std::string *p_m_searchKey; // rax
const char *v29; // rsi
void *v30; // r14
__int128 v31; // [rsp+0h] [rbp-30h] BYREF
void *__p; // [rsp+10h] [rbp-20h]
switch ( a1->m_sceneEnum )
{
case 1:
v3 = cocos2d::CCDirector::sharedDirector();
v4 = CreatorLayer::scene();
goto LABEL_20;
case 2:
v5 = cocos2d::CCDirector::sharedDirector();
v6 = MyLevels;
goto LABEL_11;
case 3:
if ( a2 )
{
if ( a2->m_levelType == Editor )
v16 = EditLevelLayer::scene(a2);
else
v16 = LevelInfoLayer::scene(a2, 0);
goto LABEL_41;
}
if ( !a1->m_searchObjectBool )
goto LABEL_40;
a1->m_searchObjectBool = 0;
v26 = GameLevelManager::sharedState();
v27 = GameLevelManager::sharedState();
if ( (v27->m_searchKey.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&v31, v27->m_searchKey.m_data.m_long.longStorage, v27->m_searchKey.m_data.m_long.size, v2);
}
else
{
p_m_searchKey = &v27->m_searchKey;
__p = p_m_searchKey->m_data.m_long.longStorage;
v31 = *(_OWORD *)&p_m_searchKey->m_data.m_short.sizex2;
}
v29 = (v31 & 1) != 0 ? (const char *)__p : (char *)&v31 + 1;
SearchScene = GameLevelManager::getSearchScene(v26, v29);
if ( (v31 & 1) != 0 )
operator delete(__p);
if ( !SearchScene )
{
LABEL_40:
v16 = CreatorLayer::scene();
goto LABEL_41;
}
goto LABEL_42;
case 7:
v17 = GameLevelManager::sharedState();
v18 = GameLevelManager::sharedState();
if ( (v18->m_searchKey.m_data.m_short.sizex2 & 1) != 0 )
{
sub_100006B70(&v31, v18->m_searchKey.m_data.m_long.longStorage, v18->m_searchKey.m_data.m_long.size, v2);
if ( (v31 & 1) == 0 )
goto LABEL_18;
}
else
{
v19 = &v18->m_searchKey;
__p = v19->m_data.m_long.longStorage;
v31 = *(_OWORD *)&v19->m_data.m_short.sizex2;
if ( (v31 & 1) == 0 )
{
LABEL_18:
v20 = (char *)&v31 + 1;
goto LABEL_23;
}
}
v20 = (const char *)__p;
LABEL_23:
SearchScene = GameLevelManager::getSearchScene(v17, v20);
if ( (v31 & 1) != 0 )
operator delete(__p);
if ( !SearchScene )
{
v16 = MenuLayer::scene(0);
LABEL_41:
SearchScene = v16;
}
LABEL_42:
v24 = cocos2d::CCDirector::sharedDirector();
v25 = SearchScene;
LABEL_43:
v21 = cocos2d::CCTransitionFade::create_1(0.5, v25);
v22 = v24;
LABEL_44:
cocos2d::CCDirector::replaceScene(v22, v21);
v15 = (GameManager *)qword_1009A0E18;
if ( !qword_1009A0E18 )
{
LABEL_45:
v30 = operator new(0x638u);
sub_10038CE40(v30);
qword_1009A0E18 = (__int64)v30;
(*(void (__fastcall **)(void *))(*(_QWORD *)v30 + 80LL))(v30);
v15 = (GameManager *)qword_1009A0E18;
}
LABEL_46:
GameManager::fadeInMenuMusic(v15);
return;
case 9:
if ( a2 )
{
v7 = a2->m_levelID.random - a2->m_levelID.seed;
v8 = 0;
if ( v7 >= 2 )
v8 = v7 - 1;
}
else
{
v8 = 0;
}
v24 = cocos2d::CCDirector::sharedDirector();
v25 = LevelSelectLayer::scene(v8);
goto LABEL_43;
case 0xC:
v9 = cocos2d::CCDirector::sharedDirector();
v10 = SecretLayer2::scene();
v11 = cocos2d::CCTransitionFade::create_1(0.5, v10);
cocos2d::CCDirector::replaceScene(v9, v11);
return;
case 0xE:
v5 = cocos2d::CCDirector::sharedDirector();
v6 = MyLists;
LABEL_11:
v12 = GJSearchObject::create_2(v6);
v13 = LevelBrowserLayer::scene(v12);
v14 = cocos2d::CCTransitionFade::create_1(0.5, v13);
cocos2d::CCDirector::pushScene(v5, v14);
v15 = (GameManager *)qword_1009A0E18;
if ( !qword_1009A0E18 )
goto LABEL_45;
goto LABEL_46;
case 0xF:
v3 = cocos2d::CCDirector::sharedDirector();
v4 = LevelAreaInnerLayer::scene(1);
goto LABEL_20;
default:
v3 = cocos2d::CCDirector::sharedDirector();
v4 = MenuLayer::scene(0);
LABEL_20:
v21 = cocos2d::CCTransitionFade::create_1(0.5, v4);
v22 = v3;
goto LABEL_44;
}
}