//
// GJSmartBlockPreview::addPreview from 0x9d6064 to 0x9d6294 (560 bytes)
//
// 3 xrefs:
// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x9deb88
// > BrowseSmartKeyLayer::init @ 0x9e0a04
// > ??> @ 0x7b180
//
// 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
//
__int64 __fastcall GJSmartBlockPreview::addPreview(__int64 a1, unsigned __int8 **a2, _QWORD *a3, LevelEditorLayer *a4)
{
cocos2d::CCArray *v7; // x0
cocos2d::CCArray *v9; // x25
EditorUI *m_editorUI; // x24
cocos2d::CCSprite *v11; // x26
char *v12; // x0
unsigned __int8 *v13; // x1
SmartBlockType v14; // w27
__int64 v15; // x0
unsigned int *v16; // x2
int v17; // w1
float v18; // [xsp+60h] [xbp+60h]
__int64 v19; // [xsp+70h] [xbp+70h] BYREF
cocos2d::CCPoint v20; // [xsp+78h] [xbp+78h] BYREF
_DWORD *v21; // [xsp+80h] [xbp+80h] BYREF
v7 = *(cocos2d::CCArray **)(*a3 - 24LL);
if ( v7 )
{
v9 = (cocos2d::CCArray *)cocos2d::CCArray::create(v7);
m_editorUI = a4->m_editorUI;
sub_D18D28(&v21);
v11 = EditorUI::spriteFromObjectString(m_editorUI, (const void **)&v21, 0, 0, 0, v9, nullptr, 0);
v12 = (char *)(v21 - 6);
if ( v21 - 6 != (_DWORD *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = v21 - 2;
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *(v21 - 2);
*(v21 - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v12);
}
(*(void (__fastcall **)(__int64, cocos2d::CCSprite *, __int64))(*(_QWORD *)a1 + 448LL))(a1, v11, 10);
v13 = *a2;
if ( !*((_QWORD *)*a2 - 3) )
sub_D13C5C("basic_string::at: __n (which is %zu) >= this->size() (which is %zu)", 0, 0);
if ( (*((_DWORD *)v13 - 2) & 0x80000000) == 0 )
{
sub_D176A8(a2);
v13 = *a2;
}
v14 = *v13;
v18 = *(float *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 312LL))(a1) * 0.5;
v15 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)a1 + 312LL))(a1);
cocos2d::CCPoint::CCPoint(&v20, v18, *(float *)(v15 + 4) * 0.5);
GJSmartTemplate::offsetForType(v14);
cocos2d::CCPoint::operator+(&v19, &v20, &v21);
v11->setPosition(v11, (const cocos2d::CCPoint *)&v19);
LevelEditorLayer::updateObjectColors(a4, v9);
}
return _stack_chk_guard;
}