//
// GJRewardItem::init from 0x40e698 to 0x40e77c (228 bytes)
//
// 1 xrefs:
// > GJRewardItem::create @ 0x40e7ca
//
// 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
//
int __fastcall GJRewardItem::init(int a1, int a2, int a3, cocos2d::CCArray *a4)
{
cocos2d::CCArray_vtbl *v5; // r2
cocos2d::CCArray *v6; // r4
cocos2d::CCString *v7; // r0
int v8; // r10
cocos2d::CCString *v9; // r0
int v10; // r9
cocos2d::CCString *v11; // r0
SpecialRewardItem v12; // r7
cocos2d::CCString *v13; // r0
cocos2d::CCArray *v14; // r0
SpecialRewardItem v15; // r5
int v16; // r8
cocos2d::CCArray *v17; // r4
GJRewardObject *v18; // r0
GJRewardObject *v19; // r0
GJRewardObject *v20; // r0
GJRewardObject *v21; // r0
*(_DWORD *)(a1 + 56) = a3;
v5 = a4->__vftable;
*(_DWORD *)(a1 + 52) = a2;
if ( v5[-1].canEncode )
{
v6 = sub_40C12C(a4, ",");
if ( cocos2d::CCArray::count(v6) > 3u )
{
v7 = cocos2d::CCArray::stringAtIndex(v6, 0);
v8 = cocos2d::CCString::intValue(v7);
v9 = cocos2d::CCArray::stringAtIndex(v6, 1u);
v10 = cocos2d::CCString::intValue(v9);
v11 = cocos2d::CCArray::stringAtIndex(v6, 2u);
v12 = cocos2d::CCString::intValue(v11);
v13 = cocos2d::CCArray::stringAtIndex(v6, 3u);
v14 = (cocos2d::CCArray *)cocos2d::CCString::intValue(v13);
v15 = (SpecialRewardItem)v14;
if ( (cocos2d::CCArray *)v12 == v14 )
{
v16 = 2;
v15 = 0;
}
else
{
v16 = 1;
}
v17 = (cocos2d::CCArray *)cocos2d::CCArray::create(v14);
if ( v8 > 0 )
{
v18 = GJRewardObject::create(BonusKey|FireShard, v8, 0);
cocos2d::CCArray::addObject(v17, v18);
}
if ( v10 > 0 )
{
v19 = GJRewardObject::create(Diamonds, v10, 0);
cocos2d::CCArray::addObject(v17, v19);
}
if ( v12 )
{
v20 = GJRewardObject::create(v12, v16, 0);
cocos2d::CCArray::addObject(v17, v20);
}
if ( v15 )
{
v21 = GJRewardObject::create(v15, 1, 0);
cocos2d::CCArray::addObject(v17, v21);
}
if ( cocos2d::CCArray::count(v17) )
sub_40C47A((cocos2d::CCObject **)(a1 + 64), v17);
}
}
return 1;
}