//
// RewardUnlockLayer::init from 0x1403cddf0 to 0x1403ceafd (3341 bytes)
//
// 2 xrefs:
// > RewardUnlockLayer::create @ 0x1403cdda6
// > ??> @ 0x1406d7c04
//
// 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
//
// Hidden C++ exception states: #wind=6
bool RewardUnlockLayer::init(RewardUnlockLayer *a1, int a2, RewardsPage *a3)
{
bool result; // al
__int64 v7; // rcx
cocos2d::CCArray *v8; // rax
__int64 v9; // rcx
cocos2d::CCDirector *v10; // rax
__int64 *v11; // rdx
size_t v12; // r8
float v13; // xmm11_4
const char *v14; // rbx
struct cocos2d::CCRect *v15; // rax
CCLightFlash *v16; // rsi
CCLightFlash_vtbl *v17; // rbx
const cocos2d::CCSize *v18; // rax
float v19; // xmm0_4
CCLightFlash_vtbl *v20; // rbx
const cocos2d::CCPoint *v21; // rax
struct cocos2d::CCFadeIn *v22; // rax
cocos2d::ccColor3B *v23; // r8
struct cocos2d::CCRect *v24; // rax
CCLightFlash *v25; // rdi
CCLightFlash_vtbl *v26; // rbx
const cocos2d::CCSize *v27; // rax
float v28; // xmm0_4
CCLightFlash_vtbl *v29; // rbx
const cocos2d::CCPoint *v30; // rax
struct cocos2d::CCFadeIn *v31; // rax
cocos2d::ccColor3B *v32; // r8
struct cocos2d::CCFadeTo *v33; // rax
cocos2d::ccColor3B *v34; // r8
int i; // esi
__int128 *v36; // rdx
float v37; // xmm0_4
size_t v38; // r8
CCSpriteWithHue *v39; // rdi
void *origin; // rcx
float j; // xmm0_4
float v42; // xmm7_4
CCSpriteWithHue_vtbl *v43; // rbx
double v44; // xmm0_8
CCSpriteWithHue_vtbl *v45; // rbx
CCSpriteWithHue_vtbl *v46; // rbx
double v47; // xmm0_8
CCSpriteWithHue_vtbl *v48; // rbx
double v49; // xmm0_8
CCSpriteWithHue_vtbl *v50; // rbx
const cocos2d::CCPoint *v51; // rax
struct cocos2d::CCFadeIn *v52; // rax
cocos2d::ccColor3B *v53; // r8
GJChestSprite *v54; // rax
float v55; // xmm0_4
double v56; // xmm0_8
struct cocos2d::CCMoveTo *v57; // rax
struct cocos2d::CCEaseBounceOut *v58; // rax
cocos2d::ccColor3B *v59; // r8
struct cocos2d::CCDelayTime *v60; // rbx
__int64 v61; // rax
struct cocos2d::CCSequence *v62; // rax
cocos2d::ccColor3B *v63; // r8
CCLightFlash *v64; // rbx
float v65; // xmm6_4
struct cocos2d::CCFadeTo *v66; // rax
cocos2d::ccColor3B *v67; // r8
struct cocos2d::CCScaleTo *v68; // rax
struct cocos2d::CCEaseBounceOut *v69; // rax
cocos2d::ccColor3B *v70; // r8
const struct cocos2d::CCPoint *v71; // rax
struct cocos2d::CCMoveBy *v72; // r13
const struct cocos2d::CCPoint *v73; // rax
struct cocos2d::CCMoveBy *v74; // r12
const struct cocos2d::CCPoint *v75; // rax
struct cocos2d::CCMoveBy *v76; // r15
const struct cocos2d::CCPoint *v77; // rax
float v78; // r14d
const struct cocos2d::CCPoint *v79; // rax
const struct cocos2d::CCPoint *v80; // rax
struct cocos2d::CCSequence *v81; // rax
RewardUnlockLayer *v82; // rdi
cocos2d::ccColor3B *v83; // r8
struct cocos2d::CCSprite *v84; // rsi
CCMenuItemSpriteExtra *v85; // rax
cocos2d::CCObject *v86; // rbx
struct cocos2d::CCSprite *v87; // rsi
CCMenuItemSpriteExtra *v88; // rax
cocos2d::CCObject *v89; // rbx
struct cocos2d::CCMenu *v90; // rax
float v91; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v92; // rbx
struct cocos2d::CCPoint v93; // rax
float v94; // xmm0_4
CCMenuItemSpriteExtra_vtbl *v95; // rbx
struct cocos2d::CCPoint v96; // rax
struct cocos2d::CCLabelBMFont *v97; // rax
float v98; // xmm0_4
cocos2d::CCLabelBMFont_vtbl *v99; // rbx
const cocos2d::CCPoint *v100; // rax
__int64 v101; // rbx
struct cocos2d::CCDelayTime *v102; // rax
struct cocos2d::CCSequence *v103; // rax
cocos2d::ccColor3B *v104; // r8
float v105; // [rsp+28h] [rbp-E0h]
float v106; // [rsp+28h] [rbp-E0h]
float v107; // [rsp+28h] [rbp-E0h]
float v108; // [rsp+28h] [rbp-E0h]
float v109; // [rsp+28h] [rbp-E0h]
float v110; // [rsp+28h] [rbp-E0h]
float v111; // [rsp+28h] [rbp-E0h]
float v112; // [rsp+28h] [rbp-E0h]
__int16 v113; // [rsp+58h] [rbp-B0h]
__int16 v114; // [rsp+5Ch] [rbp-ACh] BYREF
char v115; // [rsp+5Eh] [rbp-AAh]
__int64 v116; // [rsp+60h] [rbp-A8h]
struct cocos2d::CCDelayTime *v117; // [rsp+68h] [rbp-A0h] BYREF
struct cocos2d::CCPoint v118; // [rsp+70h] [rbp-98h] BYREF
RewardUnlockLayer *v119; // [rsp+78h] [rbp-90h]
struct cocos2d::CCPoint v120; // [rsp+88h] [rbp-80h] BYREF
cocos2d::CCRect v121; // [rsp+A8h] [rbp-60h] BYREF
__int64 v122; // [rsp+B8h] [rbp-50h]
unsigned __int64 v123; // [rsp+C0h] [rbp-48h]
__int128 v124; // [rsp+C8h] [rbp-40h] BYREF
__int64 v125; // [rsp+D8h] [rbp-30h]
unsigned __int64 v126; // [rsp+E0h] [rbp-28h]
__int128 v127; // [rsp+E8h] [rbp-20h] BYREF
__int64 v128; // [rsp+F8h] [rbp-10h]
unsigned __int64 v129; // [rsp+100h] [rbp-8h]
__int128 v130; // [rsp+108h] [rbp+0h] BYREF
__int64 v131; // [rsp+118h] [rbp+10h]
__int64 v132; // [rsp+120h] [rbp+18h]
v119 = a1;
result = FLAlertLayer::init_1(a1, 0);
if ( result )
{
v8 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
a1->m_backgroundObjects = v8;
cocos2d::CCObject::retain(v8);
v10 = (cocos2d::CCDirector *)cocos2d::CCDirector::sharedDirector(v9);
cocos2d::CCDirector::getWinSize(v10);
v11 = (__int64 *)"GJ_square02.png";
if ( a2 > 5 )
v11 = &qword_14054C518;
v127 = 0;
v128 = 0;
v129 = 0;
v12 = -1;
do
++v12;
while ( *((_BYTE *)v11 + v12) );
sub_14003A930(&v127, v11, v12);
v124 = 0;
v125 = 0;
v126 = 0;
sub_14003A930(&v124, "rewardCorner_001.png", 0x14u);
v114 = -1;
v115 = -1;
v13 = 0.0;
switch ( a2 )
{
case 6:
v113 = 17421;
v115 = 104;
break;
case 7:
v113 = 25907;
v115 = 74;
v13 = -50.0;
break;
case 8:
v113 = 8777;
v115 = 94;
v13 = 80.0;
break;
case 9:
v113 = 9522;
v115 = 56;
break;
default:
goto LABEL_15;
}
v114 = v113;
LABEL_15:
v14 = (const char *)&v127;
if ( v129 > 0xF )
v14 = (const char *)v127;
cocos2d::CCRect::CCRect(&v121, 0.0, 0.0, 80.0, 80.0);
v16 = (CCLightFlash *)cocos2d::extension::CCScale9Sprite::create(v14, v15);
(*(void (__fastcall **)(cocos2d::CCArray **, _QWORD))&v16->m_lightStripArray->m_unknown2)(
&v16->m_lightStripArray,
0);
v17 = v16->__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v117, 340.0, 220.0);
v17->setContentSize(v16, v18);
v19 = ((float (__fastcall *)(cocos2d::CCLayer *, CCLightFlash *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v16,
0xFFFFFFFFLL);
v20 = v16->__vftable;
cocos2d::CCPoint::CCPoint(v19, *(float *)&v116 * 0.5);
v20->setPosition_0(v16, v21);
v22 = cocos2d::CCFadeIn::create(0.2);
cocos2d::CCNode::runAction(v16, (cocos2d::CCPoint)v22, v23, 80.0, v105);
((void (__fastcall *)(cocos2d::CCArray **, __int16 *))v16->m_lightStripArray->__vftable)(
&v16->m_lightStripArray,
&v114);
cocos2d::CCArray::addObject(a1->m_backgroundObjects, v16);
if ( a2 > 5 )
{
cocos2d::CCRect::CCRect(&v121, 0.0, 0.0, 80.0, 80.0);
v25 = (CCLightFlash *)cocos2d::extension::CCScale9Sprite::create("GJ_square07.png", v24);
(*(void (__fastcall **)(cocos2d::CCArray **, _QWORD))&v25->m_lightStripArray->m_unknown2)(
&v25->m_lightStripArray,
0);
v26 = v25->__vftable;
cocos2d::CCSize::CCSize((cocos2d::CCSize *)&v117, 340.0, 220.0);
v26->setContentSize(v25, v27);
v28 = ((float (__fastcall *)(cocos2d::CCLayer *, CCLightFlash *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v25,
4294967294LL);
v29 = v25->__vftable;
cocos2d::CCPoint::CCPoint(v28, *(float *)&v116 * 0.5);
v29->setPosition_0(v25, v30);
v31 = cocos2d::CCFadeIn::create(0.2);
cocos2d::CCNode::runAction(v25, (cocos2d::CCPoint)v31, v32, 80.0, v107);
cocos2d::CCArray::addObject(a1->m_backgroundObjects, v25);
}
v33 = cocos2d::CCFadeTo::create(0.2, 0x96u);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v33, v34, 80.0, v106);
for ( i = 0; i < 4; ++i )
{
v36 = &v124;
v37 = 0.0;
v38 = -1;
if ( a2 == 9 )
{
if ( v126 > 0xF )
v36 = (__int128 *)v124;
v130 = 0;
v131 = 0;
v132 = 0;
do
++v38;
while ( *((_BYTE *)v36 + v38) );
sub_14003A930(&v130, v36, v38);
v39 = CCSpriteGrayscale::createWithSpriteFrameName((__int64)&v130);
sub_14003A830((__int64)&v130);
}
else
{
if ( v126 > 0xF )
v36 = (__int128 *)v124;
v121 = 0;
v122 = 0;
v123 = 0;
do
++v38;
while ( *((_BYTE *)v36 + v38) );
sub_14003A930(&v121, v36, v38);
v39 = sub_140048500((__int64)&v121);
if ( v123 > 0xF )
{
origin = (void *)v121.origin;
if ( v123 + 1 >= 0x1000 )
{
origin = *(void **)(*(_QWORD *)&v121.origin - 8LL);
if ( (unsigned __int64)(*(_QWORD *)&v121.origin - (_QWORD)origin - 8LL) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(origin);
}
v122 = 0;
v123 = 15;
LOBYTE(v121.origin.x) = 0;
if ( a2 > 5 )
{
for ( j = v13; j < 0.0; j = j + 360.0 )
;
v37 = (float)(j / 360.0) * 6.283185307179586;
v39->m_hue = v37;
CCSpriteWithHue::updateColorMatrix(v39);
}
}
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v39, 8);
cocos2d::CCArray::addObject(a1->m_backgroundObjects, v39);
v42 = 145.0;
if ( i )
{
switch ( i )
{
case 1:
v42 = -145.0;
v48 = v39->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v49 = ((double (__fastcall *)(CCSpriteWithHue *))v39->getScaleY)(v39);
v37 = *(float *)&v49 * -1.0;
((void (__fastcall *)(CCSpriteWithHue *))v48->setScaleY)(v39);
break;
case 2:
v45 = v39->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v39->getScaleX(v39);
((void (__fastcall *)(CCSpriteWithHue *))v45->setScaleX)(v39);
v46 = v39->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v47 = ((double (__fastcall *)(CCSpriteWithHue *))v39->getScaleY)(v39);
v37 = *(float *)&v47 * -1.0;
((void (__fastcall *)(CCSpriteWithHue *))v46->setScaleY)(v39);
break;
case 3:
v43 = v39->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v44 = ((double (__fastcall *)(CCSpriteWithHue *))v39->getScaleX)(v39);
v37 = *(float *)&v44 * -1.0;
((void (__fastcall *)(CCSpriteWithHue *))v43->setScaleX)(v39);
break;
}
}
else
{
v42 = -145.0;
}
v50 = v39->cocos2d::CCSprite::cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v37, (float)(*(float *)&v116 * 0.5) + v42);
v50->setPosition_0(v39, v51);
v52 = cocos2d::CCFadeIn::create(0.2);
cocos2d::CCNode::runAction((CCLightFlash *)v39, (cocos2d::CCPoint)v52, v53, 80.0, v108);
}
a1->m_rewardsPage = a3;
if ( a3 )
cocos2d::CCObject::retain(a3);
a1->m_chestType = a2;
v54 = GJChestSprite::create(a2);
a1->m_chestSprite = v54;
v55 = ((float (__fastcall *)(cocos2d::CCLayer *, GJChestSprite *, __int64))a1->m_mainLayer->addChild_0)(
a1->m_mainLayer,
v54,
2);
v56 = cocos2d::CCPoint::CCPoint(v55, *(float *)&v116 * 0.5);
a1->m_chestSprite->getContentSize(a1->m_chestSprite);
cocos2d::CCPoint::CCPoint(*(float *)&v56, 0.0);
cocos2d::CCPoint::operator+(&v118, &v117);
a1->m_chestSprite->setPosition_0(a1->m_chestSprite, (const cocos2d::CCPoint *)&v117);
v57 = cocos2d::CCMoveTo::create(1.0, &v118);
v58 = cocos2d::CCEaseBounceOut::create(v57);
cocos2d::CCNode::runAction((CCLightFlash *)a1->m_chestSprite, (cocos2d::CCPoint)v58, v59, 80.0, v108);
v60 = cocos2d::CCDelayTime::create(0.36000001);
v61 = cocos2d::CCCallFunc::create(a1, RewardUnlockLayer::playDropSound);
v62 = cocos2d::CCSequence::create(v60, v61, 0);
cocos2d::CCNode::runAction((CCLightFlash *)a1, (cocos2d::CCPoint)v62, v63, 80.0, v109);
v64 = (CCLightFlash *)cocos2d::CCSprite::createWithSpriteFrameName("chest_shadow_001.png");
if ( a2 == 1 )
v65 = 0.80000001;
else
v65 = 1.0;
cocos2d::CCPoint::CCPoint(0.36000001, 0.0);
cocos2d::CCPoint::operator+(&v118, &v117);
v64->setPosition_0(v64, (const cocos2d::CCPoint *)&v117);
a1->m_mainLayer->addChild_0(a1->m_mainLayer, v64, 1);
(*(void (__fastcall **)(cocos2d::CCArray **, _QWORD))&v64->m_lightStripArray->m_unknown2)(
&v64->m_lightStripArray,
0);
((void (__fastcall *)(CCLightFlash *))v64->setScale_0)(v64);
v66 = cocos2d::CCFadeTo::create(0.40000001, 0x5Au);
cocos2d::CCNode::runAction(v64, (cocos2d::CCPoint)v66, v67, 80.0, v110);
v68 = cocos2d::CCScaleTo::create(1.0, v65 * 0.94999999);
v69 = cocos2d::CCEaseBounceOut::create(v68);
cocos2d::CCNode::runAction(v64, (cocos2d::CCPoint)v69, v70, 80.0, v111);
v117 = cocos2d::CCDelayTime::create(1.2);
cocos2d::CCPoint::CCPoint(1.2, -4.0);
v72 = cocos2d::CCMoveBy::create(0.050000001, v71);
cocos2d::CCPoint::CCPoint(0.050000001, 4.0);
v74 = cocos2d::CCMoveBy::create(0.050000001, v73);
cocos2d::CCPoint::CCPoint(0.050000001, -4.0);
v76 = cocos2d::CCMoveBy::create(0.050000001, v75);
cocos2d::CCPoint::CCPoint(0.050000001, 4.0);
LODWORD(v78) = (unsigned int)cocos2d::CCMoveBy::create(0.050000001, v77);
cocos2d::CCPoint::CCPoint(0.050000001, -4.0);
cocos2d::CCMoveBy::create(0.050000001, v79);
cocos2d::CCPoint::CCPoint(0.050000001, 4.0);
cocos2d::CCMoveBy::create(0.050000001, v80);
cocos2d::CCDelayTime::create(0.2);
cocos2d::CCCallFunc::create(v119, RewardUnlockLayer::step2);
v81 = cocos2d::CCSequence::create(v117, v72, v74, v76);
v82 = v119;
cocos2d::CCNode::runAction((CCLightFlash *)v119->m_chestSprite, (cocos2d::CCPoint)v81, v83, 80.0, v78);
v84 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_deleteBtn_001.png");
v121.origin = (cocos2d::CCPoint)operator new(0x208u);
v85 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v121.origin);
v86 = v85;
if ( v85 )
{
if ( CCMenuItemSpriteExtra::init(v85, v84, nullptr, v82, (cocos2d::SEL_MenuHandler *)RewardUnlockLayer::onClose) )
{
cocos2d::CCObject::autorelease(v86);
goto LABEL_58;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v86->~CCObject)(v86, 1);
}
v86 = nullptr;
LABEL_58:
v82->m_closeBtn = (CCMenuItemSpriteExtra *)v86;
v86[6].m_uUnknown = 1070386381;
v87 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_rewardBtn_001.png");
v121.origin = (cocos2d::CCPoint)operator new(0x208u);
v88 = CCMenuItemSpriteExtra::CCMenuItemSpriteExtra(*(CCMenuItemSpriteExtra **)&v121.origin);
v89 = v88;
if ( v88 )
{
if ( CCMenuItemSpriteExtra::init(v88, v87, nullptr, v82, (cocos2d::SEL_MenuHandler *)RewardUnlockLayer::onClose) )
{
cocos2d::CCObject::autorelease(v89);
LABEL_63:
v82->m_rewardBtn = (CCMenuItemSpriteExtra *)v89;
v89[6].m_uUnknown = 1070386381;
v90 = cocos2d::CCMenu::create(v82->m_closeBtn, v82->m_rewardBtn, 0);
v82->m_buttonMenu = v90;
v82->m_mainLayer->addChild_0(v82->m_mainLayer, v90, 10);
v82->m_closeBtn->setEnabled(v82->m_closeBtn, 0);
v82->m_closeBtn->setVisible(v82->m_closeBtn, 0);
v82->m_rewardBtn->setEnabled(v82->m_rewardBtn, 0);
v91 = ((float (__fastcall *)(CCMenuItemSpriteExtra *, _QWORD))v82->m_rewardBtn->setVisible)(v82->m_rewardBtn, 0);
v92 = v82->m_closeBtn->__vftable;
cocos2d::CCPoint::CCPoint(v91, (float)((float)(*(float *)&v116 * 0.5) - 170.0) + 10.0);
v93 = cocos2d::CCNode::convertToNodeSpace(v82->m_buttonMenu, &v120);
v94 = ((float (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v92->setPosition_0)(
v82->m_closeBtn,
v93);
v95 = v82->m_rewardBtn->__vftable;
cocos2d::CCPoint::CCPoint(v94, *(float *)&v116 * 0.5);
v96 = cocos2d::CCNode::convertToNodeSpace(v82->m_buttonMenu, &v120);
((void (__fastcall *)(CCMenuItemSpriteExtra *, struct cocos2d::CCPoint))v95->setPosition_0)(
v82->m_rewardBtn,
v96);
v97 = cocos2d::CCLabelBMFont::create("Something went wrong...", "goldFont.fnt");
v82->m_wrongLabel = v97;
v82->m_mainLayer->addChild_1(v82->m_mainLayer, v97);
v98 = ((float (__fastcall *)(cocos2d::CCLabelBMFont *))v82->m_wrongLabel->setScale_0)(v82->m_wrongLabel);
v99 = v82->m_wrongLabel->__vftable;
cocos2d::CCPoint::CCPoint(v98, *(float *)&v116 * 0.5);
v99->setPosition_0(v82->m_wrongLabel, v100);
v82->m_wrongLabel->setVisible(v82->m_wrongLabel, 0);
v101 = cocos2d::CCCallFunc::create(v82, RewardUnlockLayer::connectionTimeout);
v102 = cocos2d::CCDelayTime::create(10.0);
v103 = cocos2d::CCSequence::create(v102, v101, 0);
cocos2d::CCNode::runAction((CCLightFlash *)v82, (cocos2d::CCPoint)v103, v104, 80.0, v112);
sub_14003A830((__int64)&v124);
sub_14003A830((__int64)&v127);
return 1;
}
((void (__fastcall *)(cocos2d::CCObject *, __int64))v89->~CCObject)(v89, 1);
}
v89 = nullptr;
goto LABEL_63;
}
return result;
}