//
// LevelEditorLayer::createObject from 0x671db4 to 0x672108 (852 bytes)
//
// 4 xrefs:
// > LevelEditorLayer::addSpecial @ 0x670714
// > LevelEditorLayer::breakApartTextObject @ 0x6722ec
// > EditorUI::createObject @ 0x688ef0
// > ??> @ 0xa8f78
//
// 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
//
// local variable allocation has failed, the output may be wrong!
GameObject *LevelEditorLayer::createObject(LevelEditorLayer *a1, int a2, cocos2d::CCPoint a3, bool a4)
{
unsigned __int8 v4; // w3
_BOOL8 v5; // x26
int v6; // w27
GameObject *v8; // x19
ObjectToolbox *v9; // x0
char *v10; // x0
int m_objectID; // w0
char *v12; // x0
void (__fastcall *setupCustomSprites)(GameObject *__hidden, std::string); // x24
long double v14; // q0
void *v15; // x0
int m_currentLayer; // w0
void (__fastcall *setStartPos)(GameObject *__hidden, cocos2d::CCPoint); // x24
void *v18; // x0
UndoObject *v20; // x0
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
__int64 v27; // [xsp+0h] [xbp+0h] BYREF
int v28[4]; // [xsp+68h] [xbp+68h]
__int64 v29; // [xsp+80h] [xbp+80h] BYREF
char *v30; // [xsp+88h] [xbp+88h] BYREF
cocos2d::CCPoint v31; // [xsp+90h] [xbp+90h] BYREF
v5 = a4;
*(_QWORD *)v28 = *(_QWORD *)&a2;
v6 = v4;
v8 = GameObject::createWithKey(a2);
if ( !v8 )
return nullptr;
v9 = ObjectToolbox::sharedState();
v10 = (char *)ObjectToolbox::intKeyToFrame(v9, v28[0]);
sub_D153B8((unsigned int)&v27 + 128, v10);
v8->setVisible(v8, 0);
m_objectID = v8->m_objectID;
if ( m_objectID == 9 || m_objectID == 1715 )
v8->m_defaultZOrder = 2;
v8->firstSetup(v8);
v8->customSetup(v8);
sub_D18D28(&v30, &v29);
GameObject::addColorSprite(v8, &v30);
v12 = v30 - 24;
if ( v30 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v30 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *((_DWORD *)v30 - 2);
*((_DWORD *)v30 - 2) = v24 - 1;
}
if ( v24 <= 0 )
operator delete(v12);
}
setupCustomSprites = v8->setupCustomSprites;
*(__n128 *)&v14 = sub_D18D28(&v31, &v29);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *, long double))setupCustomSprites)(v8, &v31, v14);
v15 = (void *)(*(_QWORD *)&v31 - 24LL);
if ( (__int64 *)(*(_QWORD *)&v31 - 24LL) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(*(_QWORD *)&v31 - 8LL);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(_DWORD *)(*(_QWORD *)&v31 - 8LL);
*(_DWORD *)(*(_QWORD *)&v31 - 8LL) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v15);
}
v8->saveActiveColors(v8);
m_currentLayer = a1->m_currentLayer;
if ( m_currentLayer != -1 )
v8->m_editorLayer = m_currentLayer;
setStartPos = v8->setStartPos;
cocos2d::CCPoint::CCPoint(&v31, (const cocos2d::CCPoint *)v5);
((void (__fastcall *)(GameObject *, cocos2d::CCPoint *))setStartPos)(v8, &v31);
a1->addToSection(a1, v8);
LevelEditorLayer::addSpecial(a1, v8);
if ( !v6 )
{
cocos2d::CCArray::removeAllObjects(a1->m_redoObjects);
v20 = UndoObject::create(v8, New);
LevelEditorLayer::addToUndoList(a1, v20, 0);
}
v18 = (void *)(v29 - 24);
if ( (__int64 *)(v29 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v29 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(v29 - 8);
*(_DWORD *)(v29 - 8) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v18);
}
return v8;
}