// // EditorUI::createSmartObjectsFromTemplate from 0x1401b6820 to 0x1401b7373 (2899 bytes) // // 3 xrefs: // > SetupSmartBlockLayer::onPasteTemplate @ 0x1405eda85 // > SetupSmartBlockLayer::onCreate @ 0x1405ee227 // > @ 0x14091a234 // // This function is hookable on this platform (idp: pc, 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 11:27:58 +0000 // // Hidden C++ exception states: #wind=9 void __fastcall EditorUI::createSmartObjectsFromTemplate( __int64 a1, __int64 a2, cocos2d::CCArray *a3, char a4, char a5, char a6) { cocos2d::CCArray *v6; // r14 __int64 v8; // rsi __int64 v9; // rdx int v10; // ecx int v11; // eax int v12; // ecx __int64 v13; // rdi _QWORD *v14; // rbx __int64 v15; // rcx __int64 v16; // rcx cocos2d::CCArray *v17; // r15 __int64 v18; // rcx cocos2d::CCDictionary *v19; // r13 unsigned int v20; // r12d struct cocos2d::CCObject *v21; // rbx int v22; // eax __int64 v23; // rax unsigned int v24; // eax __int64 v25; // rax __int64 v26; // rbx __int64 v27; // rax __int64 v28; // r8 cocos2d::CCArray *v29; // rax cocos2d::CCArray *v30; // r15 unsigned int i; // edi struct cocos2d::CCObject *v32; // rax struct cocos2d::CCObject *v33; // rbx unsigned int v34; // ebx struct cocos2d::CCObject *v35; // rax struct cocos2d::CCObject *v36; // rdi __int64 v37; // rax unsigned int v38; // eax __int64 v39; // rax int v40; // eax int v41; // ecx int v42; // eax int v43; // ecx __int64 v44; // r13 int v45; // eax int v46; // ecx __int64 v47; // r12 int v48; // eax int v49; // ecx __int64 v50; // r15 int v51; // eax int v52; // ecx __int64 v53; // r14 __int64 v54; // rbx int v55; // eax int v56; // ecx __int64 v57; // rsi int v58; // eax int v59; // ecx __int64 v60; // rdi int v61; // eax int v62; // ecx __int64 v63; // rbx void **v64; // rdi int v65; // eax __int64 v66; // rax __int64 v67; // rcx void **v68; // r14 size_t v69; // rsi unsigned __int64 v70; // rax size_t v71; // rbx void **v72; // rdx __int64 v73; // rax __int64 v74; // r9 cocos2d::CCArray *v75; // rax struct cocos2d::CCArray *v76; // rbx const struct cocos2d::CCPoint *v77; // rax __int64 v78; // rax int v79; // eax int v80; // r8d __int64 v81; // rax __int64 v82; // rbx __int64 j; // rdi _BYTE *v84; // rbx __int64 v85; // r8 unsigned int v86; // r12d unsigned int v87; // ebx cocos2d::CCArray *k; // rdi struct cocos2d::CCObject *v89; // rax cocos2d::CCObject **v90; // rdi __int64 v91; // rcx struct cocos2d::CCArray *v92; // r15 cocos2d::CCArray *v93; // rax __int64 v94; // r14 unsigned int v95; // ebx unsigned int m; // r14d struct cocos2d::CCObject *v97; // rax struct cocos2d::CCObject *v98; // rdi __int64 v99; // rbx __int64 v100; // rdx cocos2d::CCObject **v101; // rbx __int64 v102; // rcx struct cocos2d::CCArray *v103; // r14 cocos2d::CCArray *v104; // rax __int64 v105; // rdi __int64 v106; // [rsp+48h] [rbp-B8h] float v108[2]; // [rsp+68h] [rbp-98h] BYREF void **SmartNeighbor; // [rsp+70h] [rbp-90h] BYREF unsigned int v110; // [rsp+78h] [rbp-88h] cocos2d::CCArray *v111; // [rsp+80h] [rbp-80h] char v112[8]; // [rsp+88h] [rbp-78h] BYREF void *v113[2]; // [rsp+90h] [rbp-70h] BYREF size_t v114; // [rsp+A0h] [rbp-60h] __int64 v115; // [rsp+A8h] [rbp-58h] cocos2d::CCArray *v116; // [rsp+B0h] [rbp-50h] void **v117; // [rsp+B8h] [rbp-48h] __int64 v118; // [rsp+C0h] [rbp-40h] cocos2d::CCArray *v119; // [rsp+C8h] [rbp-38h] cocos2d::CCArray *v120; // [rsp+D0h] [rbp-30h] _QWORD v121[2]; // [rsp+D8h] [rbp-28h] BYREF __int128 v122; // [rsp+E8h] [rbp-18h] BYREF __int64 v123; // [rsp+F8h] [rbp-8h] __int64 v124; // [rsp+100h] [rbp+0h] char v125[8]; // [rsp+108h] [rbp+8h] BYREF __int64 v126; // [rsp+110h] [rbp+10h] cocos2d::CCDictionary *v127; // [rsp+118h] [rbp+18h] char v128[8]; // [rsp+120h] [rbp+20h] BYREF char v129[8]; // [rsp+128h] [rbp+28h] BYREF char v130[8]; // [rsp+130h] [rbp+30h] BYREF char v131[8]; // [rsp+138h] [rbp+38h] BYREF char v132[8]; // [rsp+140h] [rbp+40h] BYREF char v133[8]; // [rsp+148h] [rbp+48h] BYREF char v134[8]; // [rsp+150h] [rbp+50h] BYREF char v135[8]; // [rsp+158h] [rbp+58h] BYREF _BYTE v136[16]; // [rsp+160h] [rbp+60h] BYREF char v137[8]; // [rsp+170h] [rbp+70h] BYREF char v138[8]; // [rsp+178h] [rbp+78h] BYREF char v139[8]; // [rsp+180h] [rbp+80h] BYREF char v140[32]; // [rsp+188h] [rbp+88h] BYREF char v141[40]; // [rsp+1A8h] [rbp+A8h] BYREF __int64 v142; // [rsp+1D0h] [rbp+D0h] BYREF char v143[32]; // [rsp+1D8h] [rbp+D8h] BYREF void *Src[2]; // [rsp+1F8h] [rbp+F8h] BYREF size_t Size; // [rsp+208h] [rbp+108h] unsigned __int64 v146; // [rsp+210h] [rbp+110h] int v147; // [rsp+220h] [rbp+120h] char v148; // [rsp+224h] [rbp+124h] char v149; // [rsp+225h] [rbp+125h] _BYTE v150[32]; // [rsp+230h] [rbp+130h] BYREF if ( a3 ) { v6 = a3; v119 = a3; v126 = a2; v8 = a1; v118 = a1; if ( cocos2d::CCArray::count(a3) ) { if ( a2 ) { v9 = *(_QWORD *)(v8 + 1512); v10 = *(_DWORD *)(v9 + 15504); if ( v10 >= 0 ) { v11 = *(_DWORD *)(v9 + 15440) - v10; v12 = 0; if ( v11 > 1 ) { do { if ( v12 >= 7 ) break; v11 = (unsigned int)v11 >> 1; ++v12; } while ( (unsigned int)v11 > 1 ); } ++*(_DWORD *)(v9 + 4LL * v12 + 15472); } *(_DWORD *)(v9 + 15504) = *(_DWORD *)(v9 + 15440); v13 = a2 + 112; v14 = *(_QWORD **)(a2 + 112); sub_1403BD060(v13, v13, v14[1]); v14[1] = v14; *v14 = v14; v14[2] = v14; *(_QWORD *)(v13 + 8) = 0; EditorUI::deselectAll(v8); v116 = (cocos2d::CCArray *)cocos2d::CCArray::create(v15); v17 = (cocos2d::CCArray *)cocos2d::CCArray::create(v16); v111 = v17; v120 = (cocos2d::CCArray *)cocos2d::CCArray::create(v18); v19 = (cocos2d::CCDictionary *)cocos2d::CCDictionary::create(); v127 = v19; v20 = 0; if ( cocos2d::CCArray::count(v6) ) { do { v21 = cocos2d::CCArray::objectAtIndex(v6, v20); v22 = *((_DWORD *)v21 + 259); if ( v22 == 2896 || v22 == 2897 ) GameObject::determineSlopeDirection(v21); if ( a4 ) { cocos2d::CCPoint::CCPoint( (cocos2d::CCPoint *)&SmartNeighbor, (const struct cocos2d::CCPoint *)&unk_14090AD10); v24 = GJSmartTemplate::smartObjectToType(v21, v23); GJSmartTemplate::offsetForType(v112, v24); v25 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v21 + 200LL))(v21); cocos2d::CCPoint::operator+(v25, v108, v112); cocos2d::CCRect::CCRect((cocos2d::CCRect *)v121, v108[0] - 37.5, v108[1] - 37.5, 75.0, 75.0); v26 = *(_QWORD *)(v8 + 1512); v27 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v136, (const struct cocos2d::CCRect *)v121); LOBYTE(v28) = 1; v29 = (cocos2d::CCArray *)LevelEditorLayer::objectsInRect(v26, v27, v28); v30 = v29; if ( v29 ) { if ( cocos2d::CCArray::count(v29) ) { for ( i = 0; i < cocos2d::CCArray::count(v30); ++i ) { v32 = cocos2d::CCArray::objectAtIndex(v30, i); v33 = v32; if ( *((_DWORD *)v32 + 314) == 5 && !cocos2d::CCArray::containsObject(v6, v32) ) { cocos2d::CCArray::addObject(v6, v33); cocos2d::CCDictionary::setObject(v19, v33, *((unsigned int *)v33 + 231)); (*(void (__fastcall **)(struct cocos2d::CCObject *, _QWORD))(*(_QWORD *)v33 + 64LL))( v33, *((unsigned __int8 *)v33 + 1360)); *((_BYTE *)v33 + 1360) = 1; } } } } } ++v20; } while ( v20 < cocos2d::CCArray::count(v6) ); v17 = v111; } v34 = 0; v110 = 0; if ( cocos2d::CCArray::count(v6) ) { while ( 1 ) { v35 = cocos2d::CCArray::objectAtIndex(v6, v34); v36 = v35; v117 = (void **)v35; if ( *((_BYTE *)v35 + 1360) ) { if ( !cocos2d::CCDictionary::objectForKey(v19, *((unsigned int *)v35 + 231)) ) cocos2d::CCArray::addObject(v17, v36); } else { cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v137, (const struct cocos2d::CCPoint *)&unk_14090AD10); v38 = GJSmartTemplate::smartObjectToType(v36, v37); GJSmartTemplate::offsetForType(v125, v38); v39 = (*(__int64 (__fastcall **)(struct cocos2d::CCObject *))(*(_QWORD *)v36 + 200LL))(v36); cocos2d::CCPoint::operator+(v39, v108, v125); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v138, (const struct cocos2d::CCPoint *)v108); SmartNeighbor = (void **)EditorUI::getSmartNeighbor(v41, (_DWORD)v36, v40, 1, (__int64)v6); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v139, (const struct cocos2d::CCPoint *)v108); v44 = EditorUI::getSmartNeighbor(v43, (_DWORD)v36, v42, 2, (__int64)v6); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v128, (const struct cocos2d::CCPoint *)v108); v47 = EditorUI::getSmartNeighbor(v46, (_DWORD)v36, v45, 3, (__int64)v6); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v129, (const struct cocos2d::CCPoint *)v108); v50 = EditorUI::getSmartNeighbor(v49, (_DWORD)v36, v48, 4, (__int64)v6); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v130, (const struct cocos2d::CCPoint *)v108); v53 = EditorUI::getSmartNeighbor(v52, (_DWORD)v36, v51, 5, (__int64)v6); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v131, (const struct cocos2d::CCPoint *)v108); v54 = (__int64)v119; v57 = EditorUI::getSmartNeighbor(v56, (_DWORD)v36, v55, 6, (__int64)v119); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v132, (const struct cocos2d::CCPoint *)v108); v60 = EditorUI::getSmartNeighbor(v59, (_DWORD)v36, v58, 7, v54); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v133, (const struct cocos2d::CCPoint *)v108); v63 = EditorUI::getSmartNeighbor(v62, (_DWORD)v117, v61, 8, v54); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v134, (const struct cocos2d::CCPoint *)v108); v106 = v60; v64 = v117; GJSmartTemplate::keyFromNeighbors( (unsigned int)v150, v65, (_DWORD)v117, (_DWORD)SmartNeighbor, v44, v47, v50, v53, v57, v106, v63); v66 = sub_14003F4F0((__int64)v140, (__int64)v150); GJSmartTemplate::scanForPrefab(v126, &v142, v66); if ( v142 ) { cocos2d::CCArray::addObject(v120, (struct cocos2d::CCObject *)v64); *(_OWORD *)v113 = 0; v114 = 0; v115 = 0; v68 = Src; if ( v146 > 0xF ) v68 = (void **)Src[0]; v69 = Size; if ( Size > 0x7FFFFFFFFFFFFFFFLL ) sub_140009D90(v67); if ( Size > 0xF ) { v71 = Size | 0xF; if ( (Size | 0xF) <= 0x7FFFFFFFFFFFFFFFLL ) { if ( v71 < 0x16 ) v71 = 22; } else { v71 = 0x7FFFFFFFFFFFFFFFLL; } v113[0] = sub_14003D460(v71 + 1); v114 = v69; v115 = v71; memcpy(v113[0], v68, v69 + 1); v70 = v115; v69 = v114; } else { v114 = Size; v70 = 15; v115 = 15; *(_OWORD *)v113 = *(_OWORD *)v68; } SmartNeighbor = v113; if ( v64 + 171 != v113 ) { v72 = v113; if ( v70 > 0xF ) v72 = (void **)v113[0]; sub_1400405A0(v64 + 171, v72, v69); } sub_14003D310((__int64)v113); v73 = sub_14003F4F0((__int64)v141, v142 + 88); LOBYTE(v74) = 1; v8 = v118; v75 = (cocos2d::CCArray *)EditorUI::pasteObjects(v118, v73, 0, v74); v76 = v75; if ( v75 && cocos2d::CCArray::count(v75) ) { v77 = (const struct cocos2d::CCPoint *)(*((__int64 (__fastcall **)(void **))*v64 + 25))(v64); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v112, v77); cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v135, (const struct cocos2d::CCPoint *)v112); EditorUI::repositionObjectsToCenter(v8, v76, v78, 0); if ( v149 ) EditorUI::flipObjectsY(v8, v76); if ( v148 ) EditorUI::flipObjectsX(v8, v76); if ( v147 > 0 ) { cocos2d::CCPoint::CCPoint( (cocos2d::CCPoint *)v136, (const struct cocos2d::CCPoint *)&dword_14090A6E8); EditorUI::rotateObjects(v8, (_DWORD)v76, v80, v79, 0); } cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v121, (const struct cocos2d::CCPoint *)v112); EditorUI::repositionObjectsToCenter(v8, v76, v81, 0); EditorUI::deleteSmartBlocksFromObjects(v8, v76); cocos2d::CCArray::addObjectsFromArray(v116, v76); cocos2d::CCArray::addObject(v111, (struct cocos2d::CCObject *)v64); } } else { v122 = 0; v123 = 0; v124 = 15; LOBYTE(v122) = 0; SmartNeighbor = (void **)&v122; if ( v64 + 171 != (void **)&v122 ) sub_1400405A0(v64 + 171, &v122, 0); sub_14003D310((__int64)&v122); v8 = v118; } sub_14003D310((__int64)Src); sub_14003D310((__int64)v143); sub_14003D310((__int64)v150); v6 = v119; v19 = v127; v34 = v110; } v110 = ++v34; if ( v34 >= cocos2d::CCArray::count(v6) ) break; v17 = v111; } } if ( a4 ) { if ( v19 ) { v82 = *((_QWORD *)v19 + 7); if ( v82 ) { for ( j = *(_QWORD *)(v82 + 288); ; j = *(_QWORD *)(j + 288) ) { v84 = *(_BYTE **)(v82 + 264); v84[1360] = (*(unsigned int (__fastcall **)(_BYTE *))(*(_QWORD *)v84 + 56LL))(v84) != 0; v82 = j; if ( !j ) break; } } } } EditorUI::deselectAll(v8); v86 = 1000; if ( a6 ) { v87 = 0; for ( k = v120; v87 < cocos2d::CCArray::count(k); ++v87 ) { v89 = cocos2d::CCArray::objectAtIndex(k, v87); *((_BYTE *)v89 + 1360) = 1; SmartGameObject::updateSmartFrame(v89); } } else if ( !a5 ) { v90 = (cocos2d::CCObject **)operator new(0xA0u); v121[0] = v90; cocos2d::CCObject::CCObject((cocos2d::CCObject *)v90); *v90 = (cocos2d::CCObject *)&UndoObject::`vftable'; v90[7] = nullptr; *((_DWORD *)v90 + 16) = 0; v90[9] = nullptr; *((_WORD *)v90 + 40) = 0; GJTransformState::GJTransformState((__int64)v90 + 84); v92 = v111; if ( v111 ) { v93 = (cocos2d::CCArray *)cocos2d::CCArray::create(v91); v90[9] = v93; cocos2d::CCArray::addObjectsFromArray(v93, v92); cocos2d::CCObject::retain(v90[9]); } *((_DWORD *)v90 + 16) = 4; cocos2d::CCObject::autorelease((cocos2d::CCObject *)v90); v94 = *(_QWORD *)(v8 + 1512); cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(v94 + 14920)); v95 = 1000; if ( !*(_BYTE *)(v94 + 14663) ) v95 = 200; if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v94 + 14912)) >= v95 ) cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v94 + 14912), 0, 1); cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v94 + 14912), (struct cocos2d::CCObject *)v90); for ( m = 0; m < cocos2d::CCArray::count(v92); ++m ) { v97 = cocos2d::CCArray::objectAtIndex(v92, m); v98 = v97; if ( v97 ) { *((_BYTE *)v97 + 1140) = *((_BYTE *)v97 + 1141); EditorUI::deselectObject(v8, v97); v99 = *(_QWORD *)(v8 + 1512); LOBYTE(v100) = 1; (*(void (__fastcall **)(struct cocos2d::CCObject *, __int64))(*(_QWORD *)v98 + 1160LL))(v98, v100); GJBaseGameLayer::removeObjectFromSection(v99, v98); LevelEditorLayer::removeSpecial(v99, v98); *(_BYTE *)(v99 + 15666) = 1; EditorUI::deactivateRotationControl(v8); EditorUI::deactivateScaleControl(v8); EditorUI::deactivateTransformControl(v8); } } v6 = v116; } LOBYTE(v85) = 1; EditorUI::selectObjects(v8, v6, v85); v101 = (cocos2d::CCObject **)operator new(0xA0u); v121[0] = v101; cocos2d::CCObject::CCObject((cocos2d::CCObject *)v101); *v101 = (cocos2d::CCObject *)&UndoObject::`vftable'; v101[7] = nullptr; *((_DWORD *)v101 + 16) = 0; v101[9] = nullptr; *((_WORD *)v101 + 40) = 0; GJTransformState::GJTransformState((__int64)v101 + 84); v103 = v116; if ( v116 ) { v104 = (cocos2d::CCArray *)cocos2d::CCArray::create(v102); v101[9] = v104; cocos2d::CCArray::addObjectsFromArray(v104, v103); cocos2d::CCObject::retain(v101[9]); } *((_DWORD *)v101 + 16) = 3; cocos2d::CCObject::autorelease((cocos2d::CCObject *)v101); v105 = *(_QWORD *)(v8 + 1512); cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(v105 + 14920)); if ( !*(_BYTE *)(v105 + 14663) ) v86 = 200; if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v105 + 14912)) >= v86 ) cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v105 + 14912), 0, 1); cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v105 + 14912), (struct cocos2d::CCObject *)v101); EditorUI::updateButtons(v8); EditorUI::updateSpecialUIElements(v8); } } } }