//
// GameStatsManager::getAwardedCurrencyForLevel from 0x7a32a8 to 0x7a34d8 (560 bytes)
//
// 10 xrefs:
// > LevelCell::loadCustomLevelCell @ 0x610ed8
// > LevelInfoLayer::updateLabelValues @ 0x6d9a70
// > LevelPage::updateDynamicPage @ 0x79fdf4
// > GameStatsManager::getTotalCollectedCurrency @ 0x7a4804
// > GameStatsManager::getTotalCollectedCurrency @ 0x7a4914
// > GameStatsManager::getTotalCollectedCurrency @ 0x7a4954
// > GameStatsManager::getTotalCollectedCurrency @ 0x7a4a90
// > GameStatsManager::getTotalCollectedCurrency @ 0x7a4b14
// > GameStatsManager::getTotalCollectedCurrency @ 0x7a4b98
// > ??> @ 0xb7318
//
// 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::getAwardedCurrencyForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
bool v4; // cc
_BOOL4 m_gauntletLevel; // w1
cocos2d::CCDictionary *m_mainCurrencyScores; // x23
cocos2d::CCString *v7; // x0
int v8; // w23
char *v9; // x0
int BaseCurrencyForLevel; // w0
char *v11; // x1
float v12; // s2
char *v13; // x0
int v14; // w19
unsigned int *v16; // x1
int v17; // w2
unsigned int *v18; // x1
int v19; // w2
char *v20; // [xsp+58h] [xbp+58h] BYREF
std::string v21; // [xsp+60h] [xbp+60h] BYREF
v4 = a2->m_dailyID.random - a2->m_dailyID.seed <= 0;
m_gauntletLevel = a2->m_gauntletLevel;
if ( v4 )
{
if ( a2->m_levelType == Main )
{
m_mainCurrencyScores = a1->m_mainCurrencyScores;
}
else if ( m_gauntletLevel )
{
m_mainCurrencyScores = a1->m_gauntletCurrencyScores;
}
else
{
m_mainCurrencyScores = a1->m_onlineCurrencyScores;
}
}
else
{
m_mainCurrencyScores = a1->m_timelyCurrencyScores;
}
GameStatsManager::getCurrencyKey(a1, a2, (__int64)&v20);
sub_D153B8((int)&v21, v20);
v7 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_mainCurrencyScores, &v21);
v8 = cocos2d::CCString::intValue(v7);
v9 = (char *)v21.m_data.m_data - 24;
if ( (__int64 *)v21.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v18 = (unsigned int *)((char *)v21.m_data.m_data - 8);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *((_DWORD *)v21.m_data.m_data - 2);
*((_DWORD *)v21.m_data.m_data - 2) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v9);
}
BaseCurrencyForLevel = GameStatsManager::getBaseCurrencyForLevel(a1, a2);
if ( v8 > 99 )
{
v14 = BaseCurrencyForLevel + (int)(float)((float)BaseCurrencyForLevel * 0.25);
v11 = v20;
v13 = v20 - 24;
if ( v20 - 24 == (char *)&qword_124B6B0 )
return v14;
}
else
{
v11 = v20;
v12 = (float)BaseCurrencyForLevel;
v13 = v20 - 24;
v14 = vcvtms_s32_f32(v12 * (float)((float)v8 / 100.0));
if ( v20 - 24 == (char *)&qword_124B6B0 )
return v14;
}
if ( &pthread_create )
{
v16 = (unsigned int *)(v11 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v11 - 2);
*((_DWORD *)v11 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v13);
return v14;
}