//
// SecretRewardsLayer::updateUnlockedLabel from 0x100632250 to 0x100632462 (530 bytes)
//
// 3 xrefs:
// > SecretRewardsLayer::init @ 0x100631386
// > SecretRewardsLayer::createSecondaryLayer @ 0x100633993
// > SecretRewardsLayer::onSelectItem @ 0x1006349e6
//
// 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 __fastcall SecretRewardsLayer::updateUnlockedLabel(SecretRewardsLayer *a1)
{
double v1; // xmm0_8
GameStatsManager *v3; // rax
GameStatsManager *v4; // rax
cocos2d::CCLabelBMFont *m_chestLabel; // r15
cocos2d::CCString *v6; // rax
const char *CString; // rax
GameStatsManager *v8; // rax
int v9; // r15d
GameStatsManager *v10; // rax
char v11; // al
cocos2d::CCString *v12; // rax
const char *v13; // r13
size_t v14; // rax
size_t v15; // r12
char *v16; // r14
cocos2d::CCLabelBMFont *m_chestCounter; // rdi
size_t v18; // r15
char *v19; // rsi
cocos2d::CCObject *v20; // r12
char *v21; // rsi
cocos2d::CCLabelBMFont *v22; // rdi
char v23; // [rsp+0h] [rbp-50h]
int v24; // [rsp+0h] [rbp-50h]
int v25; // [rsp+4h] [rbp-4Ch]
_QWORD __dst[2]; // [rsp+8h] [rbp-48h] BYREF
void *__p; // [rsp+18h] [rbp-38h]
__int16 v28; // [rsp+24h] [rbp-2Ch] BYREF
char v29; // [rsp+26h] [rbp-2Ah]
v3 = GameStatsManager::sharedState();
GameStatsManager::countUnlockedSecretChests(v3, (GJRewardType)0);
v4 = GameStatsManager::sharedState();
GameStatsManager::countSecretChests(v4, (GJRewardType)0);
m_chestLabel = a1->m_chestLabel;
v6 = (cocos2d::CCString *)sub_1007AB580("%i/%i", v23);
CString = cocos2d::CCString::getCString(v6);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))m_chestLabel->setString)(m_chestLabel, CString);
if ( a1->m_inMainLayer )
return;
v8 = GameStatsManager::sharedState();
v9 = GameStatsManager::countUnlockedSecretChests(v8, a1->m_rewardType);
v10 = GameStatsManager::sharedState();
v11 = GameStatsManager::countSecretChests(v10, a1->m_rewardType);
v12 = (cocos2d::CCString *)sub_1007AB580("%i/%i", v11);
v13 = cocos2d::CCString::getCString(v12);
v14 = strlen(v13);
if ( v14 >= 0xFFFFFFFFFFFFFFF8LL )
sub_100006BF0(v1);
v15 = v14;
if ( v14 >= 0x17 )
{
v25 = v9;
v18 = 26;
if ( (v14 | 7) != 0x17 )
v18 = (v14 | 7) + 1;
v16 = (char *)operator new(v18);
__p = v16;
__dst[0] = v18 + 1;
v9 = v25;
__dst[1] = v15;
}
else
{
LOBYTE(__dst[0]) = 2 * v14;
v16 = (char *)__dst + 1;
if ( !v14 )
{
BYTE1(__dst[0]) = 0;
m_chestCounter = a1->m_chestCounter;
if ( !m_chestCounter )
goto LABEL_15;
LABEL_11:
if ( (__dst[0] & 1) != 0 )
v19 = (char *)__p;
else
v19 = (char *)__dst + 1;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, char *))m_chestCounter->setString)(m_chestCounter, v19);
goto LABEL_15;
}
}
memmove(v16, v13, v15);
v16[v15] = 0;
m_chestCounter = a1->m_chestCounter;
if ( m_chestCounter )
goto LABEL_11;
LABEL_15:
v20 = cocos2d::CCDictionary::objectForKey(a1->m_chestCounters, a1->m_rewardType);
if ( v20 )
{
if ( (__dst[0] & 1) != 0 )
v21 = (char *)__p;
else
v21 = (char *)__dst + 1;
((void (__fastcall *)(cocos2d::CCObject *, char *))v20->__vftable[11].acceptVisitor)(v20, v21);
}
if ( v9 >= v24 )
{
v22 = a1->m_chestCounter;
if ( v22 )
{
v29 = -1;
v28 = -256;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, __int16 *))v22->setColor)(v22, &v28);
}
if ( v20 )
{
v29 = 50;
v28 = -206;
((void (__fastcall *)(cocos2d::CCObject *, __int16 *))v20->__vftable[13].~CCObject_0)(v20, &v28);
}
}
if ( (__dst[0] & 1) != 0 )
operator delete(__p);
}