//
// GJPathPage::onUnlock from 0x140395260 to 0x14039545c (508 bytes)
//
// 2 xrefs:
// > GJPathPage::init @ 0x140394899
// > ??> @ 0x1409230cc
//
// 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:31:13 +0000
//
// Hidden C++ exception states: #wind=4
__int64 __fastcall GJPathPage::onUnlock(__int64 a1)
{
int v2; // edi
__int64 v3; // rsi
_QWORD *ItemKey; // rax
_DWORD *v5; // rsi
int v6; // ebp
__int16 *v7; // rdx
size_t v8; // r8
void **v9; // rdi
__int64 v10; // rcx
int Stat; // edi
void *v12; // r8
_QWORD *v14; // rax
void *v15; // [rsp+30h] [rbp-68h]
void *v16; // [rsp+30h] [rbp-68h]
void *Block[2]; // [rsp+38h] [rbp-60h] BYREF
__int64 v18; // [rsp+48h] [rbp-50h]
unsigned __int64 v19; // [rsp+50h] [rbp-48h]
_QWORD v20[4]; // [rsp+58h] [rbp-40h] BYREF
v2 = *(_DWORD *)(a1 + 688);
v3 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v15 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v15);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v3 = qword_14090BFE0;
}
ItemKey = GameStatsManager::getItemKey(a1, v20, v2 + 5, 0xCu);
v5 = (_DWORD *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(v3 + 336), ItemKey);
sub_14003D310((__int64)v20);
v6 = v5[89] - v5[90];
v7 = &word_140737D98;
if ( v5[92] == 4 )
v7 = &word_14075A858;
*(_OWORD *)Block = 0;
v18 = 0;
v19 = 0;
v8 = -1;
do
++v8;
while ( *((_BYTE *)v7 + v8) );
sub_14003D230(Block, v7, v8);
v9 = Block;
if ( v19 > 0xF )
v9 = (void **)Block[0];
v10 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v16 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v16);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v10 = qword_14090BFE0;
}
Stat = GameStatsManager::getStat(v10, v9);
if ( v19 > 0xF )
{
v12 = Block[0];
if ( v19 + 1 >= 0x1000 )
{
v12 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v12 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v12);
}
if ( v6 > Stat )
return GJPathPage::showCantAffordMessage(a1, v5);
v14 = (_QWORD *)PurchaseItemPopup::create(v5);
v14[84] = a1 + 672;
return (*(__int64 (__fastcall **)(_QWORD *))(*v14 + 1064LL))(v14);
}