//
// GameManager::returnToLastScene from 0x10031d52c to 0x10031d7ec (704 bytes)
//
// 2 xrefs:
// > PlayLayer::onQuit @ 0x100119598
// > EditorPauseLayer::onExitEditor @ 0x10039e7f4
//
// 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)
{
int m_sceneEnum; // w8
cocos2d::CCDirector *v3; // x19
cocos2d::CCScene *v4; // x0
cocos2d::CCDirector *v5; // x19
SearchType v6; // w0
GameLevelManager *v7; // x19
GameLevelManager *v8; // x0
int v9; // w8
bool v10; // vf
int v11; // w8
int v12; // w19
cocos2d::CCTransitionFade *v13; // x1
cocos2d::CCDirector *v14; // x0
cocos2d::CCScene *v15; // x0
cocos2d::CCDirector *v16; // x19
cocos2d::CCScene *v17; // x0
cocos2d::CCTransitionFade *v18; // x0
GJSearchObject *v19; // x0
cocos2d::CCScene *v20; // x0
cocos2d::CCTransitionFade *v21; // x0
void **v22; // x1
cocos2d::CCScene *SearchScene; // x19
cocos2d::CCDirector *v24; // x20
cocos2d::CCScene *v25; // x0
float v26; // s0
GameLevelManager *v27; // x19
GameLevelManager *v28; // x0
void **v29; // x1
GameManager *v30; // x0
void *__p[2]; // [xsp+0h] [xbp-30h] BYREF
char *longStorage; // [xsp+10h] [xbp-20h]
m_sceneEnum = a1->m_sceneEnum;
if ( m_sceneEnum <= 7 )
{
if ( m_sceneEnum <= 2 )
{
if ( m_sceneEnum == 1 )
{
v3 = cocos2d::CCDirector::sharedDirector();
v4 = CreatorLayer::scene();
goto LABEL_22;
}
if ( m_sceneEnum != 2 )
goto LABEL_20;
v5 = cocos2d::CCDirector::sharedDirector();
v6 = MyLevels;
goto LABEL_28;
}
if ( m_sceneEnum == 3 )
{
if ( a2 )
{
if ( a2->m_levelType == Editor )
v15 = EditLevelLayer::scene(a2);
else
v15 = LevelInfoLayer::scene(a2, 0);
}
else
{
if ( a1->m_searchObjectBool )
{
a1->m_searchObjectBool = 0;
v27 = GameLevelManager::sharedState();
v28 = GameLevelManager::sharedState();
if ( v28->m_searchKey.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__p, (void *)v28->m_searchKey.m_data.m_long.capacitym1, v28->m_searchKey.m_data.m_long.size);
}
else
{
*(_OWORD *)__p = *(_OWORD *)&v28->m_searchKey.m_data.m_short.sizex2;
longStorage = v28->m_searchKey.m_data.m_long.longStorage;
}
if ( SHIBYTE(longStorage) >= 0 )
v29 = __p;
else
v29 = (void **)__p[0];
SearchScene = GameLevelManager::getSearchScene(v27, (const char *)v29);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__p[0]);
if ( SearchScene )
goto LABEL_52;
}
v15 = CreatorLayer::scene();
}
}
else
{
if ( m_sceneEnum != 7 )
goto LABEL_20;
v7 = GameLevelManager::sharedState();
v8 = GameLevelManager::sharedState();
if ( v8->m_searchKey.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__p, (void *)v8->m_searchKey.m_data.m_long.capacitym1, v8->m_searchKey.m_data.m_long.size);
}
else
{
*(_OWORD *)__p = *(_OWORD *)&v8->m_searchKey.m_data.m_short.sizex2;
longStorage = v8->m_searchKey.m_data.m_long.longStorage;
}
if ( SHIBYTE(longStorage) >= 0 )
v22 = __p;
else
v22 = (void **)__p[0];
SearchScene = GameLevelManager::getSearchScene(v7, (const char *)v22);
if ( SHIBYTE(longStorage) < 0 )
operator delete(__p[0]);
if ( SearchScene )
goto LABEL_52;
v15 = MenuLayer::scene(0);
}
SearchScene = v15;
LABEL_52:
v24 = cocos2d::CCDirector::sharedDirector();
v26 = 0.5;
v25 = SearchScene;
goto LABEL_53;
}
if ( m_sceneEnum <= 11 )
{
if ( m_sceneEnum != 9 )
goto LABEL_20;
if ( a2 )
{
v9 = a2->m_levelID.random - a2->m_levelID.seed;
v10 = __OFSUB__(v9, 1);
v11 = v9 - 1;
if ( (v11 < 0) ^ v10 | (v11 == 0) )
v12 = 0;
else
v12 = v11;
}
else
{
v12 = 0;
}
v24 = cocos2d::CCDirector::sharedDirector();
v25 = LevelSelectLayer::scene(v12);
v26 = 0.5;
LABEL_53:
v13 = cocos2d::CCTransitionFade::create_1(v26, v25);
v14 = v24;
goto LABEL_54;
}
if ( m_sceneEnum == 12 )
{
v16 = cocos2d::CCDirector::sharedDirector();
v17 = SecretLayer2::scene();
v18 = cocos2d::CCTransitionFade::create_1(0.5, v17);
cocos2d::CCDirector::replaceScene(v16, v18);
return;
}
if ( m_sceneEnum != 14 )
{
if ( m_sceneEnum == 15 )
{
v3 = cocos2d::CCDirector::sharedDirector();
v4 = LevelAreaInnerLayer::scene(1);
LABEL_22:
v13 = cocos2d::CCTransitionFade::create_1(0.5, v4);
v14 = v3;
LABEL_54:
cocos2d::CCDirector::replaceScene(v14, v13);
goto LABEL_55;
}
LABEL_20:
v3 = cocos2d::CCDirector::sharedDirector();
v4 = MenuLayer::scene(0);
goto LABEL_22;
}
v5 = cocos2d::CCDirector::sharedDirector();
v6 = MyLists;
LABEL_28:
v19 = GJSearchObject::create_2(v6);
v20 = LevelBrowserLayer::scene(v19);
v21 = cocos2d::CCTransitionFade::create_1(0.5, v20);
cocos2d::CCDirector::pushScene(v5, v21);
LABEL_55:
v30 = GameManager::sharedState();
GameManager::fadeInMenuMusic(v30);
}