//
// GameStatsManager::trySelectActivePath from 0x1401d4660 to 0x1401d47df (383 bytes)
//
// 4 xrefs:
// > GameStatsManager::incrementStat @ 0x1401d45c3
// > GJPathsLayer::init @ 0x140284ca9
// > GJPathPage::init @ 0x140286f53
// > ??> @ 0x1406cc360
//
// 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
//
// Hidden C++ exception states: #wind=3
void GameStatsManager::trySelectActivePath(GameStatsManager *a1)
{
GameStatsManager *m_activePath; // rcx
int v3; // ebx
const char *v4; // rax
int Stat; // ebx
int v6; // edi
const char *v7; // rax
int v8; // ebx
void *v9; // [rsp+20h] [rbp-38h]
void *v10; // [rsp+20h] [rbp-38h]
_QWORD v11[4]; // [rsp+28h] [rbp-30h] BYREF
m_activePath = (GameStatsManager *)(unsigned int)a1->m_activePath;
if ( (unsigned int)((_DWORD)m_activePath - 30) > 9 )
goto LABEL_8;
a1->m_activePath = (int)m_activePath;
v3 = (_DWORD)m_activePath - 24;
if ( !qword_1406C2EE8 )
{
v9 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v9);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
}
if ( !GameStatsManager::isItemUnlocked(m_activePath, GJItem, v3) )
goto LABEL_8;
v4 = (const char *)GameToolbox::intToString(v11, a1->m_activePath);
if ( *((_QWORD *)v4 + 3) > 0xFu )
v4 = *(const char **)v4;
Stat = GameStatsManager::getStat(a1, v4);
sub_14003A830((__int64)v11);
if ( Stat >= 1000 )
LABEL_8:
a1->m_activePath = 0;
if ( !a1->m_activePath )
{
v6 = 30;
while ( 1 )
{
if ( !qword_1406C2EE8 )
{
v10 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v10);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
}
if ( GameStatsManager::isItemUnlocked(m_activePath, GJItem, v6 - 24) )
{
v7 = (const char *)GameToolbox::intToString(v11, v6);
if ( *((_QWORD *)v7 + 3) > 0xFu )
v7 = *(const char **)v7;
v8 = GameStatsManager::getStat(a1, v7);
sub_14003A830((__int64)v11);
if ( v8 < 1000 )
break;
}
if ( ++v6 > 39 )
return;
}
a1->m_activePath = v6;
}
}