//
// cocos2d::CCLabelBMFont::initWithString from 0x1800489a0 to 0x180048d14 (884 bytes)
//
// 5 xrefs:
// > cocos2d::CCLabelBMFont::create @ 0x180047c94
// > cocos2d::CCLabelBMFont::createBatched @ 0x180047dc4
// > cocos2d::CCLabelBMFont::init @ 0x180048957
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b1968
//
// 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=2
char __fastcall cocos2d::CCLabelBMFont::initWithString(
cocos2d::CCLabelBMFont *this,
const char *a2,
cocos2d *a3,
float a4,
enum cocos2d::CCTextAlignment a5,
_DWORD *a6)
{
cocos2d::CCSprite *v9; // r15
__int64 v10; // rbx
struct cocos2d::CCBMFontConfiguration *File; // rax
cocos2d::CCBMFontConfiguration *v12; // rsi
cocos2d::CCBMFontConfiguration *m_pConfiguration; // rcx
size_t v15; // r8
std::string *p_m_sAtlasName; // rdi
cocos2d::CCTextureCache *v17; // rax
void *v18; // rdx
struct cocos2d::CCTexture2D *v19; // rdi
cocos2d::CCTexture2D *v20; // rax
const CHAR *v21; // rbp
float *v22; // rax
cocos2d::CCCamera *v23; // rax
float *v24; // rax
cocos2d::CCSprite *v25; // rax
cocos2d::CCSprite_vtbl *v26; // rsi
cocos2d::CCTextureAtlas *m_pobTextureAtlas; // rdi
cocos2d::CCRect *v28; // rbx
__int64 v29; // rax
__int64 v30; // r8
cocos2d::CCRect v31; // [rsp+30h] [rbp-48h] BYREF
void *v32; // [rsp+90h] [rbp+18h] BYREF
v9 = nullptr;
v10 = -1;
if ( a3 )
{
File = cocos2d::FNTConfigLoadFile(a3, a2);
v12 = File;
if ( !File )
{
cocos2d::CCObject::release(this);
return 0;
}
cocos2d::CCObject::retain(File);
m_pConfiguration = this->m_pConfiguration;
if ( m_pConfiguration )
cocos2d::CCObject::release(m_pConfiguration);
this->m_pConfiguration = v12;
v15 = -1;
do
++v15;
while ( *((_BYTE *)a3 + v15) );
sub_180010050((void **)&this->m_sFntFile, a3, v15);
p_m_sAtlasName = &this->m_pConfiguration->m_sAtlasName;
if ( this->m_pConfiguration->m_sAtlasName.m_data.m_capacity > 0xF )
p_m_sAtlasName = (std::string *)p_m_sAtlasName->m_data.m_bigStorage;
v17 = cocos2d::CCTextureCache::sharedTextureCache();
v19 = cocos2d::CCTextureCache::addImage(v17, p_m_sAtlasName->m_data.m_smallStorage._Elems, 0);
}
else
{
v20 = (cocos2d::CCTexture2D *)operator new(0x68u);
v32 = v20;
if ( v20 )
v19 = (struct cocos2d::CCTexture2D *)cocos2d::CCTexture2D::CCTexture2D(v20);
else
v19 = nullptr;
cocos2d::CCObject::autorelease(v19);
}
v21 = Buf2;
if ( a2 )
v21 = a2;
if ( this->m_bIsBatched )
{
if ( !cocos2d::CCComponent::serialize((cocos2d::CCComponent *)this, v18) )
return 0;
this->m_fWidth = a4;
this->m_pAlignment = a5;
*(_WORD *)&this->m_cDisplayedOpacity = -1;
*(_WORD *)&this->m_tRealColor.r = -1;
this->m_tRealColor.b = -1;
*(_WORD *)&this->m_tDisplayedColor.r = -1;
this->m_tDisplayedColor.b = -1;
*(_WORD *)&this->m_bCascadeColorEnabled = 257;
cocos2d::CCSize::operator=(&this->m_obContentSize, dword_1801A83B0);
this->m_bIsOpacityModifyRGB = 1;
v22 = kmVec2Fill((float *)&v32, 0.5, 0.5);
cocos2d::CCSize::operator=(&this->m_obAnchorPoint, v22);
cocos2d::CCSize::operator=(&this->m_tImageOffset, a6);
this->m_pSomeTexture = v19;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const CHAR *, _QWORD))this->setString_0)(this, v21, 0);
return 1;
}
else
{
do
++v10;
while ( v21[v10] );
if ( !cocos2d::CCSpriteBatchNode::initWithTexture(this, v19, v10) )
return 0;
this->m_fWidth = a4;
this->m_pAlignment = a5;
*(_WORD *)&this->m_cDisplayedOpacity = -1;
*(_WORD *)&this->m_tRealColor.r = -1;
this->m_tRealColor.b = -1;
*(_WORD *)&this->m_tDisplayedColor.r = -1;
this->m_tDisplayedColor.b = -1;
*(_WORD *)&this->m_bCascadeColorEnabled = 257;
cocos2d::CCSize::operator=(&this->m_obContentSize, dword_1801A83B0);
v23 = (cocos2d::CCCamera *)((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))this->m_pobTextureAtlas->getTexture)(this->m_pobTextureAtlas);
this->m_bIsOpacityModifyRGB = cocos2d::CCCamera::isDirty(v23);
v24 = kmVec2Fill((float *)&v32, 0.5, 0.5);
cocos2d::CCSize::operator=(&this->m_obAnchorPoint, v24);
cocos2d::CCSize::operator=(&this->m_tImageOffset, a6);
v25 = (cocos2d::CCSprite *)operator new(0x258u);
v32 = v25;
if ( v25 )
v9 = (cocos2d::CCSprite *)cocos2d::CCSprite::CCSprite(v25);
this->m_pReusedChar = v9;
v26 = v9->cocos2d::CCNodeRGBA::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
m_pobTextureAtlas = this->m_pobTextureAtlas;
v28 = cocos2d::CCRect::CCRect(&v31, 0.0, 0.0, 0.0, 0.0);
v29 = ((__int64 (__fastcall *)(cocos2d::CCTextureAtlas *))m_pobTextureAtlas->getTexture)(m_pobTextureAtlas);
((void (__fastcall *)(cocos2d::CCSprite *, __int64, cocos2d::CCRect *, _QWORD))v26->initWithTexture)(
this->m_pReusedChar,
v29,
v28,
0);
((void (__fastcall *)(cocos2d::CCSprite *, cocos2d::CCLabelBMFont *))this->m_pReusedChar->setBatchNode)(
this->m_pReusedChar,
this);
LOBYTE(v30) = 1;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const CHAR *, __int64))this->setString_0)(this, v21, v30);
return 1;
}
}