//
// GameStatsManager::preProcessReward from 0x7b3824 to 0x7b3ad0 (684 bytes)
//
// 5 xrefs:
// > GameStatsManager::unlockSpecialChest @ 0x7bbbb8
// > GameStatsManager::unlockSecretChest @ 0x7bc094
// > GameStatsManager::unlockGoldChest @ 0x7bc220
// > RewardsPage::rewardsStatusFinished @ 0x93a3e4
// > ??> @ 0x36330
//
// 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)
{
int v3; // w23
cocos2d::CCArray *m_rewardObjects; // x21
unsigned int v6; // w19
__int64 v7; // x20
GJRewardObject *RewardObjectForType; // x0
int Stat; // w2
const char *v10; // x1
char *v11; // x0
int v12; // w1
char *v13; // x0
unsigned int *v14; // x1
int v15; // w4
unsigned int *v16; // x1
int v17; // w3
int v18; // [xsp+70h] [xbp+70h]
int v19; // [xsp+70h] [xbp+70h]
const char *v20; // [xsp+88h] [xbp+88h] BYREF
const char *v21; // [xsp+90h] [xbp+90h] BYREF
v3 = 0;
m_rewardObjects = a2->m_rewardObjects;
v6 = 0;
if ( m_rewardObjects )
{
LABEL_2:
if ( v6 < (unsigned int)cocos2d::CCArray::count(m_rewardObjects) )
{
while ( 1 )
{
v7 = cocos2d::CCArray::objectAtIndex(m_rewardObjects, v6);
if ( !GJRewardItem::isShardType(*(SpecialRewardItem *)(v7 + 56)) )
goto LABEL_4;
GJRewardItem::rewardItemToStat(*(_DWORD *)(v7 + 56), (__int64)&v20);
if ( GameStatsManager::getStat(a1, v20) > 99 )
break;
GJRewardItem::rewardItemToStat(*(_DWORD *)(v7 + 56), (__int64)&v21);
Stat = GameStatsManager::getStat(a1, v21);
v13 = (char *)(v21 - 24);
if ( v21 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_10;
if ( &pthread_create )
{
v14 = (unsigned int *)(v21 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *((_DWORD *)v21 - 2);
*((_DWORD *)v21 - 2) = v15 - 1;
}
if ( v15 > 0 )
goto LABEL_10;
v18 = Stat;
operator delete(v13);
v10 = v20;
Stat = v18;
v11 = (char *)(v20 - 24);
if ( v20 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_11;
LABEL_20:
if ( &pthread_create )
{
v16 = (unsigned int *)(v10 - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v10 - 2);
*((_DWORD *)v10 - 2) = v17 - 1;
}
if ( v17 <= 0 )
{
v19 = Stat;
operator delete(v11);
Stat = v19;
}
LABEL_11:
v12 = *(_DWORD *)(v7 + 68);
if ( Stat + v12 > 99 )
{
*(_DWORD *)(v7 + 68) = 100 - Stat;
v3 += Stat + v12 - 100;
if ( 100 - Stat <= 0 )
{
cocos2d::CCArray::removeObjectAtIndex(m_rewardObjects, v6, 1);
goto LABEL_2;
}
}
LABEL_4:
if ( ++v6 >= (unsigned int)cocos2d::CCArray::count(m_rewardObjects) )
goto LABEL_5;
}
Stat = 100;
LABEL_10:
v10 = v20;
v11 = (char *)(v20 - 24);
if ( v20 - 24 == (const char *)&qword_124B6B0 )
goto LABEL_11;
goto LABEL_20;
}
LABEL_5:
if ( v3 )
{
RewardObjectForType = GJRewardItem::getRewardObjectForType(a2, BonusKey|FireShard);
RewardObjectForType->m_total = (int)(float)((float)RewardObjectForType->m_total + (float)((float)v3 * 100.0));
}
}
}