//
// GJShopLayer::onSelectItem from 0xa81600 to 0xa8173c (316 bytes)
//
// 3 xrefs:
// > ??> @ 0xd6f30
// > GJShopLayer::init @ 0xa7fb4c
// > ??> @ 0x1546688
//
// This function is hookable on this platform (idp: arm, 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 13:00:32 +0000
//
__int64 __fastcall GJShopLayer::onSelectItem(GJShopLayer *this, cocos2d::CCObject *a2)
{
GameStatsManager *v4; // x0
unsigned int v5; // w21
GameStatsManager *v6; // x0
_BOOL8 isStoreItemUnlocked; // x0
cocos2d::CCDictionary **v8; // x0
__int64 StoreItem; // x0
int v10; // w23
GJStoreItem *v11; // x22
GameStatsManager *v12; // x0
int v13; // w23
GameStatsManager *v14; // x24
char *v15; // x1
GJStoreItem *v16; // x1
int Stat; // w21
__int64 *v18; // x0
__int64 v19; // x2
char v20; // [xsp+40h] [xbp+40h] BYREF
_BYTE v21[7]; // [xsp+41h] [xbp+41h] BYREF
char *v22; // [xsp+50h] [xbp+50h]
if ( !*((_BYTE *)this + 432) )
{
v4 = (GameStatsManager *)(*(__int64 (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2);
v5 = (unsigned int)v4;
v6 = (GameStatsManager *)GameStatsManager::sharedState(v4);
isStoreItemUnlocked = GameStatsManager::isStoreItemUnlocked(v6, (const char *)v5);
if ( !isStoreItemUnlocked )
{
v8 = (cocos2d::CCDictionary **)GameStatsManager::sharedState((GameStatsManager *)isStoreItemUnlocked);
StoreItem = GameStatsManager::getStoreItem(v8, v5);
v10 = *(_DWORD *)(StoreItem + 352);
v11 = (GJStoreItem *)StoreItem;
v12 = (GameStatsManager *)*(unsigned int *)(StoreItem + 356);
v13 = v10 - (_DWORD)v12;
v14 = (GameStatsManager *)GameStatsManager::sharedState(v12);
GJStoreItem::getCurrencyKey(v11, (__int64)&v20);
v15 = v21;
if ( (v20 & 1) != 0 )
v15 = v22;
Stat = GameStatsManager::getStat(v14, v15);
if ( (v20 & 1) != 0 )
operator delete(v22);
if ( Stat < v13 )
{
GJShopLayer::showCantAffordMessage(this, v11);
}
else
{
v18 = (__int64 *)PurchaseItemPopup::create(v11, v16);
v19 = *v18;
v18[84] = (__int64)this + 408;
(*(void (**)(void))(v19 + 1312))();
}
}
}
return _stack_chk_guard;
}