//
// GameStatsManager::preProcessReward from 0x418858 to 0x41894e (246 bytes)
//
// 4 xrefs:
// > GameStatsManager::unlockSpecialChest @ 0x41c7f2
// > GameStatsManager::unlockSecretChest @ 0x41c96a
// > GameStatsManager::unlockGoldChest @ 0x41ca1a
// > RewardsPage::rewardsStatusFinished @ 0x4e9ce8
//
// 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 GameStatsManager::preProcessReward(GameStatsManager *a1, GJRewardItem *a2)
{
cocos2d::CCArray *m_rewardObjects; // r8
unsigned int v4; // r5
int v5; // r6
int v6; // r7
int Stat; // r4
int v8; // r3
int v9; // r4
int v10; // r4
int v11; // r4
GJRewardObject *RewardObjectForType; // r0
char *v14; // [sp+Ch] [bp-10h] BYREF
char *v15; // [sp+10h] [bp-Ch] BYREF
m_rewardObjects = a2->m_rewardObjects;
if ( m_rewardObjects )
{
v4 = 0;
v5 = 0;
while ( v4 < cocos2d::CCArray::count(m_rewardObjects) )
{
v6 = cocos2d::CCArray::objectAtIndex(m_rewardObjects, v4);
if ( !GJRewardItem::isShardType(*(SpecialRewardItem *)(v6 + 52)) )
goto LABEL_13;
GJRewardItem::rewardItemToStat((int)&v14, *(_DWORD *)(v6 + 52));
if ( GameStatsManager::getStat(a1, v14) > 99 )
{
Stat = 100;
}
else
{
GJRewardItem::rewardItemToStat((int)&v15, *(_DWORD *)(v6 + 52));
Stat = GameStatsManager::getStat(a1, v15);
sub_774008(&v15);
}
sub_774008(&v14);
v8 = *(_DWORD *)(v6 + 64);
v9 = Stat + v8;
if ( v9 > 99 && (v10 = v9 - 100, v5 += v10, v11 = v8 - v10, *(_DWORD *)(v6 + 64) = v11, v11 <= 0) )
cocos2d::CCArray::removeObjectAtIndex(m_rewardObjects, v4, 1);
else
LABEL_13:
++v4;
}
if ( v5 )
{
RewardObjectForType = GJRewardItem::getRewardObjectForType(a2, BonusKey|FireShard);
RewardObjectForType->m_total = (int)(float)((float)RewardObjectForType->m_total + (float)((float)v5 * 100.0));
}
}
}