//
// SecretRewardsLayer::updateUnlockedLabel from 0x1403d6fd0 to 0x1403d738d (957 bytes)
//
// 4 xrefs:
// > SecretRewardsLayer::init @ 0x1403d3c6b
// > SecretRewardsLayer::createSecondaryLayer @ 0x1403d55fa
// > SecretRewardsLayer::onSelectItem @ 0x1403d6696
// > ??> @ 0x1406d7da8
//
// 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=5
void SecretRewardsLayer::updateUnlockedLabel(SecretRewardsLayer *a1)
{
__int64 v2; // rcx
unsigned int v3; // edi
__int64 v4; // rcx
unsigned int v5; // eax
cocos2d::CCLabelProtocol_vtbl *v6; // rbx
cocos2d::CCString *v7; // rax
const char *CString; // rax
__int64 v9; // r8
GJRewardType m_rewardType; // r9d
signed int v11; // edi
GJRewardType v12; // r9d
signed int v13; // ebx
cocos2d::CCString *v14; // rax
const char *v15; // rax
size_t v16; // r8
cocos2d::CCLabelBMFont *m_chestCounter; // rcx
void **v18; // rdx
struct cocos2d::CCObject *v19; // rax
struct cocos2d::CCObject *v20; // rsi
void **v21; // rdx
cocos2d::CCLabelBMFont *v22; // rcx
void *v23; // rcx
__int64 v24; // rax
__int64 v25; // rax
__int64 i; // rdx
signed int v27; // ecx
__int64 v28; // rax
__int64 v29; // rax
__int64 j; // rdx
signed int v31; // ecx
__int16 v32; // [rsp+20h] [rbp-40h] BYREF
char v33; // [rsp+22h] [rbp-3Eh]
void *v34; // [rsp+28h] [rbp-38h]
void *Block[2]; // [rsp+30h] [rbp-30h] BYREF
__int64 v36; // [rsp+40h] [rbp-20h]
unsigned __int64 v37; // [rsp+48h] [rbp-18h]
v2 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v34 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v34);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v2 = qword_1406C2EE8;
}
v3 = cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v2 + 856));
v4 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v34 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v34);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v4 = qword_1406C2EE8;
}
v5 = cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v4 + 352));
v6 = a1->m_chestLabel->__vftable;
v7 = cocos2d::CCString::createWithFormat("%i/%i", v3, v5);
CString = cocos2d::CCString::getCString(v7);
v6->setString(&a1->m_chestLabel->cocos2d::CCLabelProtocol, CString);
if ( !a1->m_inMainLayer )
{
v9 = qword_1406C2EE8;
if ( !qword_1406C2EE8 )
{
v34 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v34);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v9 = qword_1406C2EE8;
}
m_rewardType = a1->m_rewardType;
if ( m_rewardType )
{
v11 = 0;
v24 = *(_QWORD *)(v9 + 856);
if ( v24 )
{
v25 = *(_QWORD *)(v24 + 56);
if ( v25 )
{
for ( i = *(_QWORD *)(v25 + 288); ; i = *(_QWORD *)(i + 288) )
{
v27 = v11++;
if ( *(_DWORD *)(*(_QWORD *)(v25 + 264) + 64LL) != m_rewardType )
v11 = v27;
v25 = i;
if ( !i )
break;
}
}
}
}
else
{
v11 = cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v9 + 856));
v9 = qword_1406C2EE8;
}
if ( !v9 )
{
v34 = operator new(0x3E0u);
qword_1406C2EE8 = sub_1401D0AE0((__int64)v34);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);
v9 = qword_1406C2EE8;
}
v12 = a1->m_rewardType;
if ( v12 )
{
v13 = 0;
v28 = *(_QWORD *)(v9 + 352);
if ( v28 )
{
v29 = *(_QWORD *)(v28 + 56);
if ( v29 )
{
for ( j = *(_QWORD *)(v29 + 288); ; j = *(_QWORD *)(j + 288) )
{
v31 = v13++;
if ( *(_DWORD *)(*(_QWORD *)(v29 + 264) + 64LL) != v12 )
v13 = v31;
v29 = j;
if ( !j )
break;
}
}
}
}
else
{
v13 = cocos2d::CCDictionary::count(*(cocos2d::CCDictionary **)(v9 + 352));
}
v14 = cocos2d::CCString::createWithFormat("%i/%i", v11, v13);
v15 = cocos2d::CCString::getCString(v14);
*(_OWORD *)Block = 0;
v36 = 0;
v37 = 0;
v16 = -1;
do
++v16;
while ( v15[v16] );
sub_14003A930(Block, v15, v16);
m_chestCounter = a1->m_chestCounter;
if ( m_chestCounter )
{
v18 = Block;
if ( v37 > 0xF )
v18 = (void **)Block[0];
m_chestCounter->setString(&m_chestCounter->cocos2d::CCLabelProtocol, (const char *)v18);
}
v19 = cocos2d::CCDictionary::objectForKey(a1->m_chestCounters, a1->m_rewardType);
v20 = v19;
if ( v19 )
{
v21 = Block;
if ( v37 > 0xF )
v21 = (void **)Block[0];
(**(void (__fastcall ***)(__int64, void **))&v19[6].m_uAutoReleaseCount)(
(__int64)&v19[6].m_uAutoReleaseCount,
v21);
}
if ( v11 >= v13 )
{
v22 = a1->m_chestCounter;
if ( v22 )
{
v32 = -256;
v33 = -1;
v22->setColor(&v22->cocos2d::CCRGBAProtocol, (const cocos2d::ccColor3B *)&v32);
}
if ( v20 )
{
v32 = -206;
v33 = 50;
(**(void (__fastcall ***)(__int64, __int16 *))&v20[6].m_uIndexInArray)((__int64)&v20[6].m_uIndexInArray, &v32);
}
}
if ( v37 > 0xF )
{
v23 = Block[0];
if ( v37 + 1 >= 0x1000 )
{
v23 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v23 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v23);
}
}
}