//
// GJShopLayer::didPurchaseItem from 0x92ab5c to 0x92b3d0 (2164 bytes)
//
// 3 xrefs:
// > `non-virtual thunk to'GJShopLayer::didPurchaseItem @ 0x92b3d4
// > ??> @ 0xa1b98
// > ??> @ 0x11af860
//
// 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::didPurchaseItem(GJShopLayer *a1, GJStoreItem *a2)
{
FMODAudioEngine *v4; // x20
char *v5; // x0
CCCounterLabel *m_currencyLabel; // x23
GameStatsManager *v7; // x24
int Stat; // w0
char *v9; // x0
cocos2d::CCObject *v10; // x0
cocos2d::CCObject *v11; // x24
unsigned int v12; // w23
GJItemIcon *v13; // x25
cocos2d::CCArray *v14; // x0
cocos2d::CCArray *v15; // x24
__int64 v16; // x25
cocos2d::CCArray *v17; // x0
cocos2d::CCArray *v18; // x24
cocos2d::CCObject *v19; // x0
char *v20; // x0
void *v21; // x0
cocos2d::CCObject *v22; // x0
char *v23; // x0
void *v24; // x0
cocos2d::CCObject *v25; // x0
char *v26; // x0
void *v27; // x0
cocos2d::CCObject *v28; // x0
char *v29; // x0
void *v30; // x0
cocos2d::CCObject *v31; // x0
char *v32; // x0
void *v33; // x0
DialogLayer *v34; // x19
unsigned int *v35; // x1
int v36; // w2
unsigned int *v37; // x1
int v38; // w2
unsigned int *v39; // x1
int v40; // w2
unsigned int *v41; // x1
int v42; // w2
unsigned int *v43; // x1
int v44; // w2
unsigned int *v45; // x1
int v46; // w2
unsigned int *v47; // x1
int v48; // w2
unsigned int *v49; // x1
int v50; // w2
unsigned int *v51; // x1
int v52; // w2
unsigned int *v53; // x1
int v54; // w2
unsigned int *v55; // x1
int v56; // w2
unsigned int *v57; // x1
int v58; // w2
_QWORD v59[14]; // [xsp+0h] [xbp+0h] BYREF
char v60; // [xsp+80h] [xbp+80h] BYREF
__int64 v61; // [xsp+88h] [xbp+88h] BYREF
char *v62; // [xsp+90h] [xbp+90h] BYREF
v59[13] = &v60;
v4 = FMODAudioEngine::sharedEngine();
sub_D153B8((int)&v62, "buyItem03.ogg");
FMODAudioEngine::playEffect((__int64)v4, (__int64)&v62);
v5 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v37 = (unsigned int *)(v62 - 8);
do
v38 = __ldaxr(v37);
while ( __stlxr(v38 - 1, v37) );
}
else
{
v38 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v38 - 1;
}
if ( v38 <= 0 )
operator delete(v5);
}
m_currencyLabel = a1->m_currencyLabel;
v7 = GameStatsManager::sharedState();
GJStoreItem::getCurrencyKey(a2, (__int64)&v62);
Stat = GameStatsManager::getStat(v7, v62);
CCCounterLabel::setTargetCount(m_currencyLabel, Stat);
v9 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v35 = (unsigned int *)(v62 - 8);
do
v36 = __ldaxr(v35);
while ( __stlxr(v36 - 1, v35) );
}
else
{
v36 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v36 - 1;
}
if ( v36 <= 0 )
operator delete(v9);
}
v10 = cocos2d::CCDictionary::objectForKey(a1->m_shopItems, a2->m_index.random - a2->m_index.seed);
v11 = v10;
if ( v10 )
{
v12 = 0;
v13 = (GJItemIcon *)((__int64 (__fastcall *)(cocos2d::CCObject *))v10->__vftable[13].~CCObject_0)(v10);
v11->__vftable[13].copyWithZone(v11, nullptr);
GJItemIcon::darkenStoreItem(v13, a1->m_type);
v14 = v13->getChildren(v13);
v15 = v14;
if ( v14 )
{
if ( (unsigned int)cocos2d::CCArray::count(v14) )
{
do
{
v16 = cocos2d::CCArray::objectAtIndex(v15, v12++);
if ( (*(unsigned int (__fastcall **)(__int64))(*(_QWORD *)v16 + 64LL))(v16) == 1234 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v16 + 328LL))(v16, 0);
}
while ( v12 < (unsigned int)cocos2d::CCArray::count(v15) );
}
}
}
if ( a2->m_unlockType.random - a2->m_unlockType.seed == 12 )
{
v17 = (cocos2d::CCArray *)(unsigned int)(a2->m_typeID.random - a2->m_typeID.seed);
if ( (_DWORD)v17 == 4 )
{
v18 = (cocos2d::CCArray *)cocos2d::CCArray::create(v17);
sub_D153B8((int)&v61, "Scratch");
sub_D153B8((int)&v62, "Ah the shiny thing, excellent choice.");
v19 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v61, (__int64)&v62, 10, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v18, v19);
v20 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v49 = (unsigned int *)(v62 - 8);
do
v50 = __ldaxr(v49);
while ( __stlxr(v50 - 1, v49) );
}
else
{
v50 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v50 - 1;
}
if ( v50 <= 0 )
operator delete(v20);
}
v21 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)(v61 - 8);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v58 - 1;
}
if ( v58 <= 0 )
operator delete(v21);
}
sub_D153B8((unsigned int)v59 + 136, "Scratch");
sub_D153B8((int)&v62, "I found it a while ago.\nYea... 'Found' is a good word...");
v22 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v61, (__int64)&v62, 13, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v18, v22);
v23 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v39 = (unsigned int *)(v62 - 8);
do
v40 = __ldaxr(v39);
while ( __stlxr(v40 - 1, v39) );
}
else
{
v40 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v40 - 1;
}
if ( v40 <= 0 )
operator delete(v23);
}
v24 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v41 = (unsigned int *)(v61 - 8);
do
v42 = __ldaxr(v41);
while ( __stlxr(v42 - 1, v41) );
}
else
{
v42 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v42 - 1;
}
if ( v42 <= 0 )
operator delete(v24);
}
sub_D153B8((unsigned int)v59 + 136, "Scratch");
sub_D153B8((int)&v62, "Not sure what it does. If anyone asks you didnt buy it here.");
v25 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v61, (__int64)&v62, 11, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v18, v25);
v26 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v43 = (unsigned int *)(v62 - 8);
do
v44 = __ldaxr(v43);
while ( __stlxr(v44 - 1, v43) );
}
else
{
v44 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v44 - 1;
}
if ( v44 <= 0 )
operator delete(v26);
}
v27 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v51 = (unsigned int *)(v61 - 8);
do
v52 = __ldaxr(v51);
while ( __stlxr(v52 - 1, v51) );
}
else
{
v52 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v52 - 1;
}
if ( v52 <= 0 )
operator delete(v27);
}
sub_D153B8((unsigned int)v59 + 136, "Scratch");
sub_D153B8((int)&v62, "I mean, buy it where?");
v28 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v61, (__int64)&v62, 13, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v18, v28);
v29 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v47 = (unsigned int *)(v62 - 8);
do
v48 = __ldaxr(v47);
while ( __stlxr(v48 - 1, v47) );
}
else
{
v48 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v48 - 1;
}
if ( v48 <= 0 )
operator delete(v29);
}
v30 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v55 = (unsigned int *)(v61 - 8);
do
v56 = __ldaxr(v55);
while ( __stlxr(v56 - 1, v55) );
}
else
{
v56 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v56 - 1;
}
if ( v56 <= 0 )
operator delete(v30);
}
sub_D153B8((unsigned int)v59 + 136, "Scratch");
sub_D153B8((int)&v62, "...");
v31 = (cocos2d::CCObject *)DialogObject::create(1.0, (__int64)&v61, (__int64)&v62, 8, 0, (int)&unk_FFFFFF);
cocos2d::CCArray::addObject(v18, v31);
v32 = v62 - 24;
if ( v62 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v45 = (unsigned int *)(v62 - 8);
do
v46 = __ldaxr(v45);
while ( __stlxr(v46 - 1, v45) );
}
else
{
v46 = *((_DWORD *)v62 - 2);
*((_DWORD *)v62 - 2) = v46 - 1;
}
if ( v46 <= 0 )
operator delete(v32);
}
v33 = (void *)(v61 - 24);
if ( (__int64 *)(v61 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v53 = (unsigned int *)(v61 - 8);
do
v54 = __ldaxr(v53);
while ( __stlxr(v54 - 1, v53) );
}
else
{
v54 = *(_DWORD *)(v61 - 8);
*(_DWORD *)(v61 - 8) = v54 - 1;
}
if ( v54 <= 0 )
operator delete(v33);
}
v34 = DialogLayer::createWithObjects(v18, (int)&dword_0 + 2);
a1->addChild_0(a1, v34, 100);
DialogLayer::updateChatPlacement(v34, Center);
DialogLayer::animateInRandomSide(v34);
}
}
}