//
// GameStatsManager::preProcessReward from 0x522bc0 to 0x522cce (270 bytes)
//
// 4 xrefs:
// > GameStatsManager::unlockSpecialChest @ 0x52aab6
// > GameStatsManager::unlockSecretChest @ 0x52acb6
// > GameStatsManager::unlockGoldChest @ 0x52ad76
// > RewardsPage::rewardsStatusFinished @ 0x61955c
//
// 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:52 +0000
//
cocos2d::CCObject *__fastcall GameStatsManager::preProcessReward(cocos2d::CCObject *this, GJRewardItem *a2)
{
cocos2d::CCArray *v2; // r8
GameStatsManager *v3; // r11
unsigned int v4; // r5
int v5; // r6
int v6; // r7
const char *v7; // r1
const char *v8; // r1
int Stat; // r4
int v10; // r3
int v11; // r4
int v12; // r4
int v13; // r4
int v15[3]; // [sp+Ch] [bp-20h] BYREF
int v16[3]; // [sp+18h] [bp-14h] BYREF
v2 = *((cocos2d::CCArray **)a2 + 16);
v3 = this;
if ( v2 )
{
v4 = 0;
v5 = 0;
while ( 1 )
{
this = (cocos2d::CCObject *)cocos2d::CCArray::count(v2);
if ( v4 >= (unsigned int)this )
break;
v6 = cocos2d::CCArray::objectAtIndex(v2, v4);
if ( !GJRewardItem::isShardType(*(_DWORD *)(v6 + 52)) )
goto LABEL_19;
GJRewardItem::rewardItemToStat(v15, *(_DWORD *)(v6 + 52));
v7 = (v15[0] & 1) != 0 ? (const char *)v15[2] : (char *)v15 + 1;
if ( GameStatsManager::getStat(v3, v7) > 99 )
{
Stat = 100;
}
else
{
GJRewardItem::rewardItemToStat(v16, *(_DWORD *)(v6 + 52));
v8 = (v16[0] & 1) != 0 ? (const char *)v16[2] : (char *)v16 + 1;
Stat = GameStatsManager::getStat(v3, v8);
std::string::~string((int)v16);
}
std::string::~string((int)v15);
v10 = *(_DWORD *)(v6 + 64);
v11 = Stat + v10;
if ( v11 > 99 && (v12 = v11 - 100, v5 += v12, v13 = v10 - v12, *(_DWORD *)(v6 + 64) = v13, v13 <= 0) )
cocos2d::CCArray::removeObjectAtIndex(v2, v4, 1);
else
LABEL_19:
++v4;
}
if ( v5 )
{
this = GJRewardItem::getRewardObjectForType((int)a2, 7);
*((_DWORD *)this + 16) = (int)(float)((float)*((int *)this + 16) + (float)((float)v5 * 100.0));
}
}
return this;
}