//
// GameStatsManager::getTotalCollectedCurrency from 0x40da94 to 0x40de62 (974 bytes)
//
// 1 xrefs:
// > GameStatsManager::recountSpecialStats @ 0x41d152
//
// 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::getTotalCollectedCurrency(GameStatsManager *a1)
{
int v2; // r11
float v3; // s16
GameLevelManager *v4; // r0
GJGameLevel *MainLevel; // r1
cocos2d::CCString *v6; // r0
char *CString; // r0
cocos2d::CCDictionary *m_mainCurrencyScores; // r8
int i; // r6
GameLevelManager *v10; // r0
GJGameLevel *v11; // r1
cocos2d::CCString *v12; // r0
char *v13; // r0
cocos2d::CCDictionary *v14; // r9
int j; // r6
GameLevelManager *v16; // r0
GJGameLevel *v17; // r1
cocos2d::CCString *v18; // r0
char *v19; // r0
cocos2d::CCDictionary *v20; // r9
unsigned int v21; // r6
cocos2d::CCArray *v22; // r8
cocos2d::CCString *v23; // r0
const char *v24; // r9
GameLevelManager *v25; // r0
stl::StringData::Internal *v26; // r2
stl::StringData::Internal *v27; // r3
GJGameLevel *SavedLevel; // r1
cocos2d::CCString *v29; // r0
char *v30; // r0
cocos2d::CCDictionary *m_onlineCurrencyScores; // r9
unsigned int v32; // r6
cocos2d::CCArray *v33; // r8
cocos2d::CCString *v34; // r0
const char *v35; // r9
GameLevelManager *v36; // r0
GJGameLevel *SavedGauntletLevel; // r1
cocos2d::CCString *v38; // r0
char *v39; // r0
cocos2d::CCDictionary *m_gauntletCurrencyScores; // r9
unsigned int v41; // r7
cocos2d::CCArray *v42; // r9
cocos2d::CCString *v43; // r0
const char *v44; // r6
GameLevelManager *v45; // r0
GJGameLevel *SavedDailyLevel; // r1
cocos2d::CCString *v47; // r0
char *v48; // r0
cocos2d::CCDictionary *m_timelyCurrencyScores; // r11
cocos2d::CCDictionary *m_timelyStars; // r11
char *v52; // [sp+8h] [bp-14h] BYREF
char *v53; // [sp+Ch] [bp-10h] BYREF
_BYTE v54[4]; // [sp+10h] [bp-Ch] BYREF
v2 = 1;
v3 = 0.0;
do
{
v4 = GameLevelManager::sharedState();
MainLevel = GameLevelManager::getMainLevel(v4, v2, 1);
if ( MainLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, MainLevel);
}
else
{
v6 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", &byte_6);
CString = (char *)cocos2d::CCString::getCString(v6);
sub_776584((int)&v53, CString);
m_mainCurrencyScores = a1->m_mainCurrencyScores;
sub_776584((int)v54, v53);
cocos2d::CCDictionary::removeObjectForKey(m_mainCurrencyScores);
sub_774008(v54);
sub_774008(&v53);
}
++v2;
}
while ( v2 != 23 );
for ( i = 5001; i != 5005; ++i )
{
v10 = GameLevelManager::sharedState();
v11 = GameLevelManager::getMainLevel(v10, i, 1);
if ( v11 )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, v11);
}
else
{
v12 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", &byte_6);
v13 = (char *)cocos2d::CCString::getCString(v12);
sub_776584((int)&v53, v13);
v14 = a1->m_mainCurrencyScores;
sub_776584((int)v54, v53);
cocos2d::CCDictionary::removeObjectForKey(v14);
sub_774008(v54);
sub_774008(&v53);
}
}
for ( j = 2001; j != 2011; ++j )
{
v16 = GameLevelManager::sharedState();
v17 = GameLevelManager::getMainLevel(v16, j, 1);
if ( v17 )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, v17);
}
else
{
v18 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", &byte_6);
v19 = (char *)cocos2d::CCString::getCString(v18);
sub_776584((int)&v53, v19);
v20 = a1->m_mainCurrencyScores;
sub_776584((int)v54, v53);
cocos2d::CCDictionary::removeObjectForKey(v20);
sub_774008(v54);
sub_774008(&v53);
}
}
v21 = 0;
v22 = cocos2d::CCDictionary::allKeys(a1->m_onlineCurrencyScores);
while ( v21 < cocos2d::CCArray::count(v22) )
{
v23 = cocos2d::CCArray::stringAtIndex(v22, v21);
v24 = (const char *)cocos2d::CCString::intValue(v23);
v25 = GameLevelManager::sharedState();
SavedLevel = (GJGameLevel *)GameLevelManager::getSavedLevel(v25, (int)v24, v26, v27);
if ( SavedLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedLevel);
}
else
{
v29 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v24);
v30 = (char *)cocos2d::CCString::getCString(v29);
sub_776584((int)&v53, v30);
m_onlineCurrencyScores = a1->m_onlineCurrencyScores;
sub_776584((int)v54, v53);
cocos2d::CCDictionary::removeObjectForKey(m_onlineCurrencyScores);
sub_774008(v54);
sub_774008(&v53);
}
++v21;
}
v32 = 0;
v33 = cocos2d::CCDictionary::allKeys(a1->m_gauntletCurrencyScores);
while ( v32 < cocos2d::CCArray::count(v33) )
{
v34 = cocos2d::CCArray::stringAtIndex(v33, v32);
v35 = (const char *)cocos2d::CCString::intValue(v34);
v36 = GameLevelManager::sharedState();
SavedGauntletLevel = GameLevelManager::getSavedGauntletLevel(v36, (int)v35);
if ( SavedGauntletLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedGauntletLevel);
}
else
{
v38 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v35);
v39 = (char *)cocos2d::CCString::getCString(v38);
sub_776584((int)&v53, v39);
m_gauntletCurrencyScores = a1->m_gauntletCurrencyScores;
sub_776584((int)v54, v53);
cocos2d::CCDictionary::removeObjectForKey(m_gauntletCurrencyScores);
sub_774008(v54);
sub_774008(&v53);
}
++v32;
}
v41 = 0;
v42 = cocos2d::CCDictionary::allKeys(a1->m_timelyCurrencyScores);
while ( v41 < cocos2d::CCArray::count(v42) )
{
v43 = cocos2d::CCArray::stringAtIndex(v42, v41);
v44 = (const char *)cocos2d::CCString::intValue(v43);
v45 = GameLevelManager::sharedState();
SavedDailyLevel = GameLevelManager::getSavedDailyLevel(v45, (int)v44);
if ( SavedDailyLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedDailyLevel);
}
else
{
v47 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v44);
v48 = (char *)cocos2d::CCString::getCString(v47);
sub_776584((int)&v52, v48);
m_timelyCurrencyScores = a1->m_timelyCurrencyScores;
sub_776584((int)&v53, v52);
cocos2d::CCDictionary::removeObjectForKey(m_timelyCurrencyScores);
sub_774008(&v53);
m_timelyStars = a1->m_timelyStars;
sub_776584((int)v54, v52);
cocos2d::CCDictionary::removeObjectForKey(m_timelyStars);
sub_774008(v54);
sub_774008(&v52);
}
++v41;
}
return (int)v3;
}