//
// GameStatsManager::generateItemUnlockableData from 0x100065890 to 0x1000662d7 (2631 bytes)
//
// 4 xrefs:
// > GameStatsManager::init @ 0x10005a52c
// > GameStatsManager::generateItemUnlockableData @ 0x100065c0f
// > GameStatsManager::generateItemUnlockableData @ 0x100065efe
// > GameStatsManager::generateItemUnlockableData @ 0x1000661e1
//
// 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 __fastcall GameStatsManager::generateItemUnlockableData(GameStatsManager *a1)
{
cocos2d::CCDictionary *v1; // rax
unsigned int v2; // eax
unsigned int v3; // r13d
unsigned int v4; // r14d
__int64 v5; // rsi
cocos2d::CCObject *v6; // r15
__int64 v7; // rax
char *v8; // rbx
cocos2d::CCObject *v9; // rax
cocos2d::CCDictionary *v10; // rax
cocos2d::CCDictionary *v11; // rax
cocos2d::CCDictionary *v12; // r12
cocos2d::CCObject *v13; // rdi
__int64 v14; // rbx
__int64 v15; // rsi
__int64 v16; // rbx
int v17; // esi
unsigned int v18; // ecx
__int64 v19; // rax
char *v20; // rbx
cocos2d::CCObject *v21; // rax
cocos2d::CCDictionary *v22; // rax
cocos2d::CCDictionary *v23; // rax
cocos2d::CCDictionary *v24; // r12
cocos2d::CCObject *v25; // rdi
__int64 v26; // rbx
__int64 v27; // rsi
cocos2d::CCString *v28; // rax
int v29; // ebx
__int64 v30; // rax
char *v31; // rbx
cocos2d::CCObject *v32; // rax
cocos2d::CCDictionary *v33; // rax
cocos2d::CCDictionary *v34; // rax
cocos2d::CCDictionary *v35; // r12
cocos2d::CCObject *v36; // rdi
__int64 v37; // rbx
__int64 v38; // rsi
__int64 v39; // rbx
cocos2d::CCDictionary *m_unlockedItems; // rbx
char v41[8]; // [rsp+0h] [rbp-70h] BYREF
__int64 v42; // [rsp+8h] [rbp-68h]
void *v43; // [rsp+10h] [rbp-60h]
GameStatsManager *v44; // [rsp+18h] [rbp-58h]
int v45; // [rsp+20h] [rbp-50h]
unsigned int v46; // [rsp+24h] [rbp-4Ch]
__int64 (__fastcall **v47)(); // [rsp+28h] [rbp-48h]
_BYTE v48[16]; // [rsp+30h] [rbp-40h] BYREF
void *__p; // [rsp+40h] [rbp-30h]
v44 = a1;
if ( !a1->m_unlockedItems )
{
v1 = cocos2d::CCDictionary::create();
v44->m_unlockedItems = v1;
cocos2d::CCObject::retain(v1);
v47 = off_1008B3D48;
v2 = 0;
do
{
v46 = v2;
v3 = dword_100815888[v2];
v45 = dword_1008158C4[v2];
v4 = dword_100815900[v2];
do
{
v5 = (__int64)AchievementManager::sharedState();
AchievementManager::achievementForUnlock(v41, v5, v4, v3);
if ( (v41[0] & 1) != 0 )
{
if ( !v42 )
goto LABEL_12;
}
else if ( !((unsigned __int8)v41[0] >> 1) )
{
LABEL_12:
v6 = nullptr;
v7 = qword_10099ED28;
if ( qword_10099ED28 )
goto LABEL_20;
goto LABEL_13;
}
v6 = (cocos2d::CCObject *)operator new(0x38u);
*(_OWORD *)&v6->m_uIndexInArray = 0;
*(_OWORD *)&v6->m_nTag = 0;
*(_OWORD *)&v6->__vftable = 0;
*(_QWORD *)&v6->m_uOrderOfArrival = 0;
cocos2d::CCObject::CCObject(v6);
v6->__vftable = (cocos2d::CCObject_vtbl *)v47;
cocos2d::CCObject::autorelease(v6);
v5 = 1;
((void (__fastcall *)(cocos2d::CCObject *, __int64))v6->setTag)(v6, 1);
v7 = qword_10099ED28;
if ( qword_10099ED28 )
goto LABEL_20;
LABEL_13:
v8 = (char *)operator new(0x390u);
cocos2d::CCNode::CCNode(v8);
*(_QWORD *)v8 = off_1008B34B0;
v8[314] = 0;
*((_OWORD *)v8 + 20) = 0;
*((_OWORD *)v8 + 21) = 0;
*((_OWORD *)v8 + 22) = 0;
*((_OWORD *)v8 + 23) = 0;
*((_OWORD *)v8 + 24) = 0;
*((_QWORD *)v8 + 50) = 0;
*((_DWORD *)v8 + 102) = 1065353216;
*((_OWORD *)v8 + 26) = 0;
*((_OWORD *)v8 + 27) = 0;
*((_DWORD *)v8 + 112) = 1065353216;
*(_OWORD *)(v8 + 456) = 0;
*(_OWORD *)(v8 + 472) = 0;
*(_OWORD *)(v8 + 488) = 0;
*(_OWORD *)(v8 + 504) = 0;
*(_OWORD *)(v8 + 520) = 0;
*(_OWORD *)(v8 + 536) = 0;
*((_QWORD *)v8 + 69) = 0;
*((_DWORD *)v8 + 140) = 1065353216;
*(_OWORD *)(v8 + 568) = 0;
*(_OWORD *)(v8 + 584) = 0;
*((_DWORD *)v8 + 150) = 1065353216;
*((_QWORD *)v8 + 101) = 0;
*((_QWORD *)v8 + 103) = 0;
*(_OWORD *)(v8 + 840) = 0;
*((_OWORD *)v8 + 38) = 0;
*((_OWORD *)v8 + 39) = 0;
*((_OWORD *)v8 + 40) = 0;
*((_OWORD *)v8 + 41) = 0;
*((_OWORD *)v8 + 42) = 0;
*((_OWORD *)v8 + 43) = 0;
*((_OWORD *)v8 + 44) = 0;
*((_OWORD *)v8 + 45) = 0;
*((_OWORD *)v8 + 46) = 0;
*((_OWORD *)v8 + 47) = 0;
*((_DWORD *)v8 + 192) = 0;
*(_OWORD *)(v8 + 785) = 0;
*(_OWORD *)(v8 + 776) = 0;
*((_QWORD *)v8 + 104) = v8 + 840;
*((_OWORD *)v8 + 54) = 0;
*((_QWORD *)v8 + 107) = v8 + 864;
*(_OWORD *)(v8 + 888) = 0;
*((_QWORD *)v8 + 110) = v8 + 888;
*((_WORD *)v8 + 452) = 0;
*((_DWORD *)v8 + 227) = 0;
qword_10099ED28 = (__int64)v8;
v5 = 1;
v9 = (cocos2d::CCObject *)sub_1007AB580("%i", v41[0]);
*((_QWORD *)v8 + 40) = v9;
cocos2d::CCObject::retain(v9);
v10 = cocos2d::CCDictionary::create();
*((_QWORD *)v8 + 102) = v10;
cocos2d::CCObject::retain(v10);
v11 = cocos2d::CCDictionary::create();
v12 = v11;
v13 = *((cocos2d::CCObject **)v8 + 59);
if ( v13 != v11 )
{
if ( v11 )
{
cocos2d::CCObject::retain(v11);
v13 = *((cocos2d::CCObject **)v8 + 59);
}
if ( v13 )
cocos2d::CCObject::release(v13);
*((_QWORD *)v8 + 59) = v12;
}
GameStatsManager::setupIconCredits((GameStatsManager *)v8);
GameStatsManager::createStoreItems((GameStatsManager *)v8);
GameStatsManager::createSecretChestItems((GameStatsManager *)v8);
GameStatsManager::createSpecialChestItems((GameStatsManager *)v8);
GameStatsManager::generateItemUnlockableData((GameStatsManager *)v8);
v7 = qword_10099ED28;
LABEL_20:
v14 = *(_QWORD *)(v7 + 328);
GameStatsManager::getItemKey(v48, v5, v4, v3);
v15 = (__int64)v48;
v16 = cocos2d::CCDictionary::objectForKey_1(v14, v48);
if ( (v48[0] & 1) != 0 )
operator delete(__p);
if ( v16 != 0 && v6 == nullptr )
{
v6 = (cocos2d::CCObject *)operator new(0x38u);
*(_OWORD *)&v6->m_uIndexInArray = 0;
*(_OWORD *)&v6->m_nTag = 0;
*(_OWORD *)&v6->__vftable = 0;
*(_QWORD *)&v6->m_uOrderOfArrival = 0;
cocos2d::CCObject::CCObject(v6);
v6->__vftable = (cocos2d::CCObject_vtbl *)v47;
cocos2d::CCObject::autorelease(v6);
v17 = *(_DWORD *)(v16 + 364);
v18 = v17 - 1;
v15 = (unsigned int)(v17 + 4);
if ( v18 >= 4 )
v15 = 4;
((void (__fastcall *)(cocos2d::CCObject *, __int64))v6->setTag)(v6, v15);
}
v19 = qword_10099ED28;
if ( !qword_10099ED28 )
{
v20 = (char *)operator new(0x390u);
cocos2d::CCNode::CCNode(v20);
*(_QWORD *)v20 = off_1008B34B0;
v20[314] = 0;
*((_OWORD *)v20 + 20) = 0;
*((_OWORD *)v20 + 21) = 0;
*((_OWORD *)v20 + 22) = 0;
*((_OWORD *)v20 + 23) = 0;
*((_OWORD *)v20 + 24) = 0;
*((_QWORD *)v20 + 50) = 0;
*((_DWORD *)v20 + 102) = 1065353216;
*((_OWORD *)v20 + 26) = 0;
*((_OWORD *)v20 + 27) = 0;
*((_DWORD *)v20 + 112) = 1065353216;
*(_OWORD *)(v20 + 456) = 0;
*(_OWORD *)(v20 + 472) = 0;
*(_OWORD *)(v20 + 488) = 0;
*(_OWORD *)(v20 + 504) = 0;
*(_OWORD *)(v20 + 520) = 0;
*(_OWORD *)(v20 + 536) = 0;
*((_QWORD *)v20 + 69) = 0;
*((_DWORD *)v20 + 140) = 1065353216;
*(_OWORD *)(v20 + 568) = 0;
*(_OWORD *)(v20 + 584) = 0;
*((_DWORD *)v20 + 150) = 1065353216;
*((_QWORD *)v20 + 101) = 0;
*((_QWORD *)v20 + 103) = 0;
*(_OWORD *)(v20 + 840) = 0;
*((_OWORD *)v20 + 38) = 0;
*((_OWORD *)v20 + 39) = 0;
*((_OWORD *)v20 + 40) = 0;
*((_OWORD *)v20 + 41) = 0;
*((_OWORD *)v20 + 42) = 0;
*((_OWORD *)v20 + 43) = 0;
*((_OWORD *)v20 + 44) = 0;
*((_OWORD *)v20 + 45) = 0;
*((_OWORD *)v20 + 46) = 0;
*((_OWORD *)v20 + 47) = 0;
*((_DWORD *)v20 + 192) = 0;
*(_OWORD *)(v20 + 785) = 0;
*(_OWORD *)(v20 + 776) = 0;
*((_QWORD *)v20 + 104) = v20 + 840;
*((_OWORD *)v20 + 54) = 0;
*((_QWORD *)v20 + 107) = v20 + 864;
*(_OWORD *)(v20 + 888) = 0;
*((_QWORD *)v20 + 110) = v20 + 888;
*((_WORD *)v20 + 452) = 0;
*((_DWORD *)v20 + 227) = 0;
qword_10099ED28 = (__int64)v20;
v15 = 1;
v21 = (cocos2d::CCObject *)sub_1007AB580("%i", v41[0]);
*((_QWORD *)v20 + 40) = v21;
cocos2d::CCObject::retain(v21);
v22 = cocos2d::CCDictionary::create();
*((_QWORD *)v20 + 102) = v22;
cocos2d::CCObject::retain(v22);
v23 = cocos2d::CCDictionary::create();
v24 = v23;
v25 = *((cocos2d::CCObject **)v20 + 59);
if ( v25 != v23 )
{
if ( v23 )
{
cocos2d::CCObject::retain(v23);
v25 = *((cocos2d::CCObject **)v20 + 59);
}
if ( v25 )
cocos2d::CCObject::release(v25);
*((_QWORD *)v20 + 59) = v24;
}
GameStatsManager::setupIconCredits((GameStatsManager *)v20);
GameStatsManager::createStoreItems((GameStatsManager *)v20);
GameStatsManager::createSecretChestItems((GameStatsManager *)v20);
GameStatsManager::createSpecialChestItems((GameStatsManager *)v20);
GameStatsManager::generateItemUnlockableData((GameStatsManager *)v20);
v19 = qword_10099ED28;
}
v26 = *(_QWORD *)(v19 + 352);
GameStatsManager::getItemKey(v48, v15, v4, v3);
v27 = (__int64)v48;
v28 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(v26, v48);
v29 = cocos2d::CCString::intValue(v28);
if ( (v48[0] & 1) != 0 )
operator delete(__p);
if ( v29 > 0 && v6 == nullptr )
{
v6 = (cocos2d::CCObject *)operator new(0x38u);
*(_OWORD *)&v6->m_uIndexInArray = 0;
*(_OWORD *)&v6->m_nTag = 0;
*(_OWORD *)&v6->__vftable = 0;
*(_QWORD *)&v6->m_uOrderOfArrival = 0;
cocos2d::CCObject::CCObject(v6);
v6->__vftable = (cocos2d::CCObject_vtbl *)v47;
cocos2d::CCObject::autorelease(v6);
v27 = 2;
((void (__fastcall *)(cocos2d::CCObject *, __int64))v6->setTag)(v6, 2);
}
v30 = qword_10099ED28;
if ( !qword_10099ED28 )
{
v31 = (char *)operator new(0x390u);
cocos2d::CCNode::CCNode(v31);
*(_QWORD *)v31 = off_1008B34B0;
v31[314] = 0;
*((_OWORD *)v31 + 20) = 0;
*((_OWORD *)v31 + 21) = 0;
*((_OWORD *)v31 + 22) = 0;
*((_OWORD *)v31 + 23) = 0;
*((_OWORD *)v31 + 24) = 0;
*((_QWORD *)v31 + 50) = 0;
*((_DWORD *)v31 + 102) = 1065353216;
*((_OWORD *)v31 + 26) = 0;
*((_OWORD *)v31 + 27) = 0;
*((_DWORD *)v31 + 112) = 1065353216;
*(_OWORD *)(v31 + 456) = 0;
*(_OWORD *)(v31 + 472) = 0;
*(_OWORD *)(v31 + 488) = 0;
*(_OWORD *)(v31 + 504) = 0;
*(_OWORD *)(v31 + 520) = 0;
*(_OWORD *)(v31 + 536) = 0;
*((_QWORD *)v31 + 69) = 0;
*((_DWORD *)v31 + 140) = 1065353216;
*(_OWORD *)(v31 + 568) = 0;
*(_OWORD *)(v31 + 584) = 0;
*((_DWORD *)v31 + 150) = 1065353216;
*((_QWORD *)v31 + 101) = 0;
*((_QWORD *)v31 + 103) = 0;
*(_OWORD *)(v31 + 840) = 0;
*((_OWORD *)v31 + 38) = 0;
*((_OWORD *)v31 + 39) = 0;
*((_OWORD *)v31 + 40) = 0;
*((_OWORD *)v31 + 41) = 0;
*((_OWORD *)v31 + 42) = 0;
*((_OWORD *)v31 + 43) = 0;
*((_OWORD *)v31 + 44) = 0;
*((_OWORD *)v31 + 45) = 0;
*((_OWORD *)v31 + 46) = 0;
*((_OWORD *)v31 + 47) = 0;
*((_DWORD *)v31 + 192) = 0;
*(_OWORD *)(v31 + 785) = 0;
*(_OWORD *)(v31 + 776) = 0;
*((_QWORD *)v31 + 104) = v31 + 840;
*((_OWORD *)v31 + 54) = 0;
*((_QWORD *)v31 + 107) = v31 + 864;
*(_OWORD *)(v31 + 888) = 0;
*((_QWORD *)v31 + 110) = v31 + 888;
*((_WORD *)v31 + 452) = 0;
*((_DWORD *)v31 + 227) = 0;
qword_10099ED28 = (__int64)v31;
v27 = 1;
v32 = (cocos2d::CCObject *)sub_1007AB580("%i", v41[0]);
*((_QWORD *)v31 + 40) = v32;
cocos2d::CCObject::retain(v32);
v33 = cocos2d::CCDictionary::create();
*((_QWORD *)v31 + 102) = v33;
cocos2d::CCObject::retain(v33);
v34 = cocos2d::CCDictionary::create();
v35 = v34;
v36 = *((cocos2d::CCObject **)v31 + 59);
if ( v36 != v34 )
{
if ( v34 )
{
cocos2d::CCObject::retain(v34);
v36 = *((cocos2d::CCObject **)v31 + 59);
}
if ( v36 )
cocos2d::CCObject::release(v36);
*((_QWORD *)v31 + 59) = v35;
}
GameStatsManager::setupIconCredits((GameStatsManager *)v31);
GameStatsManager::createStoreItems((GameStatsManager *)v31);
GameStatsManager::createSecretChestItems((GameStatsManager *)v31);
GameStatsManager::createSpecialChestItems((GameStatsManager *)v31);
GameStatsManager::generateItemUnlockableData((GameStatsManager *)v31);
v30 = qword_10099ED28;
}
v37 = *(_QWORD *)(v30 + 368);
GameStatsManager::getItemKey(v48, v27, v4, v3);
v38 = (__int64)v48;
v39 = cocos2d::CCDictionary::objectForKey_1(v37, v48);
if ( (v48[0] & 1) != 0 )
operator delete(__p);
if ( v39 )
{
if ( !v6 )
{
v6 = (cocos2d::CCObject *)operator new(0x38u);
*(_OWORD *)&v6->m_uIndexInArray = 0;
*(_OWORD *)&v6->m_nTag = 0;
*(_OWORD *)&v6->__vftable = 0;
*(_QWORD *)&v6->m_uOrderOfArrival = 0;
cocos2d::CCObject::CCObject(v6);
v6->__vftable = (cocos2d::CCObject_vtbl *)v47;
cocos2d::CCObject::autorelease(v6);
v38 = 3;
((void (__fastcall *)(cocos2d::CCObject *, __int64))v6->setTag)(v6, 3);
}
}
else if ( !v6 )
{
goto LABEL_54;
}
m_unlockedItems = v44->m_unlockedItems;
GameStatsManager::getItemKey(v48, v38, v4, v3);
cocos2d::CCDictionary::setObject_1(m_unlockedItems, v6, v48);
if ( (v48[0] & 1) != 0 )
operator delete(__p);
LABEL_54:
if ( (v41[0] & 1) != 0 )
operator delete(v43);
++v4;
}
while ( v45 != v4 );
v2 = v46 + 1;
}
while ( v46 != 14 );
}
}