//
// cocos2d::CCLabelBMFont::updateLabel from 0xae7b50 to 0xae83bc (2156 bytes)
//
// 3 xrefs:
// > ??> @ 0xbf910
// > ??> @ 0x1137b80
// > ??> @ 0x1202db0
//
// 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)
{
float v2; // s8
float v3; // s9
signed __int64 v4; // x27
unsigned int v5; // w20
int v6; // w21
int v7; // w24
unsigned int v8; // w23
cocos2d::CCArray *v9; // x25
int i; // w27
cocos2d::CCNode *v11; // x0
cocos2d::CCSprite *v12; // x26
int v13; // w19
unsigned __int16 *v14; // x0
unsigned __int16 *v15; // x3
unsigned __int16 *m_start; // x2
unsigned __int16 *m_finish; // x3
signed __int64 v18; // x19
unsigned __int64 v19; // x0
bool v20; // cc
unsigned __int64 v21; // x0
unsigned __int64 v22; // x0
unsigned __int16 *v23; // x20
unsigned __int16 *v24; // x1
_OWORD *v25; // x5
unsigned __int16 *v26; // x4
unsigned int v27; // w0
unsigned int v28; // w3
int v29; // w2
__int128 v30; // t1
__int64 v31; // x0
cocos2d::CCLabelBMFont_vtbl *v32; // x3
float LetterPosXLeft; // s0
unsigned __int16 *v34; // x0
unsigned __int16 *v35; // x0
unsigned __int16 *v36; // x0
unsigned __int16 *v37; // x3
unsigned __int16 *v38; // x0
int v39; // w0
int v40; // w20
__int64 v41; // x26
unsigned __int16 *v42; // x0
int v43; // w21
int v44; // w19
unsigned __int16 *v45; // x1
int v46; // w2
__int64 v47; // x22
int v48; // w25
cocos2d::CCNode *v49; // x0
cocos2d::CCNode *v50; // x27
float x; // s8
float *v52; // x0
cocos2d::CCTextAlignment m_pAlignment; // w1
float v54; // s8
float v55; // s8
unsigned int v56; // w19
int v57; // w22
cocos2d::CCNode *v58; // x0
cocos2d::CCNode *v59; // x27
unsigned __int16 *v60; // x0
unsigned __int16 *v61; // x3
__int64 v62; // x0
unsigned int v63; // [xsp+90h] [xbp+90h]
void (__fastcall *setPosition)(cocos2d::CCNode *__hidden, const cocos2d::CCPoint *); // [xsp+90h] [xbp+90h]
int v65; // [xsp+98h] [xbp+98h]
float *v66; // [xsp+98h] [xbp+98h]
unsigned __int16 v67; // [xsp+ACh] [xbp+ACh] BYREF
__int16 v68; // [xsp+AEh] [xbp+AEh] BYREF
std::vector v69; // [xsp+B0h] [xbp+B0h] BYREF
std::vector v70; // [xsp+C8h] [xbp+C8h] BYREF
std::vector p; // [xsp+E0h] [xbp+E0h] BYREF
a1->setString_1(a1, a1->m_sInitialString, 0);
if ( a1->m_fWidth <= 0.0 )
goto LABEL_44;
v2 = -1.0;
cocos2d::cc_utf16_vec_from_utf16_str(&v69, a1->m_sString);
v3 = -1.0;
memset(&v70, 0, sizeof(v70));
v4 = v69.m_finish - v69.m_start;
v63 = v4;
v65 = 0;
v5 = 0;
std::vector::reserve((__int64)&v70, (unsigned int)v4);
memset(&p, 0, sizeof(p));
v6 = 0;
std::vector::reserve((__int64)&p, (unsigned int)v4);
v7 = 0;
v8 = 0;
v9 = a1->getChildren(a1);
if ( !(unsigned int)cocos2d::CCArray::count(v9) )
{
LABEL_21:
m_start = p.m_start;
m_finish = p.m_finish;
goto LABEL_22;
}
while ( 1 )
{
for ( i = 0; ; ++i )
{
v11 = a1->getChildByTag(a1, i + v6 + v5);
v12 = (cocos2d::CCSprite *)v11;
if ( v11 )
break;
}
v6 += i;
if ( !v11->isVisible(v11) )
goto LABEL_19;
if ( v8 >= v63 )
goto LABEL_21;
v13 = v69.m_start[v8];
v67 = v69.m_start[v8];
if ( !v65 )
{
LetterPosXLeft = cocos2d::CCLabelBMFont::getLetterPosXLeft(a1, v12, 0.0, 0);
v13 = v67;
v2 = LetterPosXLeft;
}
if ( !v7 )
v3 = v2;
v7 = 1;
if ( v13 == 10 )
break;
LABEL_13:
if ( cocos2d::isspace_unicode(v13) )
{
v14 = p.m_finish;
if ( p.m_finish == p.m_reserveEnd )
{
std::vector::_M_emplace_back_aux((__int64)&p, &v67);
v15 = p.m_finish;
}
else
{
if ( p.m_finish )
*p.m_finish = v67;
v15 = v14 + 1;
p.m_finish = v14 + 1;
}
++v8;
v2 = -1.0;
v65 = 0;
std::vector::_M_range_insert<__gnu_cxx::__normal_iterator>>(
(__int64)&v70,
(_BYTE *)v70.m_finish,
(char *)p.m_start,
(char *)v15);
p.m_finish = p.m_start;
LABEL_19:
++v5;
goto LABEL_20;
}
if ( (float)(cocos2d::CCLabelBMFont::getLetterPosXRight(a1, v12, 0.0, 0) - v3) <= a1->m_fWidth )
{
v38 = p.m_finish;
if ( p.m_finish == p.m_reserveEnd )
{
std::vector::_M_emplace_back_aux((__int64)&p, &v67);
}
else
{
if ( p.m_finish )
*p.m_finish = v67;
p.m_finish = v38 + 1;
}
++v8;
v65 = v7;
++v5;
}
else if ( a1->m_bLineBreakWithoutSpaces )
{
cocos2d::cc_utf8_trim_ws(&p);
v60 = p.m_finish;
v68 = 10;
if ( p.m_finish == p.m_reserveEnd )
{
std::vector::_M_emplace_back_aux((__int64)&p, &v68);
v61 = p.m_finish;
}
else
{
if ( p.m_finish )
*p.m_finish = 10;
v61 = v60 + 1;
p.m_finish = v60 + 1;
}
std::vector::_M_range_insert<__gnu_cxx::__normal_iterator>>(
(__int64)&v70,
(_BYTE *)v70.m_finish,
(char *)p.m_start,
(char *)v61);
m_finish = p.m_start;
p.m_finish = p.m_start;
if ( v8 >= v63 )
goto LABEL_112;
v2 = -1.0;
v65 = 0;
v7 = 0;
v3 = -1.0;
}
else
{
v34 = p.m_finish;
if ( p.m_finish == p.m_reserveEnd )
{
std::vector::_M_emplace_back_aux((__int64)&p, &v67);
}
else
{
if ( p.m_finish )
*p.m_finish = v67;
p.m_finish = v34 + 1;
}
if ( cocos2d::cc_utf8_find_last_not_char(&v70, 0x20u) == -1 )
{
v70.m_finish = v70.m_start;
}
else
{
cocos2d::cc_utf8_trim_ws(&v70);
v35 = v70.m_finish;
if ( v70.m_finish - v70.m_start )
{
v68 = 10;
if ( v70.m_reserveEnd == v70.m_finish )
{
std::vector::_M_emplace_back_aux((__int64)&v70, &v68);
}
else
{
if ( v70.m_finish )
*v70.m_finish = 10;
v70.m_finish = v35 + 1;
}
}
}
v65 = v7;
++v8;
v3 = -1.0;
v7 = 0;
++v5;
}
LABEL_20:
if ( v5 >= (unsigned int)cocos2d::CCArray::count(v9) )
goto LABEL_21;
}
cocos2d::cc_utf8_trim_ws(&p);
v68 = 10;
v36 = p.m_finish;
if ( p.m_finish == p.m_reserveEnd )
{
std::vector::_M_emplace_back_aux((__int64)&p, &v68);
v37 = p.m_finish;
}
else
{
if ( p.m_finish )
*p.m_finish = 10;
v37 = v36 + 1;
p.m_finish = v36 + 1;
}
v8 += i;
std::vector::_M_range_insert<__gnu_cxx::__normal_iterator>>(
(__int64)&v70,
(_BYTE *)v70.m_finish,
(char *)p.m_start,
(char *)v37);
m_finish = p.m_start;
p.m_finish = p.m_start;
if ( v63 > v8 )
{
v7 = 0;
v2 = -1.0;
LOWORD(v13) = v69.m_start[v8];
v3 = -1.0;
v67 = v13;
goto LABEL_13;
}
LABEL_112:
m_start = m_finish;
LABEL_22:
std::vector::_M_range_insert<__gnu_cxx::__normal_iterator>>(
(__int64)&v70,
(_BYTE *)v70.m_finish,
(char *)m_start,
(char *)m_finish);
v18 = v70.m_finish - v70.m_start;
v19 = (int)v18 + 1;
v20 = v19 > 0x3F80000000000000LL;
v21 = 2 * v19;
if ( v20 )
v21 = -1;
v22 = operator new[](v21);
v23 = (unsigned __int16 *)v22;
if ( (int)v18 > 0 )
{
v24 = v70.m_start;
if ( (v70.m_start >= (unsigned __int16 *)(v22 + 16) || (unsigned __int16 *)v22 >= v70.m_start + 8)
&& (unsigned int)v18 > 9 )
{
v25 = (_OWORD *)v22;
v26 = v70.m_start;
v27 = ((unsigned int)(v18 - 8) >> 3) + 1;
v28 = 0;
v29 = 8 * v27;
do
{
v30 = *(_OWORD *)v26;
v26 += 8;
++v28;
*v25++ = v30;
}
while ( v27 > v28 );
if ( v29 != (_DWORD)v18 )
{
v23[v29] = v24[v29];
v31 = v29;
if ( (int)v18 > v29 + 1 )
{
v23[v31 + 1] = v24[v31 + 1];
if ( v29 + 2 < (int)v18 )
{
v23[v31 + 2] = v24[v31 + 2];
if ( (int)v18 > v29 + 3 )
{
v23[v31 + 3] = v24[v31 + 3];
if ( (int)v18 > v29 + 4 )
{
v23[v31 + 4] = v24[v31 + 4];
if ( (int)v18 > v29 + 5 )
{
v23[v31 + 5] = v24[v31 + 5];
if ( (int)v18 > v29 + 6 )
v23[v31 + 6] = v24[v31 + 6];
}
}
}
}
}
}
}
else
{
v62 = 0;
do
{
v23[v62] = v24[v62];
++v62;
}
while ( (int)v18 > (int)v62 );
}
}
v32 = a1->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v23[(int)v18] = 0;
v32->setString_1(a1, v23, 0);
operator delete[](v23);
if ( p.m_start )
operator delete(p.m_start);
if ( v70.m_start )
operator delete(v70.m_start);
if ( v69.m_start )
operator delete(v69.m_start);
LABEL_44:
if ( a1->m_pAlignment )
{
v39 = cocos2d::cc_wcslen(a1->m_sString);
memset(&p, 0, sizeof(p));
v40 = v39;
if ( (v39 & 0x80000000) == 0 )
{
v41 = 0;
v42 = nullptr;
v43 = 0;
v44 = 0;
while ( 2 )
{
v45 = &a1->m_sString[v41];
v46 = *v45;
if ( *v45 && v46 != 10 )
{
if ( v42 == p.m_reserveEnd )
{
std::vector::_M_emplace_back_aux((__int64)&p, v45);
}
else
{
if ( v42 )
*v42 = v46;
p.m_finish = v42 + 1;
}
goto LABEL_78;
}
v47 = v42 - p.m_start;
if ( !(_DWORD)v47 )
{
++v41;
++v43;
if ( v40 < (int)v41 )
{
LABEL_83:
if ( p.m_start )
operator delete(p.m_start);
return;
}
goto LABEL_79;
}
v48 = v44 + v47;
if ( v43 - 1 + v44 + (int)v47 >= 0 )
{
v49 = a1->getChildByTag(a1, (unsigned int)(v43 - 1 + v44 + v47));
v50 = v49;
if ( v49 )
{
x = v49->getPosition(v49)->x;
v52 = (float *)v50->getContentSize(v50);
m_pAlignment = a1->m_pAlignment;
v54 = x + (float)(*v52 * 0.5);
if ( m_pAlignment == kCCTextAlignmentCenter )
{
v55 = -(float)((float)(v54 * 0.5) - (float)(a1->getContentSize(a1)->width * 0.5));
goto LABEL_90;
}
if ( m_pAlignment == kCCTextAlignmentRight )
{
v55 = a1->getContentSize(a1)->width - v54;
LABEL_90:
if ( v55 != 0.0 )
{
v56 = v43 + v44;
v57 = v56 + v47;
do
{
if ( (v56 & 0x80000000) == 0 )
{
v58 = a1->getChildByTag(a1, v56);
v59 = v58;
if ( v58 )
{
setPosition = v58->setPosition;
v66 = (float *)v58->getPosition(v58);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v69, v55, 0.0);
cocos2d::CCPoint::operator+(v66, (float *)&v69, (cocos2d::CCPoint *)&v70);
setPosition(v59, (const cocos2d::CCPoint *)&v70);
}
}
++v56;
}
while ( v56 != v57 );
}
}
v44 = v48;
++v43;
p.m_finish = p.m_start;
}
}
LABEL_78:
if ( v40 < (int)++v41 )
goto LABEL_83;
LABEL_79:
v42 = p.m_finish;
continue;
}
}
}
}