//
// TextGameObject::updateTextObject from 0x1401a75a0 to 0x1401a793d (925 bytes)
//
// 8 xrefs:
// > CustomizeObjectLayer::textChanged @ 0x1400a9a28
// > CustomizeObjectLayer::onClear @ 0x1400a9ad3
// > EditorUI::getCreateBtn @ 0x14010ec45
// > EditorUI::onCreateObject @ 0x14010f9f7
// > TextGameObject::customObjectSetup @ 0x1401a7a81
// > LevelEditorLayer::updateLevelFont @ 0x1402df45a
// > LevelEditorLayer::breakApartTextObject @ 0x1402df7e9
// > ??> @ 0x1406cc114
//
// 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=3
void __fastcall TextGameObject::updateTextObject(__int64 *a1, struct cocos2d::CCPoint a2, char a3)
{
__int64 v4; // r14
unsigned int v6; // ebp
char v7; // r12
unsigned __int64 v8; // rdi
unsigned __int64 v9; // r15
char *v10; // rbx
const void *v11; // rcx
size_t v12; // r8
char v13; // di
char *v14; // rax
char *v15; // rdx
char v16; // al
cocos2d::CCArray *v17; // rcx
struct cocos2d::CCObject *v18; // rax
__int64 v19; // rax
bool v20; // r12
__int64 v21; // rcx
struct cocos2d::CCArray *v22; // r15
GameManager *v23; // rcx
GameManager *v24; // rbx
int m_loadedFont; // eax
int v26; // ebx
cocos2d::CCString *v27; // rax
const char *CString; // rax
const char *v29; // rcx
struct cocos2d::CCLabelBMFont *Batched; // rdi
void (__fastcall **v31)(__int64 *, __int64); // rbx
__int64 v32; // rax
cocos2d::CCLabelBMFont_vtbl *v33; // rbx
struct cocos2d::CCPoint v34; // rax
__int64 v35; // rdx
struct cocos2d::CCObject *v36; // rax
struct cocos2d::CCObject *v37; // rbx
int v38; // [rsp+20h] [rbp-78h] BYREF
struct cocos2d::CCPoint v39[2]; // [rsp+28h] [rbp-70h] BYREF
__int128 Buf2; // [rsp+38h] [rbp-60h] BYREF
__int64 v41; // [rsp+48h] [rbp-50h]
__int64 v42; // [rsp+50h] [rbp-48h]
v4 = (__int64)a2;
v39[1] = a2;
v6 = 0;
v7 = 0;
v38 = 0;
v8 = *(_QWORD *)(*(_QWORD *)&a2 + 16LL);
if ( !v8 )
{
v9 = v42;
v10 = (char *)Buf2;
LABEL_10:
v13 = 1;
goto LABEL_11;
}
Buf2 = 0;
v41 = 1;
v9 = 15;
v42 = 15;
LOWORD(Buf2) = (unsigned __int8)asc_140518984[0];
v7 = 1;
v10 = (char *)Buf2;
v11 = (const void *)a2;
if ( *(_QWORD *)(*(_QWORD *)&a2 + 24LL) > 0xFu )
v11 = **(const void ***)&a2;
v12 = v8;
if ( v8 > 1 )
v12 = 1;
if ( !memcmp(v11, &Buf2, v12) && v8 <= 1 )
goto LABEL_10;
v13 = 0;
LABEL_11:
if ( (v7 & 1) != 0 && v9 > 0xF )
{
v14 = v10;
if ( v9 + 1 >= 0x1000 )
{
v10 = *((char **)v10 - 1);
if ( (unsigned __int64)(v14 - v10 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v10);
}
if ( v13 )
sub_14003CCE0((void **)v4, &word_1405447D4, 1u);
if ( a1 + 170 != (__int64 *)v4 )
{
v15 = (char *)v4;
if ( *(_QWORD *)(v4 + 24) > 0xFu )
v15 = *(char **)v4;
sub_14003CCE0((void **)a1 + 170, v15, *(_QWORD *)(v4 + 16));
}
LOWORD(v38) = -1;
v16 = -1;
BYTE2(v38) = -1;
v17 = (cocos2d::CCArray *)a1[26];
if ( v17 )
{
if ( cocos2d::CCArray::count(v17) )
{
v18 = cocos2d::CCArray::objectAtIndex((cocos2d::CCArray *)a1[26], 0);
v19 = (*(__int64 (__fastcall **)(int *))(*(_QWORD *)&v18[5].m_unknown2 + 8LL))(&v18[5].m_unknown2);
LOWORD(v38) = *(_WORD *)v19;
v16 = *(_BYTE *)(v19 + 2);
BYTE2(v38) = v16;
}
else
{
v16 = BYTE2(v38);
}
}
v20 = *((_BYTE *)a1 + 1141) && ((_WORD)v38 != 0xFFFF || v16 != -1);
LOBYTE(a2.x) = 1;
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCPoint))(*a1 + 560))(a1, a2);
v22 = (struct cocos2d::CCArray *)cocos2d::CCArray::create(v21);
if ( !a3 )
{
v23 = (GameManager *)qword_1406C2ED8;
if ( !qword_1406C2ED8 )
{
v39[0] = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(*(_QWORD *)v39);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v23 = (GameManager *)qword_1406C2ED8;
}
v24 = v23;
if ( !v23 )
{
v39[0] = (struct cocos2d::CCPoint)operator new(0x668u);
qword_1406C2ED8 = sub_14017AB00(*(_QWORD *)v39);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2ED8 + 72LL))(qword_1406C2ED8);
v23 = (GameManager *)qword_1406C2ED8;
}
m_loadedFont = v24->m_loadedFont;
v26 = 59;
if ( m_loadedFont < 59 )
v26 = m_loadedFont;
if ( v26 > 0 )
{
GameManager::loadFont(v23, v26);
v27 = cocos2d::CCString::createWithFormat("gjFont%02d.fnt", v26);
CString = cocos2d::CCString::getCString(v27);
goto LABEL_43;
}
GameManager::loadFont(v23, 0);
}
CString = (const char *)&qword_14052A4D8;
LABEL_43:
v29 = (const char *)v4;
if ( *(_QWORD *)(v4 + 24) > 0xFu )
v29 = *(const char **)v4;
Batched = cocos2d::CCLabelBMFont::createBatched(v29, CString, v22, *((_DWORD *)a1 + 348));
v31 = (void (__fastcall **)(__int64 *, __int64))*a1;
v32 = (__int64)Batched->getContentSize(Batched);
v31[37](a1, v32);
v33 = Batched->cocos2d::CCSpriteBatchNode::cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable;
v34 = cocos2d::CCNode::convertToNodeSpace((cocos2d::CCNode *)a1, v39);
((void (__fastcall *)(struct cocos2d::CCLabelBMFont *, struct cocos2d::CCPoint))v33->setPosition_0)(Batched, v34);
if ( cocos2d::CCArray::count(v22) )
{
do
{
v36 = cocos2d::CCArray::objectAtIndex(v22, v6);
v37 = v36;
if ( v20 )
(**(void (__fastcall ***)(__int64, int *))&v36[5].m_unknown2)((__int64)&v36[5].m_unknown2, &v38);
(*(void (__fastcall **)(__int64 *, struct cocos2d::CCObject *))(*a1 + 448))(a1, v37);
++v6;
}
while ( v6 < cocos2d::CCArray::count(v22) );
}
*((_BYTE *)a1 + 894) = 1;
*((_WORD *)a1 + 436) = 257;
*((_BYTE *)a1 + 848) = 1;
LOBYTE(v35) = 1;
(*(void (__fastcall **)(__int64 *, __int64))(*a1 + 1032))(a1, v35);
*((_BYTE *)a1 + 559) = 1;
sub_14003A830(v4);
}