//
// GJShopLayer::didPurchaseItem from 0x1402ac590 to 0x1402acd62 (2002 bytes)
//
// 2 xrefs:
// > ??> @ 0x14057e800
// > ??> @ 0x1406d2258
//
// 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
//
// Hidden C++ exception states: #wind=5
void GJShopLayer::didPurchaseItem(GJShopLayer *a1, GJStoreItem *a2)
{
int v4; // ecx
__int16 *v5; // rdx
size_t v6; // r8
void **v7; // rbx
GameStatsManager *v8; // rcx
int Stat; // eax
void *v10; // rcx
struct cocos2d::CCObject *v11; // rax
__int64 v12; // rcx
struct cocos2d::CCObject *v13; // rdi
GJItemIcon *v14; // rbx
cocos2d::CCArray *v15; // rax
cocos2d::CCArray *v16; // rsi
unsigned int v17; // edi
struct cocos2d::CCObject *v18; // rbx
cocos2d::CCArray *v19; // rbx
char *v20; // rax
char *v21; // rax
char *v22; // rax
char *v23; // rax
char *v24; // rax
DialogLayer *DialogLayer; // rdi
__int64 v26; // rcx
cocos2d::CCDirector *v27; // rax
cocos2d::CCLayer_vtbl *v28; // rbx
const cocos2d::CCPoint *v29; // rax
_QWORD v30[2]; // [rsp+38h] [rbp-39h] BYREF
FMODAudioEngine *v31; // [rsp+48h] [rbp-29h]
__int128 v32; // [rsp+50h] [rbp-21h] BYREF
__int64 v33; // [rsp+60h] [rbp-11h]
__int64 v34; // [rsp+68h] [rbp-9h]
void *Block[2]; // [rsp+70h] [rbp-1h] BYREF
__int64 v36; // [rsp+80h] [rbp+Fh]
unsigned __int64 v37; // [rsp+88h] [rbp+17h]
v30[0] = Block;
v36 = 13;
v37 = 15;
strcpy((char *)Block, "buyItem03.ogg");
HIWORD(Block[1]) = 0;
v4 = qword_1406C2E88;
if ( !qword_1406C2E88 )
{
v31 = (FMODAudioEngine *)operator new(0x888u);
qword_1406C2E88 = (__int64)FMODAudioEngine::FMODAudioEngine(v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2E88 + 72LL))(qword_1406C2E88);
v4 = qword_1406C2E88;
}
FMODAudioEngine::playEffect_1(v4, (__int64)Block);
v5 = (__int16 *)"14";
if ( a2->m_shopType == Diamond )
v5 = &word_14055A524;
*(_OWORD *)Block = 0;
v36 = 0;
v37 = 0;
v6 = -1;
do
++v6;
while ( *((_BYTE *)v5 + v6) );
sub_14003A930(Block, v5, v6);
v7 = Block;
if ( v37 > 0xF )
v7 = (void **)Block[0];
v8 = (GameStatsManager *)qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v31 = (FMODAudioEngine *)operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v31);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v8 = (GameStatsManager *)qword_1406C2EE8;
}
Stat = GameStatsManager::getStat(v8, (const char *)v7);
CCCounterLabel::setTargetCount(*(CCCounterLabel **)&a1->m_uIndexInArray, Stat);
if ( v37 > 0xF )
{
v10 = Block[0];
if ( v37 + 1 >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v10);
}
v11 = cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)&a1->m_unknown2,
a2->m_index.random - a2->m_index.seed);
v13 = v11;
if ( v11 )
{
v14 = (GJItemIcon *)((__int64 (__fastcall *)(struct cocos2d::CCObject *))v11->__vftable[13].copyWithZone)(v11);
((void (__fastcall *)(struct cocos2d::CCObject *, _QWORD))v13->__vftable[12].getTag)(v13, 0);
GJItemIcon::darkenStoreItem_1(v14, (ShopType)a1->m_uOrderOfArrival);
v15 = v14->getChildren(v14);
v16 = v15;
if ( v15 )
{
v17 = 0;
if ( cocos2d::CCArray::count(v15) )
{
do
{
v18 = cocos2d::CCArray::objectAtIndex(v16, v17);
if ( v18->getTag(v18) == 1234 )
((void (__fastcall *)(struct cocos2d::CCObject *, _QWORD))v18->__vftable[4].update)(v18, 0);
++v17;
}
while ( v17 < cocos2d::CCArray::count(v16) );
}
}
}
if ( a2->m_unlockType.random - a2->m_unlockType.seed == 12 && a2->m_typeID.random - a2->m_typeID.seed == 4 )
{
v19 = (cocos2d::CCArray *)cocos2d::CCArray::create(v12);
v31 = (FMODAudioEngine *)&v32;
LOWORD(v30[0]) = -1;
BYTE2(v30[0]) = -1;
v32 = 0;
v33 = 0;
v34 = 15;
*(_QWORD *)&v32 = sub_14003AA10(0x30u);
v33 = 45;
v34 = 47;
strcpy((char *)v32, "Ah the shiny thing, excellent choice.");
Block[1] = nullptr;
v36 = 7;
v37 = 15;
Block[0] = (void *)0x68637461726353LL;
v20 = DialogObject::create((__int64)Block, (__int64)&v32, 10, 1.0, 0, (__int64)v30);
cocos2d::CCArray::addObject(v19, (struct cocos2d::CCObject *)v20);
v31 = (FMODAudioEngine *)&v32;
LOWORD(v30[0]) = -1;
BYTE2(v30[0]) = -1;
v32 = 0;
v33 = 0;
v34 = 15;
*(_QWORD *)&v32 = sub_14003AA10(0x60u);
v33 = 80;
v34 = 95;
strcpy((char *)v32, "I found it a while ago.\nYea... 'Found' is a good word...");
Block[1] = nullptr;
v36 = 7;
v37 = 15;
Block[0] = (void *)0x68637461726353LL;
v21 = DialogObject::create((__int64)Block, (__int64)&v32, 13, 1.0, 0, (__int64)v30);
cocos2d::CCArray::addObject(v19, (struct cocos2d::CCObject *)v21);
v31 = (FMODAudioEngine *)&v32;
LOWORD(v30[0]) = -1;
BYTE2(v30[0]) = -1;
v32 = 0;
v33 = 0;
v34 = 15;
*(_QWORD *)&v32 = sub_14003AA10(0x50u);
v33 = 66;
v34 = 79;
strcpy((char *)v32, "Not sure what it does. If anyone asks you didnt buy it here.");
Block[1] = nullptr;
v36 = 7;
v37 = 15;
Block[0] = (void *)0x68637461726353LL;
v22 = DialogObject::create((__int64)Block, (__int64)&v32, 11, 1.0, 0, (__int64)v30);
cocos2d::CCArray::addObject(v19, (struct cocos2d::CCObject *)v22);
v31 = (FMODAudioEngine *)&v32;
LOWORD(v30[0]) = -1;
BYTE2(v30[0]) = -1;
v32 = 0;
v33 = 0;
v34 = 15;
*(_QWORD *)&v32 = sub_14003AA10(0x20u);
v33 = 27;
v34 = 31;
strcpy((char *)v32, "I mean, buy it where?");
Block[1] = nullptr;
v36 = 7;
v37 = 15;
Block[0] = (void *)0x68637461726353LL;
v23 = DialogObject::create((__int64)Block, (__int64)&v32, 13, 1.0, 0, (__int64)v30);
cocos2d::CCArray::addObject(v19, (struct cocos2d::CCObject *)v23);
v31 = (FMODAudioEngine *)&v32;
LOWORD(v30[0]) = -1;
BYTE2(v30[0]) = -1;
v32 = 0;
v33 = 0;
v34 = 15;
*(_QWORD *)&v32 = sub_14003AA10(0x20u);
v33 = 21;
v34 = 31;
strcpy((char *)v32, "...");
Block[1] = nullptr;
v36 = 7;
v37 = 15;
Block[0] = (void *)0x68637461726353LL;
v24 = DialogObject::create((__int64)Block, (__int64)&v32, 8, 1.0, 0, (__int64)v30);
cocos2d::CCArray::addObject(v19, (struct cocos2d::CCObject *)v24);
DialogLayer = DialogLayer::createDialogLayer(nullptr, v19, 2);
(*(void (__fastcall **)(float *, DialogLayer *, __int64))(*(_QWORD *)&a1[-1].m_sAdditionalTransform.d + 440LL))(
&a1[-1].m_sAdditionalTransform.d,
DialogLayer,
100);
v27 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v26);
cocos2d::CCDirector::getWinSize(v27);
v28 = DialogLayer->m_mainLayer->__vftable;
cocos2d::CCPoint::CCPoint(0.0000000025668347, *(float *)v30 * 0.5);
v28->setPosition_0(DialogLayer->m_mainLayer, v29);
DialogLayer::animateInRandomSide(DialogLayer);
}
}