//
// LevelEditorLayer::breakApartTextObject from 0x672108 to 0x6724ac (932 bytes)
//
// 2 xrefs:
// > CustomizeObjectLayer::onBreakApart @ 0x83fb60
// > ??> @ 0xa7bb0
//
// 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 LevelEditorLayer::breakApartTextObject(LevelEditorLayer *a1, TextGameObject *a2)
{
EditorUI *m_editorUI; // x0
long double v5; // q0
cocos2d::CCArray *v6; // x23
unsigned __int64 v7; // x19
float *v8; // x20
__int64 v9; // x0
unsigned __int64 v10; // x2
cocos2d::CCSpriteBatchNode *m_textLayerB1; // x27
float v12; // s8
__int64 v13; // x0
GameObject *Object; // x20
unsigned __int64 v15; // x3
void *v16; // x0
cocos2d::CCArray *v17; // x0
unsigned int *v18; // x1
int v19; // w2
EditorUI *v20; // x0
void *v21; // x0
unsigned int *v22; // x20
int v23; // w1
__int64 v24; // [xsp+0h] [xbp+0h] BYREF
cocos2d::CCArray *v25; // [xsp+70h] [xbp+70h]
__int64 (__fastcall **v26)(int, int, int, int, int, int, int, int, char); // [xsp+78h] [xbp+78h]
__int64 v27; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v28; // [xsp+90h] [xbp+90h] BYREF
cocos2d::CCPoint v29; // [xsp+98h] [xbp+98h] BYREF
cocos2d::CCPoint v30; // [xsp+A0h] [xbp+A0h] BYREF
cocos2d::CCPoint v31; // 0:s0.4,4:s1.4
if ( a2 && a2->m_objectID == 914 )
{
m_editorUI = a1->m_editorUI;
if ( m_editorUI )
EditorUI::deselectAll(m_editorUI);
v26 = &jpeg_idct_9x9_ptr;
LevelEditorLayer::removeObject(a1, a2, 0);
a1->m_textLayerB1->addChild(a1->m_textLayerB1, a2);
*(__n128 *)&v5 = sub_D18D28(&v27, &a2->m_text);
v6 = (cocos2d::CCArray *)((__int64 (__fastcall *)(TextGameObject *, long double))a2->getChildren)(a2, v5);
v25 = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)&jpeg_idct_9x9_ptr);
v7 = 0;
v26 = &jpeg_idct_9x9_ptr;
while ( (unsigned int)cocos2d::CCArray::count(v6) > (unsigned int)v7 )
{
v8 = (float *)cocos2d::CCArray::objectAtIndex(v6, v7);
v9 = v27;
v10 = *(_QWORD *)(v27 - 24);
if ( v7 >= v10 )
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", v7, v10);
if ( (*(_DWORD *)(v27 - 8) & 0x80000000) == 0 )
{
sub_D176A8(&v27);
v9 = v27;
}
if ( *(_BYTE *)(v9 + v7) != 32 )
{
m_textLayerB1 = a1->m_textLayerB1;
v12 = *(float *)(*(__int64 (__fastcall **)(float *))(*(_QWORD *)v8 + 192LL))(v8) - v8[149];
v13 = (*(__int64 (__fastcall **)(float *))(*(_QWORD *)v8 + 312LL))(v8);
cocos2d::CCPoint::CCPoint(&v29, v12, v8[150] + (float)(*(float *)(v13 + 4) * 0.5));
cocos2d::CCNode::convertToWorldSpace(a2, &v29);
cocos2d::CCNode::convertToNodeSpace(m_textLayerB1, &v30);
cocos2d::CCPoint::CCPoint(&v30, &v28);
Object = LevelEditorLayer::createObject(a1, 914, v31, (unsigned __int8)&v24 - 96);
GameObject::duplicateValues(Object);
v15 = *(_QWORD *)(v27 - 24);
if ( v7 > v15 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v7, v15);
sub_D14F84(&v30, &v27, v7, 1);
TextGameObject::updateTextObject((__int64 *)Object, (const void **)&v30, 0);
v16 = (void *)(*(_QWORD *)&v30 - 24LL);
if ( (__int64 (__fastcall *)(int, int, int, int, int, int, int, int, char))(*(_QWORD *)&v30 - 24LL) != v26[509] )
{
if ( &pthread_create )
{
v18 = (unsigned int *)(*(_QWORD *)&v30 - 8LL);
do
v19 = __ldaxr(v18);
while ( __stlxr(v19 - 1, v18) );
}
else
{
v19 = *(_DWORD *)(*(_QWORD *)&v30 - 8LL);
*(_DWORD *)(*(_QWORD *)&v30 - 8LL) = v19 - 1;
}
if ( v19 <= 0 )
operator delete(v16);
}
v17 = v25;
Object->m_updateEditorColor = 1;
cocos2d::CCArray::addObject(v17, Object);
}
++v7;
}
a2->removeFromParentAndCleanup(a2, 0);
v20 = a1->m_editorUI;
if ( v20 )
EditorUI::selectObjects(v20, v25, 1);
v21 = (void *)(v27 - 24);
if ( (__int64 (__fastcall *)(int, int, int, int, int, int, int, int, char))(v27 - 24) != v26[509] )
{
if ( &pthread_create )
{
v22 = (unsigned int *)(v27 - 8);
do
v23 = __ldaxr(v22);
while ( __stlxr(v23 - 1, v22) );
}
else
{
v23 = *(_DWORD *)(v27 - 8);
*(_DWORD *)(v27 - 8) = v23 - 1;
}
if ( v23 <= 0 )
operator delete(v21);
}
}
}