//
// GameStatsManager::getTotalCollectedCurrency from 0x7a47a8 to 0x7a51e4 (2620 bytes)
//
// 2 xrefs:
// > GameStatsManager::recountSpecialStats @ 0x7bd5e8
// > ??> @ 0x3f8b8
//
// 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; // w19
float v3; // s8
GameLevelManager *v4; // x0
GJGameLevel *MainLevel; // x1
cocos2d::CCString *v6; // x0
char *CString; // x0
cocos2d::CCDictionary *m_mainCurrencyScores; // x21
char *v9; // x0
char *v10; // x0
unsigned int *v11; // x1
int v12; // w2
int i; // w19
GameLevelManager *v14; // x0
GJGameLevel *v15; // x1
int j; // w19
GameLevelManager *v17; // x0
GJGameLevel *v18; // x1
cocos2d::CCString *v19; // x0
char *v20; // x0
cocos2d::CCDictionary *v21; // x21
char *v22; // x0
char *v23; // x0
unsigned int *v24; // x1
int v25; // w2
unsigned int v26; // w19
cocos2d::CCArray *v27; // x22
cocos2d::CCString *v28; // x0
unsigned int v29; // w21
GameLevelManager *v30; // x0
GJGameLevel *SavedLevel; // x1
unsigned int v32; // w19
cocos2d::CCArray *v33; // x22
cocos2d::CCString *v34; // x0
unsigned int v35; // w21
GameLevelManager *v36; // x0
GJGameLevel *SavedGauntletLevel; // x1
unsigned int v38; // w19
cocos2d::CCArray *v39; // x22
cocos2d::CCString *v40; // x0
unsigned int v41; // w21
GameLevelManager *v42; // x0
GJGameLevel *SavedDailyLevel; // x1
cocos2d::CCString *v45; // x0
char *v46; // x0
cocos2d::CCDictionary *m_onlineCurrencyScores; // x21
char *v48; // x0
char *v49; // x0
unsigned int *v50; // x1
int v51; // w2
cocos2d::CCString *v52; // x0
char *v53; // x0
cocos2d::CCDictionary *m_gauntletCurrencyScores; // x21
char *v55; // x0
char *v56; // x0
unsigned int *v57; // x1
int v58; // w2
cocos2d::CCString *v59; // x0
char *v60; // x0
cocos2d::CCDictionary *m_timelyCurrencyScores; // x27
char *v62; // x0
cocos2d::CCDictionary *m_timelyStars; // x27
char *v64; // x0
char *v65; // x0
unsigned int *v66; // x1
int v67; // w2
unsigned int *v68; // x1
int v69; // w2
unsigned int *v70; // x1
int v71; // w2
cocos2d::CCString *v72; // x0
char *v73; // x0
cocos2d::CCDictionary *v74; // x21
char *v75; // x0
char *v76; // x0
unsigned int *v77; // x1
int v78; // w2
unsigned int *v79; // x1
int v80; // w2
unsigned int *v81; // x1
int v82; // w2
unsigned int *v83; // x1
int v84; // w2
unsigned int *v85; // x1
int v86; // w2
unsigned int *v87; // x1
int v88; // w2
__int64 v89; // [xsp+0h] [xbp+0h] BYREF
char *v90; // [xsp+80h] [xbp+80h] BYREF
std::string v91; // [xsp+88h] [xbp+88h] BYREF
std::string v92; // [xsp+90h] [xbp+90h] 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 *)&stru_2BF80.st_value + 4);
CString = (char *)cocos2d::CCString::getCString(v6);
sub_D153B8((int)&v91, CString);
m_mainCurrencyScores = a1->m_mainCurrencyScores;
sub_D153B8((int)&v92, (char *)v91.m_data.m_data);
cocos2d::CCDictionary::removeObjectForKey(m_mainCurrencyScores, &v92);
v9 = (char *)v92.m_data.m_data - 24;
if ( (__int64 *)v92.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v83 = (unsigned int *)((char *)v92.m_data.m_data - 8);
do
v84 = __ldaxr(v83);
while ( __stlxr(v84 - 1, v83) );
}
else
{
v84 = *((_DWORD *)v92.m_data.m_data - 2);
*((_DWORD *)v92.m_data.m_data - 2) = v84 - 1;
}
if ( v84 <= 0 )
operator delete(v9);
}
v10 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v10);
}
}
++v2;
}
while ( v2 != 23 );
for ( i = 5001; i != 5005; ++i )
{
v14 = GameLevelManager::sharedState();
v15 = GameLevelManager::getMainLevel(v14, i, 1);
if ( v15 )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, v15);
}
else
{
v72 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(_BYTE *)&stru_2BF80.st_value + 4);
v73 = (char *)cocos2d::CCString::getCString(v72);
sub_D153B8((unsigned int)&v89 + 136, v73);
v74 = a1->m_mainCurrencyScores;
sub_D153B8((int)&v92, (char *)v91.m_data.m_data);
cocos2d::CCDictionary::removeObjectForKey(v74, &v92);
v75 = (char *)v92.m_data.m_data - 24;
if ( (__int64 *)v92.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v87 = (unsigned int *)((char *)v92.m_data.m_data - 8);
do
v88 = __ldaxr(v87);
while ( __stlxr(v88 - 1, v87) );
}
else
{
v88 = *((_DWORD *)v92.m_data.m_data - 2);
*((_DWORD *)v92.m_data.m_data - 2) = v88 - 1;
}
if ( v88 <= 0 )
operator delete(v75);
}
v76 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v77 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v78 = __ldaxr(v77);
while ( __stlxr(v78 - 1, v77) );
}
else
{
v78 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v78 - 1;
}
if ( v78 <= 0 )
operator delete(v76);
}
}
}
for ( j = 2001; j != 2011; ++j )
{
v17 = GameLevelManager::sharedState();
v18 = GameLevelManager::getMainLevel(v17, j, 1);
if ( v18 )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, v18);
}
else
{
v19 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat(
(cocos2d::CCString *)"%i",
(_BYTE *)&stru_2BF80.st_value + 4);
v20 = (char *)cocos2d::CCString::getCString(v19);
sub_D153B8((int)&v91, v20);
v21 = a1->m_mainCurrencyScores;
sub_D153B8((int)&v92, (char *)v91.m_data.m_data);
cocos2d::CCDictionary::removeObjectForKey(v21, &v92);
v22 = (char *)v92.m_data.m_data - 24;
if ( (__int64 *)v92.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v85 = (unsigned int *)((char *)v92.m_data.m_data - 8);
do
v86 = __ldaxr(v85);
while ( __stlxr(v86 - 1, v85) );
}
else
{
v86 = *((_DWORD *)v92.m_data.m_data - 2);
*((_DWORD *)v92.m_data.m_data - 2) = v86 - 1;
}
if ( v86 <= 0 )
operator delete(v22);
}
v23 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v24 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v25 = __ldaxr(v24);
while ( __stlxr(v25 - 1, v24) );
}
else
{
v25 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v25 - 1;
}
if ( v25 <= 0 )
operator delete(v23);
}
}
}
v26 = 0;
v27 = cocos2d::CCDictionary::allKeys(a1->m_onlineCurrencyScores);
if ( (unsigned int)cocos2d::CCArray::count(v27) )
{
do
{
v28 = cocos2d::CCArray::stringAtIndex(v27, v26);
v29 = cocos2d::CCString::intValue(v28);
v30 = GameLevelManager::sharedState();
SavedLevel = (GJGameLevel *)GameLevelManager::getSavedLevel(v30, v29);
if ( SavedLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedLevel);
}
else
{
v45 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v29);
v46 = (char *)cocos2d::CCString::getCString(v45);
sub_D153B8((int)&v91, v46);
m_onlineCurrencyScores = a1->m_onlineCurrencyScores;
sub_D153B8((int)&v92, (char *)v91.m_data.m_data);
cocos2d::CCDictionary::removeObjectForKey(m_onlineCurrencyScores, &v92);
v48 = (char *)v92.m_data.m_data - 24;
if ( (__int64 *)v92.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v81 = (unsigned int *)((char *)v92.m_data.m_data - 8);
do
v82 = __ldaxr(v81);
while ( __stlxr(v82 - 1, v81) );
}
else
{
v82 = *((_DWORD *)v92.m_data.m_data - 2);
*((_DWORD *)v92.m_data.m_data - 2) = v82 - 1;
}
if ( v82 <= 0 )
operator delete(v48);
}
v49 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v50 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v51 = __ldaxr(v50);
while ( __stlxr(v51 - 1, v50) );
}
else
{
v51 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v51 - 1;
}
if ( v51 <= 0 )
{
++v26;
operator delete(v49);
continue;
}
}
}
++v26;
}
while ( v26 < (unsigned int)cocos2d::CCArray::count(v27) );
}
v32 = 0;
v33 = cocos2d::CCDictionary::allKeys(a1->m_gauntletCurrencyScores);
if ( (unsigned int)cocos2d::CCArray::count(v33) )
{
do
{
v34 = cocos2d::CCArray::stringAtIndex(v33, v32);
v35 = cocos2d::CCString::intValue(v34);
v36 = GameLevelManager::sharedState();
SavedGauntletLevel = GameLevelManager::getSavedGauntletLevel(v36, v35);
if ( SavedGauntletLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedGauntletLevel);
}
else
{
v52 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v35);
v53 = (char *)cocos2d::CCString::getCString(v52);
sub_D153B8((int)&v91, v53);
m_gauntletCurrencyScores = a1->m_gauntletCurrencyScores;
sub_D153B8((int)&v92, (char *)v91.m_data.m_data);
cocos2d::CCDictionary::removeObjectForKey(m_gauntletCurrencyScores, &v92);
v55 = (char *)v92.m_data.m_data - 24;
if ( (__int64 *)v92.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v79 = (unsigned int *)((char *)v92.m_data.m_data - 8);
do
v80 = __ldaxr(v79);
while ( __stlxr(v80 - 1, v79) );
}
else
{
v80 = *((_DWORD *)v92.m_data.m_data - 2);
*((_DWORD *)v92.m_data.m_data - 2) = v80 - 1;
}
if ( v80 <= 0 )
operator delete(v55);
}
v56 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v57 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v58 = __ldaxr(v57);
while ( __stlxr(v58 - 1, v57) );
}
else
{
v58 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v58 - 1;
}
if ( v58 <= 0 )
{
++v32;
operator delete(v56);
continue;
}
}
}
++v32;
}
while ( v32 < (unsigned int)cocos2d::CCArray::count(v33) );
}
v38 = 0;
v39 = cocos2d::CCDictionary::allKeys(a1->m_timelyCurrencyScores);
if ( (unsigned int)cocos2d::CCArray::count(v39) )
{
do
{
v40 = cocos2d::CCArray::stringAtIndex(v39, v38);
v41 = cocos2d::CCString::intValue(v40);
v42 = GameLevelManager::sharedState();
SavedDailyLevel = GameLevelManager::getSavedDailyLevel(v42, v41);
if ( SavedDailyLevel )
{
v3 = v3 + (float)GameStatsManager::getAwardedCurrencyForLevel(a1, SavedDailyLevel);
}
else
{
v59 = (cocos2d::CCString *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", (const char *)v41);
v60 = (char *)cocos2d::CCString::getCString(v59);
sub_D153B8((int)&v90, v60);
m_timelyCurrencyScores = a1->m_timelyCurrencyScores;
sub_D153B8((int)&v91, v90);
cocos2d::CCDictionary::removeObjectForKey(m_timelyCurrencyScores, &v91);
v62 = (char *)v91.m_data.m_data - 24;
if ( (__int64 *)v91.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v70 = (unsigned int *)((char *)v91.m_data.m_data - 8);
do
v71 = __ldaxr(v70);
while ( __stlxr(v71 - 1, v70) );
}
else
{
v71 = *((_DWORD *)v91.m_data.m_data - 2);
*((_DWORD *)v91.m_data.m_data - 2) = v71 - 1;
}
if ( v71 <= 0 )
operator delete(v62);
}
m_timelyStars = a1->m_timelyStars;
sub_D153B8((int)&v92, v90);
cocos2d::CCDictionary::removeObjectForKey(m_timelyStars, &v92);
v64 = (char *)v92.m_data.m_data - 24;
if ( (__int64 *)v92.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v68 = (unsigned int *)((char *)v92.m_data.m_data - 8);
do
v69 = __ldaxr(v68);
while ( __stlxr(v69 - 1, v68) );
}
else
{
v69 = *((_DWORD *)v92.m_data.m_data - 2);
*((_DWORD *)v92.m_data.m_data - 2) = v69 - 1;
}
if ( v69 <= 0 )
operator delete(v64);
}
v65 = v90 - 24;
if ( v90 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v66 = (unsigned int *)(v90 - 8);
do
v67 = __ldaxr(v66);
while ( __stlxr(v67 - 1, v66) );
}
else
{
v67 = *((_DWORD *)v90 - 2);
*((_DWORD *)v90 - 2) = v67 - 1;
}
if ( v67 <= 0 )
{
++v38;
operator delete(v65);
continue;
}
}
}
++v38;
}
while ( v38 < (unsigned int)cocos2d::CCArray::count(v39) );
}
return (int)v3;
}