//
// GJSmartBlockPreview::addChance from 0x1402b6770 to 0x1402b6962 (498 bytes)
//
// 3 xrefs:
// > BrowseSmartKeyLayer::init @ 0x14045b8c6
// > BrowseSmartKeyLayer::updateChanceValues @ 0x14045c422
// > ??> @ 0x1406d248c
//
// 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=1
void GJSmartBlockPreview::addChance(GJSmartBlockPreview *a1, int a2, int a3)
{
float v3; // xmm0_4
cocos2d::CCLabelBMFont *v7; // rax
cocos2d::CCLabelBMFont *m_infoLabel; // rbx
cocos2d::CCLabelBMFont_vtbl *v9; // rbx
const cocos2d::CCPoint *v10; // rax
cocos2d::CCString *v11; // rax
char *CString; // rax
size_t v13; // r8
void **v14; // rdx
_BOOL8 v15; // rdx
void *v16; // rcx
void *Block[2]; // [rsp+28h] [rbp-40h] BYREF
__int64 v18; // [rsp+38h] [rbp-30h]
unsigned __int64 v19; // [rsp+40h] [rbp-28h]
if ( !a1->m_infoLabel )
{
v7 = cocos2d::CCLabelBMFont::create(" ", (const char *)&qword_14052A4D8);
a1->m_infoLabel = v7;
a1->addChild_1(a1, v7);
}
m_infoLabel = a1->m_infoLabel;
if ( a3 )
{
v9 = m_infoLabel->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
cocos2d::CCPoint::CCPoint(v3, 45.0);
v9->setPosition_0(a1->m_infoLabel, v10);
*(_OWORD *)Block = 0;
v18 = 0;
v19 = 15;
LOBYTE(Block[0]) = 0;
if ( a2 )
{
v11 = cocos2d::CCString::createWithFormat(
"%i (%.1f%%)",
(unsigned int)a2,
(float)((float)((float)a2 / (float)a3) * 100.0));
CString = (char *)cocos2d::CCString::getCString(v11);
v13 = -1;
do
++v13;
while ( CString[v13] );
sub_14003CCE0(Block, CString, v13);
v14 = Block;
if ( v19 > 0xF )
v14 = (void **)Block[0];
}
else
{
v18 = 1;
LOWORD(Block[0]) = 48;
v14 = Block;
}
a1->m_infoLabel->setString(&a1->m_infoLabel->cocos2d::CCLabelProtocol, (const char *)v14);
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_infoLabel, 100.0, 0.80000001, 0.0);
LOBYTE(v15) = 1;
a1->m_infoLabel->setVisible(a1->m_infoLabel, v15);
if ( v19 > 0xF )
{
v16 = Block[0];
if ( v19 + 1 >= 0x1000 )
{
v16 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v16 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v16);
}
}
else
{
m_infoLabel->setVisible(a1->m_infoLabel, 0);
}
}