//
// GameStatsManager::awardCurrencyForLevel from 0x52a16c to 0x52a432 (710 bytes)
//
// 4 xrefs:
// > PlayLayer::destroyPlayer @ 0x405e1e
// > PlayLayer::levelComplete @ 0x4080be
// > GameLevelManager::updateLevelRewards @ 0x4ab4a8
// > GameStatsManager::awardOldSpecialStats @ 0x52a4ca
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:51:59 +0000
//
int __fastcall GameStatsManager::awardCurrencyForLevel(GameStatsManager *this, GJGameLevel *a2)
{
float v2; // s14
const char *v5; // r9
int v6; // r5
const char *v7; // r1
const char *v8; // r10
int v9; // r8
int v10; // r4
const char *v11; // r5
char *v12; // r1
size_t v13; // r0
cocos2d::CCString *v14; // r0
int v15; // s16
float BaseCurrencyForLevel; // s17
int v18; // r4
float v19; // r0
int v20; // s15
char *v21; // r1
size_t v22; // r0
int v23; // r8
size_t v24; // r0
cocos2d::CCString *v25; // r0
char *v26; // r10
cocos2d::CCObject *v27; // r9
size_t v28; // r0
_BOOL4 v29; // [sp+0h] [bp-54h]
cocos2d::CCObject *v30; // [sp+4h] [bp-50h]
cocos2d::CCObject *v31; // [sp+4h] [bp-50h]
char *v32; // [sp+Ch] [bp-48h]
unsigned __int8 v33; // [sp+10h] [bp-44h] BYREF
_BYTE v34[7]; // [sp+11h] [bp-43h] BYREF
char *v35; // [sp+18h] [bp-3Ch]
int v36[3]; // [sp+1Ch] [bp-38h] BYREF
int v37[2]; // [sp+28h] [bp-2Ch] BYREF
char *v38; // [sp+30h] [bp-24h]
int v39[3]; // [sp+34h] [bp-20h] BYREF
int v40[3]; // [sp+40h] [bp-14h] BYREF
v5 = (const char *)(*((_DWORD *)a2 + 193) - *((_DWORD *)a2 + 194));
v6 = *((_DWORD *)a2 + 172) - *((_DWORD *)a2 + 173);
v29 = *((_DWORD *)a2 + 238) == 1;
v7 = (const char *)(*((_DWORD *)a2 + 186) - *((_DWORD *)a2 + 187));
v8 = (const char *)((int)v7 > 0);
if ( (int)v7 <= 0 )
{
if ( v29 )
{
v9 = *((_DWORD *)this + 108);
}
else if ( *((_BYTE *)a2 + 477) )
{
v9 = *((_DWORD *)this + 109);
}
else
{
v9 = *((_DWORD *)this + 107);
}
}
else
{
v9 = *((_DWORD *)this + 110);
}
if ( (int)v5 <= 0 || v6 <= 0 || (int)v7 > 0 && GameStatsManager::isDailyRecall(this, v7) )
return 0;
if ( v6 > 99 )
v11 = (const char *)&dword_64;
else
v11 = (const char *)(v6 & ~(v6 >> 31));
GameStatsManager::getCurrencyKey((GameStatsManager *)&v33, this, a2);
if ( (v33 & 1) == 0 )
v12 = v34;
v36[0] = 0;
if ( (v33 & 1) != 0 )
v12 = v35;
v36[1] = 0;
v36[2] = 0;
v30 = (cocos2d::CCObject *)v12;
v13 = strlen(v12);
std::string::__init(v36, v30, v13);
v14 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v9, v36);
v15 = cocos2d::CCString::intValue(v14);
std::string::~string((int)v36);
if ( v15 >= (int)v11 )
goto LABEL_20;
BaseCurrencyForLevel = (float)GameStatsManager::getBaseCurrencyForLevel(this, a2);
v18 = (int)floorf(BaseCurrencyForLevel * (float)((float)v15 / 100.0));
v19 = floorf(BaseCurrencyForLevel * (float)((float)(int)v11 / 100.0));
if ( v11 == (const char *)&dword_64 )
v2 = 0.25;
v20 = (int)v19;
if ( v11 == (const char *)&dword_64 )
v20 = (int)(float)((float)v20 + (float)(BaseCurrencyForLevel * v2));
v10 = v20 - v18;
if ( v10 <= 0 )
{
LABEL_20:
v10 = 0;
}
else
{
v31 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v11);
v21 = (char *)(v33 << 31);
if ( (v33 & 1) == 0 )
v21 = v34;
v37[0] = 0;
if ( (v33 & 1) != 0 )
v21 = v35;
v37[1] = 0;
v38 = nullptr;
v32 = v21;
v22 = strlen(v21);
std::string::__init(v37, v32, v22);
cocos2d::CCDictionary::setObject(v9, v31);
std::string::~string((int)v37);
if ( !v29 )
{
v23 = *((_DWORD *)this + 112);
if ( !v8 )
v23 = *((_DWORD *)this + 111);
GameStatsManager::getCurrencyKey((GameStatsManager *)v37, this, a2);
if ( (v37[0] & 1) == 0 )
v8 = (char *)v37 + 1;
v39[0] = 0;
if ( (v37[0] & 1) != 0 )
v8 = v38;
v39[1] = 0;
v39[2] = 0;
v24 = strlen(v8);
std::string::__init(v39, v8, v24);
v25 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(v23, v39);
v26 = (char *)cocos2d::CCString::intValue(v25);
std::string::~string((int)v39);
if ( (int)v26 < (int)v5 )
{
v27 = (cocos2d::CCObject *)cocos2d::CCString::createWithFormat((cocos2d::CCString *)"%i", v5);
if ( (v37[0] & 1) == 0 )
v26 = (char *)v37 + 1;
v40[0] = 0;
if ( (v37[0] & 1) != 0 )
v26 = v38;
v40[1] = 0;
v40[2] = 0;
v28 = strlen(v26);
std::string::__init(v40, v26, v28);
cocos2d::CCDictionary::setObject(v23, v27);
std::string::~string((int)v40);
}
std::string::~string((int)v37);
}
GameStatsManager::incrementStat(this, "14", v10);
}
std::string::~string((int)&v33);
return v10;
}