//
// GJPathPage::onUnlock from 0x140287480 to 0x14028765e (478 bytes)
//
// 2 xrefs:
// > GJPathPage::init @ 0x140286b34
// > ??> @ 0x1406d15a4
//
// 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=4
void GJPathPage::onUnlock(GJPathPage *a1, cocos2d::CCObject *a2)
{
int m_pathNumber; // ebx
__int64 v4; // rdi
_QWORD *ItemKey; // rax
__int64 v6; // rbx
__int16 *v7; // rdx
size_t v8; // r8
void **v9; // rbp
GameStatsManager *v10; // rcx
int v11; // edi
int Stat; // ebp
void *v13; // rcx
PurchaseItemPopup *v14; // rax
void *v15; // [rsp+20h] [rbp-58h]
void *v16; // [rsp+20h] [rbp-58h]
void *Block[2]; // [rsp+28h] [rbp-50h] BYREF
__int64 v18; // [rsp+38h] [rbp-40h]
unsigned __int64 v19; // [rsp+40h] [rbp-38h]
_QWORD v20[4]; // [rsp+48h] [rbp-30h] BYREF
m_pathNumber = a1->m_pathNumber;
v4 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v15 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v15);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v4 = qword_1406C2EE8;
}
ItemKey = GameStatsManager::getItemKey((__int64)a1, v20, m_pathNumber + 5, 0xCu);
v6 = cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v4 + 336), ItemKey);
sub_14003A830((__int64)v20);
v7 = (__int16 *)"14";
if ( *(_DWORD *)(v6 + 368) == 4 )
v7 = &word_14055A524;
*(_OWORD *)Block = 0;
v18 = 0;
v19 = 0;
v8 = -1;
do
++v8;
while ( *((_BYTE *)v7 + v8) );
sub_14003A930(Block, v7, v8);
v9 = Block;
if ( v19 > 0xF )
v9 = (void **)Block[0];
v10 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v16 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v16);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v10 = (GameStatsManager *)qword_1406C2EE8;
}
v11 = *(_DWORD *)(v6 + 356) - *(_DWORD *)(v6 + 360);
Stat = GameStatsManager::getStat(v10, (const char *)v9);
if ( v19 > 0xF )
{
v13 = Block[0];
if ( v19 + 1 >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v13);
}
if ( v11 <= Stat )
{
v14 = PurchaseItemPopup::create((GJStoreItem *)v6);
v14->m_delegate = &a1->GJPurchaseDelegate;
v14->show(v14);
}
else
{
GJPathPage::showCantAffordMessage(a1, (GJStoreItem *)v6);
}
}