//
// cocos2d::CCLabelBMFont::updateLabel from 0x5cd768 to 0x5cdb66 (1022 bytes)
//
// 0 xrefs:
//
// 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 cocos2d::CCLabelBMFont::updateLabel(cocos2d::CCLabelBMFont *a1)
{
unsigned int v2; // r5
float LetterPosXLeft; // s16
unsigned int v4; // r7
int v5; // r11
int v6; // r8
unsigned int v7; // r6
int v8; // r2
float v9; // s17
int v10; // r9
int v11; // r2
cocos2d::CCNode *v12; // r0
cocos2d::CCSprite *v13; // r10
unsigned __int16 v14; // r3
int v15; // r6
int v16; // r8
unsigned int v17; // r0
char *v18; // r0
unsigned __int16 *m_start; // r2
int v20; // r3
void *v21; // r5
cocos2d::CCLabelBMFont_vtbl *v22; // r3
int v23; // r5
int v24; // r0
int v25; // r8
int v26; // r7
unsigned __int16 *v27; // r1
int v28; // r6
cocos2d::CCNode *v29; // r0
cocos2d::CCNode *v30; // r9
float x; // s16
float *v32; // r0
cocos2d::CCTextAlignment m_pAlignment; // r3
float v34; // s16
float v35; // s16
int v36; // r9
cocos2d::CCNode *v37; // r0
int v38; // [sp+0h] [bp-4Ch]
int v39; // [sp+0h] [bp-4Ch]
cocos2d::CCArray *v40; // [sp+4h] [bp-48h]
cocos2d::CCArray *setPosition; // [sp+4h] [bp-48h]
int v42; // [sp+Ch] [bp-40h]
int v43; // [sp+Ch] [bp-40h]
float *v44; // [sp+10h] [bp-3Ch]
cocos2d::CCNode *v45; // [sp+14h] [bp-38h]
unsigned __int16 v46; // [sp+1Ch] [bp-30h] BYREF
__int16 v47; // [sp+1Eh] [bp-2Eh] BYREF
std::vector v48; // [sp+20h] [bp-2Ch] BYREF
std::vector v49; // [sp+2Ch] [bp-20h] BYREF
std::vector v50; // [sp+38h] [bp-14h] BYREF
std::vector v51; // 0:r0.12
a1->setString_1(a1, a1->m_sInitialString, 0);
if ( a1->m_fWidth <= 0.0 )
goto LABEL_39;
cocos2d::cc_utf16_vec_from_utf16_str(&v48, a1->m_sString);
v2 = 0;
memset(&v49, 0, sizeof(v49));
LetterPosXLeft = -1.0;
v4 = v48.m_finish - v48.m_start;
v5 = 0;
v6 = 0;
v7 = 0;
std::vector::reserve((int)&v49, v4, (int)v48.m_start);
memset(&v50, 0, sizeof(v50));
std::vector::reserve((int)&v50, v4, v8);
v9 = -1.0;
v38 = 0;
v40 = a1->getChildren(a1);
while ( v2 < cocos2d::CCArray::count(v40) )
{
v10 = 0;
v11 = v38 + v2;
while ( 1 )
{
v42 = v11;
v12 = a1->getChildByTag(a1, v11 + v10);
v11 = v42;
v13 = (cocos2d::CCSprite *)v12;
if ( v12 )
break;
++v10;
}
v38 += v10;
if ( ((int (__fastcall *)(cocos2d::CCNode *))v12->isVisible)(v12) )
{
if ( v7 >= v4 )
break;
v46 = v48.m_start[v7];
if ( !v5 )
LetterPosXLeft = cocos2d::CCLabelBMFont::getLetterPosXLeft(a1, v13, 0.0, 0);
if ( !v6 )
v9 = LetterPosXLeft;
if ( v46 == 10 )
{
v7 += v10;
cocos2d::cc_utf8_trim_ws(&v50);
v47 = 10;
std::vector::emplace_back((void **)&v50.m_start, &v47);
std::vector::insert<__gnu_cxx::__normal_iterator>,void>(
(void **)&v49.m_start,
(char *)v49.m_finish,
(char *)v50.m_start,
(char *)v50.m_finish);
v50.m_finish = v50.m_start;
if ( v7 >= v4 )
break;
LetterPosXLeft = -1.0;
v6 = 0;
v46 = v48.m_start[v7];
v9 = -1.0;
}
else
{
v6 = 1;
}
if ( cocos2d::isspace_unicode(v46) )
{
LetterPosXLeft = -1.0;
++v7;
std::vector::push_back((void **)&v50.m_start, &v46);
std::vector::insert<__gnu_cxx::__normal_iterator>,void>(
(void **)&v49.m_start,
(char *)v49.m_finish,
(char *)v50.m_start,
(char *)v50.m_finish);
v50.m_finish = v50.m_start;
LABEL_19:
v5 = 0;
goto LABEL_31;
}
if ( (float)(cocos2d::CCLabelBMFont::getLetterPosXRight(a1, v13, 0.0, 0) - v9) <= a1->m_fWidth )
{
std::vector::push_back((void **)&v50.m_start, &v46);
++v7;
v5 = v6;
}
else
{
if ( a1->m_bLineBreakWithoutSpaces )
{
cocos2d::cc_utf8_trim_ws(&v50);
v47 = 10;
std::vector::emplace_back((void **)&v50.m_start, &v47);
std::vector::insert<__gnu_cxx::__normal_iterator>,void>(
(void **)&v49.m_start,
(char *)v49.m_finish,
(char *)v50.m_start,
(char *)v50.m_finish);
v50.m_finish = v50.m_start;
if ( v7 >= v4 )
break;
LetterPosXLeft = -1.0;
--v2;
v6 = 0;
v9 = -1.0;
goto LABEL_19;
}
std::vector::push_back((void **)&v50.m_start, &v46);
v51.m_finish = (unsigned __int16 *)&dword_20;
v51.m_start = (unsigned __int16 *)&v49;
if ( cocos2d::cc_utf8_find_last_not_char(v51, v14) == -1 )
v49.m_finish = v49.m_start;
else
cocos2d::cc_utf8_trim_ws(&v49);
if ( (unsigned int)((char *)v49.m_finish - (char *)v49.m_start) >> 1 )
{
v47 = 10;
std::vector::emplace_back((void **)&v49.m_start, &v47);
}
v5 = v6;
++v7;
v9 = -1.0;
v6 = 0;
}
}
LABEL_31:
++v2;
}
std::vector::insert<__gnu_cxx::__normal_iterator>,void>(
(void **)&v49.m_start,
(char *)v49.m_finish,
(char *)v50.m_start,
(char *)v50.m_finish);
v15 = (char *)v49.m_finish - (char *)v49.m_start;
v16 = v49.m_finish - v49.m_start;
if ( (unsigned int)(v16 + 1) > 0x3F800000 )
v17 = -1;
else
v17 = 2 * (v16 + 1);
v18 = (char *)operator new[](v17);
m_start = v49.m_start;
v20 = 0;
v21 = v18;
while ( v20 < v16 )
{
*(_WORD *)&v18[2 * v20] = m_start[v20];
++v20;
}
v22 = a1->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
*(_WORD *)&v18[v15] = 0;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, char *))v22->setString_1)(a1, v18);
operator delete[](v21);
std::_Vector_base::~_Vector_base((void **)&v50.m_start);
std::_Vector_base::~_Vector_base((void **)&v49.m_start);
std::_Vector_base::~_Vector_base((void **)&v48.m_start);
LABEL_39:
if ( a1->m_pAlignment == kCCTextAlignmentLeft )
return;
v23 = 0;
v24 = cocos2d::cc_wcslen(a1->m_sString);
v25 = 0;
v26 = 0;
memset(&v50, 0, sizeof(v50));
v39 = v24;
while ( 2 )
{
if ( v23 <= v39 )
{
v27 = &a1->m_sString[v23];
if ( *v27 != 10 && *v27 )
{
std::vector::push_back((void **)&v50.m_start, v27);
goto LABEL_61;
}
v28 = v50.m_finish - v50.m_start;
if ( !v28 )
{
++v25;
LABEL_61:
++v23;
continue;
}
if ( v25 - 1 + v26 + v28 < 0 )
goto LABEL_61;
v29 = a1->getChildByTag(a1, v25 - 1 + v26 + v28);
v30 = v29;
if ( !v29 )
goto LABEL_61;
x = v29->getPosition(v29)->x;
v32 = (float *)v30->getContentSize(v30);
m_pAlignment = a1->m_pAlignment;
v34 = x + (float)(*v32 * 0.5);
if ( m_pAlignment != kCCTextAlignmentCenter )
{
if ( m_pAlignment == kCCTextAlignmentRight )
{
v35 = a1->getContentSize(a1)->width - v34;
LABEL_52:
if ( v35 != 0.0 )
{
v36 = 0;
v43 = v25 + v26;
do
{
if ( v43 + v36 >= 0 )
{
v37 = a1->getChildByTag(a1, v43 + v36);
if ( v37 )
{
v45 = v37;
setPosition = (cocos2d::CCArray *)v37->setPosition;
v44 = (float *)v37->getPosition(v37);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v48, v35, 0.0);
cocos2d::CCPoint::operator+((cocos2d::CCPoint *)&v49, v44, (float *)&v48);
((void (__fastcall *)(cocos2d::CCNode *, std::vector *))setPosition)(v45, &v49);
}
}
++v36;
}
while ( v36 != v28 );
}
}
v26 += v28;
++v25;
v50.m_finish = v50.m_start;
goto LABEL_61;
}
v35 = (float)(a1->getContentSize(a1)->width * 0.5) - (float)(v34 * 0.5);
goto LABEL_52;
}
break;
}
std::_Vector_base::~_Vector_base((void **)&v50.m_start);
}