//
// LevelEditorLayer::breakApartTextObject from 0x7a1640 to 0x7a1b34 (1268 bytes)
//
// 2 xrefs:
// > CustomizeObjectLayer::onBreakApart @ 0x982be0
// > ??> @ 0xdc138
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:53:39 +0000
//
__int64 __fastcall LevelEditorLayer::breakApartTextObject(LevelEditorLayer *this, TextGameObject *a2)
{
EditorUI *v4; // x0
char v5; // w0
__int64 v6; // x0
__int64 v7; // x1
cocos2d::CCArray *v8; // x23
unsigned int v9; // w21
__int64 v10; // x0
int v11; // w5
__int64 v12; // x22
char *v13; // x6
int v14; // w1
int v15; // w4
unsigned __int64 v16; // x2
char *v17; // x0
char v18; // w0
size_t v19; // x3
const cocos2d::CCPoint *v20; // x0
cocos2d::CCNode *v21; // x22
cocos2d::CCObject **Object; // x22
cocos2d::CCObject *v23; // x1
cocos2d::CCArray *v24; // x0
__int64 v25; // x0
__int64 v26; // x27
__int64 v27; // x0
long double v28; // q0
long double v29; // q0
char v30; // w0
int v31; // w3
int v32; // w0
_BYTE *v33; // x0
EditorUI *v34; // x0
cocos2d::CCArray *v35; // [xsp+60h] [xbp+60h]
cocos2d::CCNode *v36; // [xsp+68h] [xbp+68h]
void (__fastcall *v37)(cocos2d::CCObject **, __int64 *); // [xsp+70h] [xbp+70h]
_BYTE v39[8]; // [xsp+98h] [xbp+98h] BYREF
__int64 v40; // [xsp+A0h] [xbp+A0h] BYREF
__int64 v41; // [xsp+A8h] [xbp+A8h] BYREF
__int64 v42; // [xsp+B0h] [xbp+B0h] BYREF
__int64 v43; // [xsp+B8h] [xbp+B8h] BYREF
__int64 v44; // [xsp+C0h] [xbp+C0h] BYREF
__int64 v45; // [xsp+C8h] [xbp+C8h]
void *v46; // [xsp+D0h] [xbp+D0h]
__int64 v47; // [xsp+D8h] [xbp+D8h] BYREF
size_t v48; // [xsp+E0h] [xbp+E0h]
void *v49; // [xsp+E8h] [xbp+E8h]
__int64 v50; // [xsp+F0h] [xbp+F0h] BYREF
size_t v51; // [xsp+F8h] [xbp+F8h]
void *v52; // [xsp+100h] [xbp+100h]
if ( !a2 || *((_DWORD *)a2 + 257) != 914 )
return _stack_chk_guard;
v4 = *((EditorUI **)this + 1781);
if ( v4 )
EditorUI::deselectAll(v4);
LevelEditorLayer::removeObject((__int64)this, a2, 0);
(*(void (__fastcall **)(_QWORD, TextGameObject *))(**((_QWORD **)this + 341) + 456LL))(*((_QWORD *)this + 341), a2);
v44 = 0;
v5 = *((_BYTE *)a2 + 1352);
v45 = 0;
v46 = nullptr;
if ( (v5 & 1) != 0 )
{
std::string::__init(&v44, *((void **)a2 + 171), *((_QWORD *)a2 + 170));
}
else
{
v6 = *((_QWORD *)a2 + 169);
v7 = *((_QWORD *)a2 + 170);
v46 = *((void **)a2 + 171);
v44 = v6;
v45 = v7;
}
v8 = (cocos2d::CCArray *)(*(__int64 (__fastcall **)(TextGameObject *))(*(_QWORD *)a2 + 488LL))(a2);
v35 = (cocos2d::CCArray *)cocos2d::CCArray::create(v8);
v9 = 0;
while ( v9 < (unsigned int)cocos2d::CCArray::count(v8) )
{
v10 = cocos2d::CCArray::objectAtIndex(v8, v9);
v11 = *(_DWORD *)(v10 + 640);
v12 = v10;
if ( v11 > 0 )
{
v13 = (char *)&v44 + 1;
v14 = 0;
v15 = v44 & 1;
if ( (v44 & 1) != 0 )
v13 = (char *)v46;
LODWORD(v16) = 0;
while ( 1 )
{
if ( (v44 & 1) != 0 )
{
if ( (int)v45 <= (int)v16 )
{
v16 = (int)v16;
goto LABEL_17;
}
}
else if ( (int)(unsigned __int8)v44 >> 1 <= (int)v16 )
{
v16 = (int)v16;
v17 = (char *)&v44 + 1;
LABEL_18:
v18 = v17[v16];
if ( (v18 & 0xE0) != 0xC0 )
goto LABEL_19;
LABEL_39:
v19 = 2;
goto LABEL_22;
}
v30 = v13[(int)v16];
if ( (v30 & 0xE0) == 0xC0 )
{
v31 = 2;
}
else if ( (v30 & 0xF0) == 0xE0 )
{
v31 = 3;
}
else
{
v31 = 1;
if ( (v30 & 0xF8) == 0xF0 )
{
v31 = 4;
v32 = 2;
goto LABEL_35;
}
}
v32 = 1;
LABEL_35:
v14 += v32;
LODWORD(v16) = v16 + v31;
if ( v11 <= v14 )
{
v16 = (int)v16;
goto LABEL_37;
}
}
}
v16 = 0;
v15 = v44 & 1;
LABEL_37:
if ( v15 )
{
LABEL_17:
v17 = (char *)v46;
goto LABEL_18;
}
v18 = *((_BYTE *)&v44 + v16 + 1);
if ( (v18 & 0xE0) == 0xC0 )
goto LABEL_39;
LABEL_19:
v19 = 3;
if ( (v18 & 0xF0) != 0xE0 )
{
v19 = 4;
if ( (v18 & 0xF8) != 0xF0 )
v19 = 1;
}
LABEL_22:
std::string::basic_string(&v47, (__int64)&v44, v16, v19);
if ( (v47 & 1) != 0 )
{
if ( v48 != 1 )
goto LABEL_24;
v33 = v49;
}
else
{
if ( (int)(unsigned __int8)v47 >> 1 != 1 )
goto LABEL_24;
v33 = (char *)&v47 + 1;
}
if ( *v33 == 32 )
{
if ( (v47 & 1) == 0 )
goto LABEL_29;
LABEL_30:
++v9;
operator delete(v49);
}
else
{
LABEL_24:
v20 = (const cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v12 + 192LL))(v12);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v39, v20);
v21 = *((cocos2d::CCNode **)this + 341);
cocos2d::CCNode::convertToWorldSpace(&v42, a2, (const cocos2d::CCPoint *)v39);
cocos2d::CCNode::convertToNodeSpace(&v43, v21, (const cocos2d::CCPoint *)&v42);
Object = LevelEditorLayer::createObject((cocos2d::CCArray **)this, 0x392u, (const cocos2d::CCPoint *)&v43, 0);
GameObject::duplicateValues((GameObject *)Object, a2);
v50 = 0;
v51 = 0;
v52 = nullptr;
if ( (v47 & 1) != 0 )
{
std::string::__init(&v50, v49, v48);
}
else
{
v52 = v49;
v50 = v47;
v51 = v48;
}
TextGameObject::updateTextObject(Object, (unsigned __int8 *)&v50, 0);
if ( (v50 & 1) != 0 )
operator delete(v52);
v23 = *Object;
*((_BYTE *)Object + 1149) = 1;
v24 = (cocos2d::CCArray *)(*((__int64 (__fastcall **)(cocos2d::CCObject **))v23 + 61))(Object);
v25 = cocos2d::CCArray::objectAtIndex(v24, 0);
v26 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v25 + 192LL))(v25);
v27 = (*((__int64 (__fastcall **)(cocos2d::CCObject **))*Object + 39))(Object);
cocos2d::CCPoint::operator-(&v40, v26, v27, v28);
v36 = *((cocos2d::CCNode **)this + 341);
v37 = *((void (__fastcall **)(cocos2d::CCObject **, __int64 *))*Object + 171);
cocos2d::CCPoint::operator-(&v41, v39, &v40, v29);
cocos2d::CCNode::convertToWorldSpace(&v42, a2, (const cocos2d::CCPoint *)&v41);
cocos2d::CCNode::convertToNodeSpace(&v43, v36, (const cocos2d::CCPoint *)&v42);
v37(Object, &v43);
GJBaseGameLayer::reorderObjectSection(this, (GameObject *)Object);
cocos2d::CCArray::addObject(v35, (cocos2d::CCObject *)Object);
if ( (v47 & 1) != 0 )
goto LABEL_30;
LABEL_29:
++v9;
}
}
(*(void (__fastcall **)(TextGameObject *, _QWORD))(*(_QWORD *)a2 + 528LL))(a2, 0);
v34 = *((EditorUI **)this + 1781);
if ( v34 )
EditorUI::selectObjects(v34, v35, 1);
if ( (v44 & 1) != 0 )
operator delete(v46);
return _stack_chk_guard;
}