//
// cocos2d::CCLabelTTF::_updateWithTextDefinition from 0x18004db40 to 0x18004dcef (431 bytes)
//
// 4 xrefs:
// > cocos2d::CCLabelTTF::initWithStringAndTextDefinition @ 0x18004e622
// > cocos2d::CCLabelTTF::setTextDefinition @ 0x18004e868
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b1bfc
//
// 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 __fastcall cocos2d::CCLabelTTF::_updateWithTextDefinition(
cocos2d::CCLabelTTF *this,
struct cocos2d::_ccFontDefinition *Src,
char a3)
{
float *v6; // rax
std::string *v7; // rax
std::string *v8; // rbx
char *v9; // rcx
struct cocos2d::_ccFontDefinition *m_bigStorage; // r15
std::size_t m_size; // rbp
__int64 v12; // rdi
unsigned __int64 m_capacity; // r9
__int64 v14; // r8
size_t v15; // rcx
void *v16; // rax
std::string *v17; // [rsp+50h] [rbp+8h] BYREF
v6 = kmVec2Fill((float *)&v17, Src->m_dimensions.width, Src->m_dimensions.height);
cocos2d::CCSize::operator=(&this->m_tDimensions, v6);
this->m_hAlignment = Src->m_alignment;
this->m_vAlignment = Src->m_vertAlignment;
v7 = (std::string *)operator new(0x20u);
v8 = v7;
v17 = v7;
v9 = nullptr;
if ( v7 )
{
v7->m_data.0 = 0;
v7->m_data.m_size = 0;
v7->m_data.m_capacity = 0;
m_bigStorage = Src;
if ( Src->m_fontName.m_data.m_capacity > 0xF )
m_bigStorage = (struct cocos2d::_ccFontDefinition *)Src->m_fontName.m_data.m_bigStorage;
m_size = Src->m_fontName.m_data.m_size;
v12 = 0x7FFFFFFFFFFFFFFFLL;
if ( m_size > 0x7FFFFFFFFFFFFFFFLL )
std::vector::_Xlen();
v7->m_data.m_capacity = 15;
if ( m_size <= 0xF )
{
v7->m_data.m_size = m_size;
v7->m_data.0 = m_bigStorage->m_fontName.m_data.0;
goto LABEL_22;
}
m_capacity = v7->m_data.m_capacity;
if ( (m_size | 0xF) > 0x7FFFFFFFFFFFFFFFLL
|| (v14 = m_capacity >> 1, m_capacity > 0x7FFFFFFFFFFFFFFFLL - (m_capacity >> 1)) )
{
v15 = 0x8000000000000027uLL;
}
else
{
v12 = m_size | 0xF;
if ( (m_size | 0xF) < v14 + m_capacity )
v12 = v14 + m_capacity;
if ( (unsigned __int64)(v12 + 1) < 0x1000 )
{
if ( v12 != -1 )
v9 = (char *)operator new(v12 + 1);
goto LABEL_20;
}
v15 = v12 + 40;
if ( v12 + 40 < (unsigned __int64)(v12 + 1) )
Concurrency::cancel_current_task();
}
v16 = operator new(v15);
if ( !v16 )
invalid_parameter_noinfo_noreturn();
v9 = (char *)(((unsigned __int64)v16 + 39) & 0xFFFFFFFFFFFFFFE0uLL);
*((_QWORD *)v9 - 1) = v16;
LABEL_20:
v8->m_data.m_bigStorage = v9;
v8->m_data.m_size = m_size;
v8->m_data.m_capacity = v12;
memcpy(v9, m_bigStorage, m_size + 1);
goto LABEL_22;
}
v8 = nullptr;
LABEL_22:
this->m_pFontName = v8;
this->m_fFontSize = (float)Src->m_fontSize;
if ( a3 )
cocos2d::CCLabelTTF::updateTexture(this);
}