//
// GJShopLayer::onSelectItem from 0x931020 to 0x9311a4 (388 bytes)
//
// 3 xrefs:
// > ??> @ 0xa37d0
// > GJShopLayer::init @ 0x92eacc
// > ??> @ 0x122da40
//
// 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
//
void GJShopLayer::onSelectItem(GJShopLayer *a1, cocos2d::CCObject *a2)
{
int v3; // w21
GameStatsManager *v4; // x0
GameStatsManager *v5; // x0
GJStoreItem *StoreItem; // x21
int v7; // w22
GameStatsManager *v8; // x23
int Stat; // w23
char *v10; // x0
PurchaseItemPopup *v11; // x0
PurchaseItemPopup_vtbl *v12; // x2
unsigned int *v13; // x2
int v14; // w1
char *v15; // [xsp+50h] [xbp+50h] BYREF
if ( !a1->m_closing )
{
v3 = a2->getTag(a2);
v4 = GameStatsManager::sharedState();
if ( !GameStatsManager::isStoreItemUnlocked(v4, v3) )
{
v5 = GameStatsManager::sharedState();
StoreItem = (GJStoreItem *)GameStatsManager::getStoreItem(v5, v3);
v7 = StoreItem->m_price.random - StoreItem->m_price.seed;
v8 = GameStatsManager::sharedState();
GJStoreItem::getCurrencyKey(StoreItem, (__int64)&v15);
Stat = GameStatsManager::getStat(v8, v15);
v10 = v15 - 24;
if ( v15 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v15 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v10);
}
if ( Stat < v7 )
{
GJShopLayer::showCantAffordMessage(a1, StoreItem);
}
else
{
v11 = PurchaseItemPopup::create(StoreItem);
v12 = v11->FLAlertLayer::cocos2d::CCLayerColor::cocos2d::CCLayerRGBA::cocos2d::CCLayer::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v11->m_delegate = &a1->GJPurchaseDelegate;
((void (*)(void))v12->show)();
}
}
}
}