//
// GameStatsManager::getAwardedCurrencyForLevel from 0x1401e0720 to 0x1401e0952 (562 bytes)
//
// 10 xrefs:
// > LevelCell::loadCustomLevelCell @ 0x1400b070e
// > GameStatsManager::getTotalCollectedCurrency @ 0x1401e3910
// > GameStatsManager::getTotalCollectedCurrency @ 0x1401e3a43
// > GameStatsManager::getTotalCollectedCurrency @ 0x1401e3ba3
// > GameStatsManager::getTotalCollectedCurrency @ 0x1401e3d42
// > GameStatsManager::getTotalCollectedCurrency @ 0x1401e3ea2
// > GameStatsManager::getTotalCollectedCurrency @ 0x1401e3ff2
// > LevelInfoLayer::updateLabelValues @ 0x1402ff701
// > LevelPage::updateDynamicPage @ 0x14031b335
// > ??> @ 0x1406cc4e0
//
// 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
//
// Hidden C++ exception states: #wind=2
int GameStatsManager::getAwardedCurrencyForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
int v4; // edx
cocos2d::CCDictionary *m_mainCurrencyScores; // rbp
cocos2d::CCString *v6; // rax
const char *CString; // rax
size_t v8; // rbx
size_t v9; // r8
cocos2d::CCString *v10; // rax
void **v11; // rdx
cocos2d::CCString *v12; // rax
int v13; // ebx
void *v14; // rcx
int BaseCurrencyForLevel; // eax
float v16; // xmm1_4
int v17; // ebx
void *v18; // rcx
void *v20[2]; // [rsp+28h] [rbp-60h] BYREF
__int128 v21; // [rsp+38h] [rbp-50h]
void *Block[2]; // [rsp+48h] [rbp-40h] BYREF
__int128 v23; // [rsp+58h] [rbp-30h]
v4 = a2->m_dailyID.random - a2->m_dailyID.seed;
if ( v4 <= 0 )
{
if ( a2->m_levelType == Main )
{
m_mainCurrencyScores = a1->m_mainCurrencyScores;
}
else if ( a2->m_gauntletLevel )
{
m_mainCurrencyScores = a1->m_gauntletCurrencyScores;
}
else
{
m_mainCurrencyScores = a1->m_onlineCurrencyScores;
}
v10 = cocos2d::CCString::createWithFormat("%i", a2->m_levelID.random - a2->m_levelID.seed);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)v20 = 0;
v21 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
}
else
{
m_mainCurrencyScores = a1->m_timelyCurrencyScores;
v6 = cocos2d::CCString::createWithFormat("%i", v4);
CString = cocos2d::CCString::getCString(v6);
*(_OWORD *)v20 = 0;
v21 = 0;
v8 = -1;
v9 = -1;
do
++v9;
while ( CString[v9] );
}
sub_14003A930(v20, CString, v9);
v11 = v20;
if ( *((_QWORD *)&v21 + 1) > 0xFu )
v11 = (void **)v20[0];
*(_OWORD *)Block = 0;
v23 = 0;
do
++v8;
while ( *((_BYTE *)v11 + v8) );
sub_14003A930(Block, v11, v8);
v12 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_mainCurrencyScores, Block);
v13 = cocos2d::CCString::intValue(v12);
if ( *((_QWORD *)&v23 + 1) > 0xFu )
{
v14 = Block[0];
if ( (unsigned __int64)(*((_QWORD *)&v23 + 1) + 1LL) >= 0x1000 )
{
v14 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v14 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v14);
}
BaseCurrencyForLevel = GameStatsManager::getBaseCurrencyForLevel(a1, a2);
v16 = (float)BaseCurrencyForLevel;
if ( v13 >= 100 )
v17 = BaseCurrencyForLevel + (int)(float)(v16 * 0.25);
else
v17 = (int)floorf((float)((float)v13 / 100.0) * v16);
if ( *((_QWORD *)&v21 + 1) > 0xFu )
{
v18 = v20[0];
if ( (unsigned __int64)(*((_QWORD *)&v21 + 1) + 1LL) >= 0x1000 )
{
v18 = *((void **)v20[0] - 1);
if ( (unsigned __int64)((char *)v20[0] - (char *)v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
return v17;
}