//
// GameLevelManager::gotoLevelPage from 0x140221390 to 0x140221576 (486 bytes)
//
// 4 xrefs:
// > LevelCell::onClick @ 0x14014d460
// > LevelCell::onClick @ 0x14014d4bd
// > GauntletLayer::onLevel @ 0x1402fcbfa
// > ??> @ 0x14091bba8
//
// 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:28:24 +0000
//
// Hidden C++ exception states: #wind=1
char __fastcall GameLevelManager::gotoLevelPage(_QWORD *a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 v4; // rbx
__int64 v6; // rax
struct cocos2d::CCScene *v7; // rax
struct cocos2d::CCScene *v8; // rbx
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
__int64 SavedGauntletLevel; // rax
_DWORD *v12; // rdi
_DWORD *v13; // rsi
struct cocos2d::CCScene *v14; // rax
struct cocos2d::CCScene *v15; // rbx
__int64 v16; // rcx
cocos2d::CCDirector *v17; // rax
struct cocos2d::CCScene *v18; // rax
struct cocos2d::CCScene *v19; // rbx
__int64 v20; // rcx
cocos2d::CCDirector *v21; // rax
void *v23; // [rsp+38h] [rbp+10h]
v4 = a2;
v6 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v23 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v23);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v6 = qword_14090BFD0;
}
*(_BYTE *)(v6 + 744) = 1;
if ( v4 )
{
LODWORD(v6) = *(_DWORD *)(v4 + 1220);
if ( (_DWORD)v6 != 2 )
{
if ( (_DWORD)v6 != 3 )
{
if ( (_DWORD)v6 != 4 )
return v6;
if ( *(_DWORD *)(v4 + 992) - *(_DWORD *)(v4 + 996) <= 0 )
{
v12 = (_DWORD *)(v4 + 332);
v13 = (_DWORD *)(v4 + 328);
if ( *(_BYTE *)(v4 + 721) )
SavedGauntletLevel = GameLevelManager::getSavedGauntletLevel((__int64)a1);
else
SavedGauntletLevel = GameLevelManager::getSavedLevel((__int64)a1);
}
else
{
SavedGauntletLevel = GameLevelManager::getSavedDailyLevel((__int64)a1);
v12 = (_DWORD *)(v4 + 332);
v13 = (_DWORD *)(v4 + 328);
}
if ( SavedGauntletLevel
&& (*(_DWORD *)(v4 + 992) - *(_DWORD *)(v4 + 996) <= 0
|| *(_DWORD *)(SavedGauntletLevel + 328) - *(_DWORD *)(SavedGauntletLevel + 332) == *v13 - *v12) )
{
if ( *(_BYTE *)(SavedGauntletLevel + 1185) )
{
GameLevelManager::saveLevel(a1, v4);
}
else if ( *(_DWORD *)(SavedGauntletLevel + 860) >= *(_DWORD *)(v4 + 860) )
{
*(_DWORD *)(SavedGauntletLevel + 680) = *(_DWORD *)(v4 + 680);
v4 = SavedGauntletLevel;
}
}
if ( *(_BYTE *)(v4 + 721) )
{
v14 = (struct cocos2d::CCScene *)LevelInfoLayer::scene(v4, 0);
v15 = cocos2d::CCTransitionFade::create(0.5, v14);
v17 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v16);
LOBYTE(v6) = cocos2d::CCDirector::replaceScene(v17, v15);
return v6;
}
}
v18 = (struct cocos2d::CCScene *)LevelInfoLayer::scene(v4, 0);
v19 = cocos2d::CCTransitionFade::create(0.5, v18);
v21 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v20);
LOBYTE(v6) = cocos2d::CCDirector::pushScene(v21, v19);
return v6;
}
v7 = (struct cocos2d::CCScene *)EditLevelLayer::scene(v4, a2, a3, a4);
v8 = cocos2d::CCTransitionFade::create(0.5, v7);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
LOBYTE(v6) = cocos2d::CCDirector::replaceScene(v10, v8);
}
return v6;
}