//
// GameStatsManager::getTotalCollectedDiamonds from 0x40de64 to 0x40dfd6 (370 bytes)
//
// 1 xrefs:
// > GameStatsManager::recountSpecialStats @ 0x41d178
//
// 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
//
int GameStatsManager::getTotalCollectedDiamonds(GameStatsManager *a1)
{
int m_challengeDiamonds; // r4
int v3; // r3
int v4; // r6
int v5; // r2
cocos2d::CCDictionary *m_completedLists; // r3
int v7; // r11
cocos2d::CCDictionary *m_gauntletDiamondScores; // r9
cocos2d::CCDictionary *i; // r3
cocos2d::CCDictElement *m_pElements; // r3
cocos2d::CCDictElement *next; // r6
cocos2d::CCDictElement *v12; // r2
cocos2d::CCString *v13; // r0
char *CString; // r0
cocos2d::CCString *v15; // r0
int v16; // s16
cocos2d::CCString *v17; // r0
int BaseDiamonds; // r0
unsigned int v19; // r8
cocos2d::CCArray *v20; // r10
cocos2d::CCDictionary *v22; // [sp+4h] [bp-20h]
int v23; // [sp+Ch] [bp-18h]
char *v24; // [sp+14h] [bp-10h] BYREF
std::string v25; // [sp+18h] [bp-Ch] BYREF
m_challengeDiamonds = (int)a1->m_challengeDiamonds;
if ( m_challengeDiamonds )
{
v3 = *(_DWORD *)(m_challengeDiamonds + 52);
if ( v3 )
v4 = *(_DWORD *)(v3 + 272);
else
v4 = 0;
m_challengeDiamonds = 0;
while ( v3 )
{
m_challengeDiamonds += cocos2d::CCString::intValue(*(cocos2d::CCString **)(v3 + 260));
if ( v4 )
v5 = *(_DWORD *)(v4 + 272);
else
v5 = 0;
v3 = v4;
v4 = v5;
}
}
m_completedLists = a1->m_completedLists;
if ( m_completedLists )
{
m_pElements = m_completedLists->m_pElements;
if ( m_pElements )
next = (cocos2d::CCDictElement *)m_pElements->hh.next;
else
next = nullptr;
while ( m_pElements )
{
m_challengeDiamonds += cocos2d::CCString::intValue((cocos2d::CCString *)m_pElements->m_pObject);
if ( next )
v12 = (cocos2d::CCDictElement *)next->hh.next;
else
v12 = nullptr;
m_pElements = next;
next = v12;
}
}
v7 = 0;
m_gauntletDiamondScores = a1->m_gauntletDiamondScores;
for ( i = a1->m_onlineStars; ; i = a1->m_timelyStars )
{
v22 = i;
v19 = 0;
v20 = cocos2d::CCDictionary::allKeys(m_gauntletDiamondScores);
while ( v19 < cocos2d::CCArray::count(v20) )
{
v13 = cocos2d::CCArray::stringAtIndex(v20, v19);
CString = (char *)cocos2d::CCString::getCString(v13);
sub_776584((int)&v24, CString);
v15 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_gauntletDiamondScores, (const std::string *)&v24);
v16 = cocos2d::CCString::intValue(v15);
sub_776584((int)&v25, v24);
v17 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v22, &v25);
v23 = cocos2d::CCString::intValue(v17);
sub_774008(&v25);
BaseDiamonds = GameStatsManager::getBaseDiamonds(a1, v23);
++v19;
m_challengeDiamonds = (int)(float)((float)m_challengeDiamonds
+ floorf((float)BaseDiamonds * (float)((float)v16 / 100.0)));
sub_774008(&v24);
}
if ( v7 )
break;
m_gauntletDiamondScores = a1->m_timelyDiamondScores;
v7 = 1;
}
return m_challengeDiamonds;
}