//
// GameStatsManager::awardCurrencyForLevel from 0x100332810 to 0x100332ad0 (704 bytes)
//
// 3 xrefs:
// > GameLevelManager::updateLevelRewards @ 0x100093a9c
// > PlayLayer::levelComplete @ 0x100119fe8
// > PlayLayer::destroyPlayer @ 0x10011f048
//
// 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
//
void __fastcall GameStatsManager::awardCurrencyForLevel(GameStatsManager *a1, GJGameLevel *a2)
{
int v2; // w24
unsigned int v3; // w23
GJLevelType m_levelType; // w27
int random; // w25
int seed; // w26
__int64 v7; // x8
__int64 v11; // x22
int v12; // w28
char *v13; // x1
cocos2d::CCString *v14; // x0
int v15; // w20
int BaseCurrencyForLevel; // w0
unsigned int v17; // w8
float v18; // s1
unsigned int v19; // w9
int v20; // w10
int v21; // w20
cocos2d::CCObject *v22; // x23
char *v23; // x1
__int64 v24; // x8
__int64 v25; // x22
char *v26; // x1
cocos2d::CCString *v27; // x0
int v28; // w21
cocos2d::CCObject *v29; // x21
char *v30; // x1
void *v31[2]; // [xsp+8h] [xbp-98h] BYREF
char v32; // [xsp+1Fh] [xbp-81h]
void *__p[2]; // [xsp+20h] [xbp-80h] BYREF
char v34; // [xsp+37h] [xbp-69h]
void *v35[2]; // [xsp+38h] [xbp-68h] BYREF
char v36; // [xsp+4Fh] [xbp-51h]
v2 = a2->m_stars.random - a2->m_stars.seed;
v3 = a2->m_orbCompletion.random - a2->m_orbCompletion.seed;
m_levelType = a2->m_levelType;
random = a2->m_dailyID.random;
seed = a2->m_dailyID.seed;
v7 = 640;
if ( a2->m_gauntletLevel )
v7 = 656;
if ( m_levelType == Main )
v7 = 648;
if ( random > seed )
v7 = 664;
if ( v2 >= 1 && (int)v3 >= 1 )
{
v11 = *(__int64 *)((char *)&a1->__vftable + v7);
if ( v3 >= 0x64 )
v12 = 100;
else
v12 = a2->m_orbCompletion.random - a2->m_orbCompletion.seed;
GameStatsManager::getCurrencyKey(a2, v35);
if ( v36 >= 0 )
v13 = (char *)v35;
else
v13 = (char *)v35[0];
sub_100009900(__p, v13);
v14 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(v11, __p);
v15 = cocos2d::CCString::intValue(v14);
if ( v34 < 0 )
operator delete(__p[0]);
if ( v15 < v12 )
{
BaseCurrencyForLevel = GameStatsManager::getBaseCurrencyForLevel(a1, a2);
v17 = vcvtms_s32_f32((float)((float)v15 / 100.0) * (float)BaseCurrencyForLevel);
v18 = (float)((float)(unsigned int)v12 / 100.0) * (float)BaseCurrencyForLevel;
v19 = vcvtms_s32_f32(v18);
v20 = (int)(float)((float)(int)floorf(v18) + (float)((float)BaseCurrencyForLevel * 0.25));
if ( v3 > 0x63 )
v19 = v20;
v21 = v19 - v17;
if ( (int)(v19 - v17) >= 1 )
{
v22 = sub_100268F4C("%i", v12);
if ( v36 >= 0 )
v23 = (char *)v35;
else
v23 = (char *)v35[0];
sub_100009900(__p, v23);
cocos2d::CCDictionary::setObject_1(v11, v22, __p);
if ( v34 < 0 )
operator delete(__p[0]);
if ( m_levelType != Main )
{
v24 = 672;
if ( random > seed )
v24 = 680;
v25 = *(__int64 *)((char *)&a1->__vftable + v24);
GameStatsManager::getCurrencyKey(a2, __p);
if ( v34 >= 0 )
v26 = (char *)__p;
else
v26 = (char *)__p[0];
sub_100009900(v31, v26);
v27 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey_1(v25, v31);
v28 = cocos2d::CCString::intValue(v27);
if ( v32 < 0 )
operator delete(v31[0]);
if ( v28 < v2 )
{
v29 = sub_100268F4C("%i", v2);
v30 = v34 >= 0 ? (char *)__p : (char *)__p[0];
sub_100009900(v31, v30);
cocos2d::CCDictionary::setObject_1(v25, v29, v31);
if ( v32 < 0 )
operator delete(v31[0]);
}
if ( v34 < 0 )
operator delete(__p[0]);
}
GameStatsManager::incrementStat(a1, "14", v21);
}
}
if ( v36 < 0 )
operator delete(v35[0]);
}
}