//
// GameStatsManager::createSecretChestItems from 0x7b9820 to 0x7b9a08 (488 bytes)
//
// 2 xrefs:
// > GameStatsManager::init @ 0x7c58d4
// > ??> @ 0x37d28
//
// 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 GameStatsManager::createSecretChestItems(GameStatsManager *a1)
{
cocos2d::CCDictionary *v2; // x0
cocos2d::CCDictionary *v3; // x0
cocos2d::CCDictionary *m_allTreasureRoomChests; // x0
cocos2d::CCDictElement *m_pElements; // x19
cocos2d::CCDictElement *i; // x27
cocos2d::CCObject *m_pObject; // x24
cocos2d::CCArray *v8; // x20
unsigned int v9; // w19
_DWORD *v10; // x2
cocos2d::CCDictionary *m_allTreasureRoomChestItems; // x23
cocos2d::CCObject *v12; // x0
char *v13; // x0
unsigned int *v14; // x1
int v15; // w2
std::string v16; // [xsp+80h] [xbp+80h] BYREF
if ( !a1->m_allTreasureRoomChestItems )
{
v2 = cocos2d::CCDictionary::create();
a1->m_allTreasureRoomChestItems = v2;
cocos2d::CCObject::retain(v2);
v3 = cocos2d::CCDictionary::create();
a1->m_allTreasureRoomChests = v3;
cocos2d::CCObject::retain(v3);
GameStatsManager::createSecretChestRewards(a1);
m_allTreasureRoomChests = a1->m_allTreasureRoomChests;
if ( m_allTreasureRoomChests )
{
m_pElements = m_allTreasureRoomChests->m_pElements;
if ( m_pElements )
{
for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )
{
m_pObject = m_pElements->m_pObject;
if ( m_pObject )
{
v8 = *(cocos2d::CCArray **)&m_pObject[1].m_nTag;
v9 = 0;
if ( v8 )
{
if ( (unsigned int)cocos2d::CCArray::count(*(cocos2d::CCArray **)&m_pObject[1].m_nTag) )
{
do
{
v10 = (_DWORD *)cocos2d::CCArray::objectAtIndex(v8, v9);
if ( v10[14] != 9 )
goto LABEL_10;
GameStatsManager::getItemKey(a1, v10[16], v10[15], (__int64)&v16);
cocos2d::CCDictionary::objectForKey(a1->m_allTreasureRoomChestItems, &v16);
m_allTreasureRoomChestItems = a1->m_allTreasureRoomChestItems;
v12 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(const char *)LODWORD(m_pObject[1].__vftable));
cocos2d::CCDictionary::setObject((int)m_allTreasureRoomChestItems, v12);
v13 = (char *)v16.m_data.m_data - 24;
if ( (__int64 *)v16.m_data.m_data - 3 == &qword_124B6B0 )
goto LABEL_10;
if ( &pthread_create )
{
v14 = (unsigned int *)((char *)v16.m_data.m_data - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v16.m_data.m_data - 2);
*((_DWORD *)v16.m_data.m_data - 2) = v15 - 1;
}
if ( v15 > 0 )
{
LABEL_10:
++v9;
}
else
{
++v9;
operator delete(v13);
}
}
while ( v9 < (unsigned int)cocos2d::CCArray::count(v8) );
}
}
}
if ( !i )
break;
m_pElements = i;
}
}
}
}
}