// // EditorUI::addObjectsToSmartTemplate from 0x6b3ba0 to 0x6b4a40 (3744 bytes) // // 2 xrefs: // > SetupSmartBlockLayer::onCreateTemplate @ 0x9dc094 // > @ 0x97680 // // 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 EditorUI::addObjectsToSmartTemplate(EditorUI *a1, GJSmartTemplate *a2, cocos2d::CCArray *a3) { unsigned int v5; // w19 __int64 v6; // x0 cocos2d::CCObject *v7; // x1 SmartGameObject *v8; // x24 SmartBlockType v9; // w0 __int64 v10; // x0 long double v11; // q1 long double v12; // q0 int v13; // w21 cocos2d::CCArray *v14; // x28 const cocos2d::CCPoint *v15; // x1 SmartGameObject *v16; // x23 SmartGameObject *v17; // x22 cocos2d::CCArray *v18; // x0 int m_linkedGroup; // w1 cocos2d::CCArray *StickyGroup; // x23 unsigned int v21; // w21 cocos2d::CCObject *v22; // x22 unsigned int v23; // w22 cocos2d::CCObject *v24; // x21 const cocos2d::CCPoint *v25; // x0 float v26; // s9 int v27; // w1 int m_objectID; // w21 GameObject *Object; // x21 void (__fastcall *setRotation)(GameObject *__hidden, float); // x22 void (__fastcall *setFlipX)(GameObject *__hidden, bool); // x22 int v32; // w0 void (__fastcall *setFlipY)(GameObject *__hidden, bool); // x22 int v34; // w0 cocos2d::ccArray *data; // x1 void *v36; // x0 void *v37; // x0 void *v38; // x0 unsigned int *v39; // x1 int v40; // w2 void *v41; // x0 unsigned int *v42; // x1 int v43; // w2 __int64 v44; // x22 float v45; // s0 float v46; // s1 int m_nTag; // w2 cocos2d::CCPoint origin; // x22 unsigned int *v49; // x0 int v50; // w1 unsigned int *v51; // x1 int v52; // w2 unsigned int *v53; // x1 int v54; // w2 int v55; // [xsp+8Ch] [xbp+7Ch] int v57; // [xsp+98h] [xbp+88h] int v58; // [xsp+9Ch] [xbp+8Ch] int v59; // [xsp+B8h] [xbp+A8h] int v60; // [xsp+BCh] [xbp+ACh] int v61; // [xsp+D0h] [xbp+C0h] int v62; // [xsp+D4h] [xbp+C4h] cocos2d::CCDictionary *v63; // [xsp+D8h] [xbp+C8h] int v64; // [xsp+E0h] [xbp+D0h] unsigned int v65; // [xsp+E4h] [xbp+D4h] cocos2d::CCDictionary *v66; // [xsp+E8h] [xbp+D8h] int v67; // [xsp+F0h] [xbp+E0h] int v68; // [xsp+F4h] [xbp+E4h] int v69; // [xsp+F8h] [xbp+E8h] int v70; // [xsp+FCh] [xbp+ECh] int v71; // [xsp+100h] [xbp+F0h] int v72; // [xsp+104h] [xbp+F4h] LevelEditorLayer *m_editorLayer; // [xsp+118h] [xbp+108h] SmartGameObject *v74; // [xsp+120h] [xbp+110h] SmartGameObject *v75; // [xsp+128h] [xbp+118h] SmartGameObject *v76; // [xsp+130h] [xbp+120h] SmartGameObject *v77; // [xsp+138h] [xbp+128h] SmartGameObject *v78; // [xsp+140h] [xbp+130h] SmartGameObject *SmartNeighbor; // [xsp+148h] [xbp+138h] int v80; // [xsp+150h] [xbp+140h] int v81; // [xsp+158h] [xbp+148h] int v82; // [xsp+160h] [xbp+150h] int v83; // [xsp+168h] [xbp+158h] cocos2d::CCObject *v84; // [xsp+168h] [xbp+158h] float v85; // [xsp+180h] [xbp+170h] BYREF float v86; // [xsp+184h] [xbp+174h] cocos2d::CCPoint v87; // [xsp+188h] [xbp+178h] BYREF cocos2d::CCPoint v88; // [xsp+190h] [xbp+180h] BYREF __int64 v89; // [xsp+198h] [xbp+188h] BYREF __int64 v90; // [xsp+1A0h] [xbp+190h] BYREF _BYTE v91[8]; // [xsp+1A8h] [xbp+198h] BYREF cocos2d::CCPoint v92; // [xsp+1B0h] [xbp+1A0h] BYREF _BYTE v93[8]; // [xsp+1B8h] [xbp+1A8h] BYREF cocos2d::CCPoint v94; // [xsp+1C0h] [xbp+1B0h] BYREF _BYTE v95[8]; // [xsp+1C8h] [xbp+1B8h] BYREF cocos2d::CCPoint v96; // [xsp+1D0h] [xbp+1C0h] BYREF _BYTE v97[8]; // [xsp+1D8h] [xbp+1C8h] BYREF cocos2d::CCPoint v98; // [xsp+1E0h] [xbp+1D0h] BYREF _BYTE v99[8]; // [xsp+1E8h] [xbp+1D8h] BYREF cocos2d::CCPoint v100; // [xsp+1F0h] [xbp+1E0h] BYREF _BYTE v101[8]; // [xsp+1F8h] [xbp+1E8h] BYREF cocos2d::CCPoint v102; // [xsp+200h] [xbp+1F0h] BYREF _BYTE v103[8]; // [xsp+208h] [xbp+1F8h] BYREF cocos2d::CCPoint v104; // [xsp+210h] [xbp+200h] BYREF _BYTE v105[8]; // [xsp+218h] [xbp+208h] BYREF cocos2d::CCPoint v106; // [xsp+220h] [xbp+210h] BYREF cocos2d::CCRect v107; // [xsp+228h] [xbp+218h] BYREF cocos2d::CCRect v108; // [xsp+238h] [xbp+228h] BYREF cocos2d::CCPoint v109; // 0:kr00_8.8 cocos2d::CCPoint v110; // 0:s0.4,4:s1.4 cocos2d::CCPoint v111; // 0:s0.4,4:s1.4 cocos2d::CCPoint v112; // 0:s0.4,4:s1.4 cocos2d::CCPoint v113; // 0:s0.4,4:s1.4 cocos2d::CCPoint v114; // 0:s0.4,4:s1.4 cocos2d::CCPoint v115; // 0:s0.4,4:s1.4 cocos2d::CCPoint v116; // 0:s0.4,4:s1.4 cocos2d::CCPoint v117; // 0:s0.4,4:s1.4 cocos2d::CCPoint v118; // 0:s0.4,4:s1.4 cocos2d::CCPoint v119; // 0:s0.4,4:s1.4 cocos2d::CCPoint v120; // 0:s0.4,4:s1.4 cocos2d::CCRect v121; // 0:s0.4,4:s1.4,8:s2.4,12:s3.4 if ( !a2 ) return; v5 = 0; v66 = cocos2d::CCDictionary::create(); v63 = cocos2d::CCDictionary::create(); while ( v5 < (unsigned int)cocos2d::CCArray::count(a3) ) { while ( 1 ) { v6 = cocos2d::CCArray::objectAtIndex(a3, v5); v7 = (cocos2d::CCObject *)v6; if ( *(_DWORD *)(v6 + 1232) == 5 ) break; cocos2d::CCArray::removeObjectAtIndex(a3, v5, 1); if ( v5 >= (unsigned int)cocos2d::CCArray::count(a3) ) goto LABEL_6; } if ( (unsigned int)(*(_DWORD *)(v6 + 1012) - 2896) <= 1 ) { v84 = (cocos2d::CCObject *)v6; GameObject::determineSlopeDirection((GameObject *)v6); v7 = v84; } m_nTag = v7[15].m_nTag; if ( m_nTag > 0 ) cocos2d::CCDictionary::setObject(v63, v7, m_nTag); ++v5; } LABEL_6: v65 = 0; LABEL_8: if ( v65 < (unsigned int)cocos2d::CCArray::count(a3) ) { v8 = (SmartGameObject *)cocos2d::CCArray::objectAtIndex(a3, v65); if ( v8->m_referenceOnly ) goto LABEL_7; cocos2d::CCPoint::CCPoint(&v108.origin, (const cocos2d::CCPoint *)&dword_1242110); v9 = GJSmartTemplate::smartObjectToType(v8, v110); v109 = GJSmartTemplate::offsetForType(v9); v10 = ((__int64 (__fastcall *)(SmartGameObject *, float, float))v8->getPosition)(v8, v109.x, v109.y); cocos2d::CCPoint::operator+(&v87, v10, &v85); cocos2d::CCPoint::CCPoint(&v88); *(float *)&v11 = v85; LODWORD(v12) = dword_1242110; if ( v85 == *(float *)&dword_1242110 && (*(float *)&v11 = v86, LODWORD(v12) = dword_1242114, v86 == *(float *)&dword_1242114) ) { v67 = 0; v72 = 1; } else { v67 = 1; v72 = 2; v44 = ((__int64 (__fastcall *)(SmartGameObject *, long double, long double))v8->getPosition)(v8, v12, v11); cocos2d::CCPoint::operator-(&v107, &v85); cocos2d::CCPoint::operator+(&v108, v44, &v107); cocos2d::CCPoint::operator=(&v88, v45, v46); } v13 = 0; sub_D153B8((int)&v89, &byte_F288A0); v14 = nullptr; v15 = &v87; while ( 1 ) { cocos2d::CCPoint::CCPoint(&v106, v15); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); SmartNeighbor = EditorUI::getSmartNeighbor( a1, v8, v111, (GJSmartDirection)&v108, (cocos2d::CCArray *)((char *)&dword_0 + 1)); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v78 = EditorUI::getSmartNeighbor( a1, v8, v112, (GJSmartDirection)&v108, (cocos2d::CCArray *)((char *)&dword_0 + 2)); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v77 = EditorUI::getSmartNeighbor( a1, v8, v113, (GJSmartDirection)&v108, (cocos2d::CCArray *)((char *)&dword_0 + 3)); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v16 = EditorUI::getSmartNeighbor(a1, v8, v114, (GJSmartDirection)&v108, (cocos2d::CCArray *)&byte_4); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v17 = EditorUI::getSmartNeighbor(a1, v8, v115, (GJSmartDirection)&v108, (cocos2d::CCArray *)&byte_5); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v76 = EditorUI::getSmartNeighbor(a1, v8, v116, (GJSmartDirection)&v108, (cocos2d::CCArray *)&byte_6); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v75 = EditorUI::getSmartNeighbor(a1, v8, v117, (GJSmartDirection)&v108, (cocos2d::CCArray *)&byte_7); cocos2d::CCPoint::CCPoint(&v108.origin, &v106); v74 = EditorUI::getSmartNeighbor(a1, v8, v118, (GJSmartDirection)&v108, (cocos2d::CCArray *)byte_8); if ( SmartNeighbor ) v83 = !SmartNeighbor->m_referenceOnly; else v83 = 0; if ( v78 ) v81 = !v78->m_referenceOnly; else v81 = 0; if ( v77 ) v80 = !v77->m_referenceOnly; else v80 = 0; if ( v16 ) v82 = !v16->m_referenceOnly; else v82 = 0; if ( v17 ) v71 = !v17->m_referenceOnly; else v71 = 0; if ( v76 ) v69 = !v76->m_referenceOnly; else v69 = 0; if ( v75 ) v68 = !v75->m_referenceOnly; else v68 = 0; if ( v74 ) v70 = !v74->m_referenceOnly; else v70 = 0; cocos2d::CCRect::CCRect(&v107, v106.x - 14.0, v106.y - 14.0, 28.0, 28.0); if ( !v83 ) v107.size.height = v107.size.height + 14.0; if ( !v81 ) { v107.size.height = v107.size.height + 14.0; v107.origin.y = v107.origin.y - 14.0; } if ( !v80 ) { v107.size.width = v107.size.width + 14.0; v107.origin.x = v107.origin.x - 14.0; } if ( !v82 ) v107.size.width = v107.size.width + 14.0; m_editorLayer = a1->m_editorLayer; cocos2d::CCRect::CCRect(&v108, &v107); v18 = LevelEditorLayer::objectsInRect(m_editorLayer, v121, (bool)&v108); if ( v14 ) { if ( v18 ) cocos2d::CCArray::addObjectsFromArray(v14, v18); if ( v13 ) { LABEL_42: if ( ++v13 == v72 ) goto LABEL_50; goto LABEL_43; } } else { v14 = v18; if ( v13 ) goto LABEL_42; } cocos2d::CCPoint::CCPoint(&v108.origin, &v106); GJSmartTemplate::keyFromNeighbors( (GJSmartTemplate *)&v108, v119, v8, SmartNeighbor, v78, v77, v16, v17, v76, v75, v74); sub_D163D4(&v89, &v90); if ( (__int64 *)(v90 - 24) != &qword_124B6B0 ) sub_6865FC((void *)(v90 - 24)); ++v13; v55 = v70; v57 = v68; v58 = v69; v59 = v71; v60 = v82; v61 = v80; v62 = v81; v64 = v83; if ( v13 == v72 ) { LABEL_50: m_linkedGroup = v8->m_linkedGroup; if ( m_linkedGroup > 0 ) { StickyGroup = GJBaseGameLayer::getStickyGroup(a1->m_editorLayer, m_linkedGroup); v21 = 0; if ( StickyGroup ) { while ( v21 < (unsigned int)cocos2d::CCArray::count(StickyGroup) ) { v22 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(StickyGroup, v21); if ( !(unsigned __int8)cocos2d::CCArray::containsObject(v14, v22) ) cocos2d::CCArray::addObject(v14, v22); ++v21; } } } v23 = 0; if ( v14 ) { while ( 2 ) { while ( 2 ) { if ( v23 >= (unsigned int)cocos2d::CCArray::count(v14) ) { if ( (unsigned int)cocos2d::CCArray::count(v14) ) { m_objectID = v8->m_objectID; ((void (__fastcall *)(cocos2d::CCRect *__return_ptr, SmartGameObject *))v8->getRealPosition)( &v108, v8); Object = EditorUI::createObject(a1, m_objectID, v120); cocos2d::CCArray::addObject(v14, Object); setRotation = Object->setRotation; v8->getRotation(v8); ((void (__fastcall *)(GameObject *))setRotation)(Object); setFlipX = Object->setFlipX; v32 = ((__int64 (__fastcall *)(SmartGameObject *))v8->isFlipX)(v8); setFlipX(Object, v32); setFlipY = Object->setFlipY; v34 = ((__int64 (__fastcall *)(SmartGameObject *))v8->isFlipY)(v8); setFlipY(Object, v34); data = v14->data; Object->m_hasGroupParent = 1; qsort(data->arr, data->num, 8u, (int (*)(const void *, const void *))smartPrefabSort); EditorUI::copyObjectsDetailed(a1, v14, (__int64)&v106); Object->m_hasGroupParent = 0; EditorUI::deleteObject(a1, Object, 1); sub_D18D28(&v107, &v89); sub_D18D28(&v108, &v106); GJSmartTemplate::savePrefab(a2, (std::string)&v107, (std::string)&v108); v36 = (void *)(*(_QWORD *)&v108.origin - 24LL); if ( (__int64 *)(*(_QWORD *)&v108.origin - 24LL) != &qword_124B6B0 ) { if ( &pthread_create ) { v53 = (unsigned int *)(*(_QWORD *)&v108.origin - 8LL); do v54 = __ldaxr(v53); while ( __stlxr(v54 - 1, v53) ); } else { v54 = *(_DWORD *)(*(_QWORD *)&v108.origin - 8LL); *(_DWORD *)(*(_QWORD *)&v108.origin - 8LL) = v54 - 1; } if ( v54 <= 0 ) operator delete(v36); } v37 = (void *)(*(_QWORD *)&v107.origin - 24LL); if ( (__int64 *)(*(_QWORD *)&v107.origin - 24LL) != &qword_124B6B0 ) { if ( &pthread_create ) { v51 = (unsigned int *)(*(_QWORD *)&v107.origin - 8LL); do v52 = __ldaxr(v51); while ( __stlxr(v52 - 1, v51) ); } else { v52 = *(_DWORD *)(*(_QWORD *)&v107.origin - 8LL); *(_DWORD *)(*(_QWORD *)&v107.origin - 8LL) = v52 - 1; } if ( v52 <= 0 ) operator delete(v37); } v38 = (void *)(*(_QWORD *)&v106 - 24LL); if ( (__int64 *)(*(_QWORD *)&v106 - 24LL) != &qword_124B6B0 ) { if ( &pthread_create ) { v39 = (unsigned int *)(*(_QWORD *)&v106 - 8LL); do v40 = __ldaxr(v39); while ( __stlxr(v40 - 1, v39) ); } else { v40 = *(_DWORD *)(*(_QWORD *)&v106 - 8LL); *(_DWORD *)(*(_QWORD *)&v106 - 8LL) = v40 - 1; } if ( v40 <= 0 ) operator delete(v38); } } goto LABEL_101; } v24 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(v14, v23); if ( LODWORD(v24[22].__vftable) == 5 || cocos2d::CCDictionary::objectForKey(v66, HIDWORD(v24[16].__vftable)) ) { LABEL_66: cocos2d::CCArray::removeObjectAtIndex(v14, v23, 1); continue; } break; } v25 = (const cocos2d::CCPoint *)((__int64 (__fastcall *)(cocos2d::CCObject *))v24->__vftable[2].acceptVisitor)(v24); cocos2d::CCPoint::CCPoint(&v108.origin, v25); v26 = cocos2d::ccpDistance(&v87, &v108.origin); if ( v67 && v26 > cocos2d::ccpDistance(&v88, &v108.origin) ) v26 = cocos2d::ccpDistance(&v88, &v108.origin); v27 = v24[15].m_nTag; if ( v27 <= 0 ) { LABEL_75: if ( !v27 || v8->m_linkedGroup != v27 ) { if ( v64 ) { GJSmartTemplate::offsetForDir((GJSmartDirection)1, 0); cocos2d::CCPoint::operator+(&v92, &v87, v91); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v92) ) goto LABEL_66; } if ( v62 ) { GJSmartTemplate::offsetForDir((GJSmartDirection)2, 0); cocos2d::CCPoint::operator+(&v94, &v87, v93); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v94) ) goto LABEL_66; } if ( v61 ) { GJSmartTemplate::offsetForDir((GJSmartDirection)3, 0); cocos2d::CCPoint::operator+(&v96, &v87, v95); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v96) ) goto LABEL_66; } if ( v60 ) { GJSmartTemplate::offsetForDir((GJSmartDirection)4, 0); cocos2d::CCPoint::operator+(&v98, &v87, v97); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v98) ) goto LABEL_66; } if ( v59 ) { GJSmartTemplate::offsetForDir(TopLeft, 0); cocos2d::CCPoint::operator+(&v100, &v87, v99); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v100) ) goto LABEL_66; } if ( v58 ) { GJSmartTemplate::offsetForDir(TopRight, 0); cocos2d::CCPoint::operator+(&v102, &v87, v101); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v102) ) goto LABEL_66; } if ( v57 ) { GJSmartTemplate::offsetForDir(BottomLeft, 0); cocos2d::CCPoint::operator+(&v104, &v87, v103); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v104) ) goto LABEL_66; } if ( v55 ) { GJSmartTemplate::offsetForDir(BottomRight, 0); cocos2d::CCPoint::operator+(&v106, &v87, v105); if ( v26 > cocos2d::ccpDistance(&v108.origin, &v106) ) goto LABEL_66; } } } else if ( v27 != v8->m_linkedGroup ) { if ( cocos2d::CCDictionary::objectForKey(v63, v27) ) goto LABEL_66; v27 = v24[15].m_nTag; goto LABEL_75; } cocos2d::CCDictionary::setObject(v66, v24, HIDWORD(v24[16].__vftable)); ++v23; continue; } } LABEL_101: v41 = (void *)(v89 - 24); if ( (__int64 *)(v89 - 24) != &qword_124B6B0 ) { if ( &pthread_create ) { v42 = (unsigned int *)(v89 - 8); do v43 = __ldaxr(v42); while ( __stlxr(v43 - 1, v42) ); } else { v43 = *(_DWORD *)(v89 - 8); *(_DWORD *)(v89 - 8) = v43 - 1; } if ( v43 <= 0 ) operator delete(v41); } LABEL_7: ++v65; goto LABEL_8; } LABEL_43: v15 = &v88; if ( !v13 ) v15 = &v87; } } GJSmartTemplate::logTemplateStatus((__int64 *)&v108, a2, 1); origin = v108.origin; if ( (__int64 *)(*(_QWORD *)&v108.origin - 24LL) != &qword_124B6B0 ) { v49 = (unsigned int *)(*(_QWORD *)&v108.origin - 8LL); if ( &pthread_create ) { do v50 = __ldaxr(v49); while ( __stlxr(v50 - 1, v49) ); } else { v50 = *(_DWORD *)(*(_QWORD *)&v108.origin - 8LL); *(_DWORD *)(*(_QWORD *)&v108.origin - 8LL) = v50 - 1; } if ( v50 <= 0 ) operator delete((void *)(*(_QWORD *)&origin - 24LL)); } }
GD Web Decomp Icon

GD Web Decomp

Raw Source