//
// GJShopLayer::onSelectItem from 0x1403b2040 to 0x1403b2279 (569 bytes)
//
// 2 xrefs:
// > GJShopLayer::init @ 0x1403b15b7
// > ??> @ 0x140923c00
//
// 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:23 +0000
//
// Hidden C++ exception states: #wind=4
void __fastcall GJShopLayer::onSelectItem(__int64 a1, __int64 a2)
{
__int64 v3; // rdi
__int64 v4; // rcx
__int64 v5; // rcx
struct cocos2d::CCObject *v6; // rdi
int v7; // ebp
__int16 *v8; // rdx
size_t v9; // r8
void **v10; // rsi
__int64 v11; // rcx
int Stat; // esi
void *v13; // r8
_QWORD *v14; // rax
void *v15; // [rsp+30h] [rbp-48h]
void *v16; // [rsp+30h] [rbp-48h]
void *v17; // [rsp+30h] [rbp-48h]
void *Block[2]; // [rsp+38h] [rbp-40h] BYREF
__int64 v19; // [rsp+48h] [rbp-30h]
unsigned __int64 v20; // [rsp+50h] [rbp-28h]
if ( !*(_BYTE *)(a1 + 432) )
{
v3 = (*(int (__fastcall **)(__int64))(*(_QWORD *)a2 + 56LL))(a2);
v4 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v15 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v15);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v4 = qword_14090BFE0;
}
if ( !GameStatsManager::isStoreItemUnlocked(v4) )
{
v5 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v16 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v16);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v5 = qword_14090BFE0;
}
v6 = cocos2d::CCDictionary::objectForKey(*(cocos2d::CCDictionary **)(v5 + 344), v3);
v7 = *((_DWORD *)v6 + 89) - *((_DWORD *)v6 + 90);
v8 = &word_140737D98;
if ( *((_DWORD *)v6 + 92) == 4 )
v8 = &word_14075A858;
*(_OWORD *)Block = 0;
v19 = 0;
v20 = 0;
v9 = -1;
do
++v9;
while ( *((_BYTE *)v8 + v9) );
sub_14003D230(Block, v8, v9);
v10 = Block;
if ( v20 > 0xF )
v10 = (void **)Block[0];
v11 = qword_14090BFE0;
if ( !qword_14090BFE0 )
{
v17 = operator new(0x3E8u);
qword_14090BFE0 = sub_1402D6480((__int64)v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFE0 + 72LL))(qword_14090BFE0);
v11 = qword_14090BFE0;
}
Stat = GameStatsManager::getStat(v11, v10);
if ( v20 > 0xF )
{
v13 = Block[0];
if ( v20 + 1 >= 0x1000 )
{
v13 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v13 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v13);
}
if ( v7 <= Stat )
{
v14 = (_QWORD *)PurchaseItemPopup::create(v6);
v14[84] = a1 + 408;
(*(void (__fastcall **)(_QWORD *))(*v14 + 1064LL))(v14);
}
else
{
GJShopLayer::showCantAffordMessage(a1, v6);
}
}
}
}