//
// EditorUI::convertKeyBasedOnNeighbors from 0x100613a10 to 0x1006140f5 (1765 bytes)
//
// 2 xrefs:
// > EditorUI::processSmartObjectsFromType @ 0x10004436f
// > EditorUI::processSmartObjectsFromType @ 0x1000444b2
//
// 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
//
int __fastcall EditorUI::convertKeyBasedOnNeighbors(
EditorUI *a1,
int a2,
int a3,
cocos2d::CCPoint a4,
cocos2d::CCArray *a5)
{
int v7; // r12d
cocos2d::CCPoint v8; // xmm0_8
cocos2d::CCPoint v9; // xmm0_8
cocos2d::CCPoint v10; // xmm0_8
cocos2d::CCPoint v11; // xmm0_8
cocos2d::CCNode *v12; // rax
__int64 v13; // rdi
unsigned __int64 v14; // r8
int v15; // ecx
bool v16; // si
bool v17; // r10
bool v18; // di
bool v19; // r11
bool v20; // r8
bool v21; // r15
bool v22; // dl
bool v23; // bl
bool v24; // si
bool v25; // di
bool v26; // dl
unsigned int v27; // edx
float v28; // xmm0_4
unsigned __int64 v29; // r8
bool v30; // di
bool v31; // r11
bool v32; // r8
bool v33; // bl
bool v34; // r9
bool v35; // si
bool v36; // r14
bool v37; // si
bool v38; // dl
bool v39; // r14
bool v40; // di
bool v41; // r8
bool v42; // dl
bool v43; // cc
int v44; // eax
unsigned __int64 Neighbor; // [rsp+0h] [rbp-50h]
__int64 v47; // [rsp+Ch] [rbp-44h] BYREF
int v48; // [rsp+14h] [rbp-3Ch]
__int128 v49; // [rsp+18h] [rbp-38h]
v7 = EditorUI::convertToBaseKey(a1, a2);
v48 = v7;
*(double *)&v8 = sub_10028CC60(&v47, (double *)a5);
*(_QWORD *)&v49 = EditorUI::getNeighbor(a1, a3, v8, (GJSmartDirection)&v47, (cocos2d::CCArray *)1);
*(double *)&v9 = sub_10028CC60(&v47, (double *)a5);
Neighbor = (unsigned __int64)EditorUI::getNeighbor(a1, a3, v9, (GJSmartDirection)&v47, (cocos2d::CCArray *)2);
*(double *)&v10 = sub_10028CC60(&v47, (double *)a5);
*((_QWORD *)&v49 + 1) = EditorUI::getNeighbor(a1, a3, v10, (GJSmartDirection)&v47, (cocos2d::CCArray *)3);
*(double *)&v11 = sub_10028CC60(&v47, (double *)a5);
v12 = EditorUI::getNeighbor(a1, a3, v11, (GJSmartDirection)&v47, (cocos2d::CCArray *)4);
if ( v7 > 2837 )
{
switch ( v7 )
{
case 2838:
v13 = *((_QWORD *)&v49 + 1);
v14 = Neighbor;
v15 = 2838;
if ( Neighbor != 0 && (_QWORD)v49 != 0 && v12 != nullptr && *((_QWORD *)&v49 + 1) != 0 )
return v15;
v15 = 2842;
if ( v49 == 0 )
return v15;
v15 = 2846;
goto LABEL_31;
case 2839:
v29 = Neighbor;
v15 = 2839;
if ( Neighbor != 0 && (_QWORD)v49 != 0 && v12 != nullptr && *((_QWORD *)&v49 + 1) != 0 )
return v15;
v15 = 2843;
if ( !((unsigned __int64)v12 | (unsigned __int64)v49) )
return v15;
v15 = 2847;
goto LABEL_39;
case 2840:
v13 = *((_QWORD *)&v49 + 1);
v14 = Neighbor;
v15 = 2840;
if ( Neighbor != 0 && (_QWORD)v49 != 0 && v12 != nullptr && *((_QWORD *)&v49 + 1) != 0 )
return v15;
v15 = 2844;
if ( v49 == 0 )
return v15;
v15 = 2848;
LABEL_31:
if ( !(v14 | v13) )
return v15;
return v48;
case 2841:
v29 = Neighbor;
v15 = 2841;
if ( Neighbor != 0 && (_QWORD)v49 != 0 && v12 != nullptr && *((_QWORD *)&v49 + 1) != 0 )
return v15;
v15 = 2845;
if ( !((unsigned __int64)v12 | (unsigned __int64)v49) )
return v15;
v15 = 2849;
LABEL_39:
if ( v29 | (unsigned __int64)v12 )
return v48;
return v15;
default:
return v48;
}
}
if ( v7 == 869 )
{
v27 = 214013 * qword_1009A35A0 + 2531011;
qword_1009A35A0 = 214013 * qword_1009A35A0 + 2531011;
v15 = 869;
if ( Neighbor == 0 || (_QWORD)v49 == 0 || v12 == nullptr || *((_QWORD *)&v49 + 1) == 0 )
{
v28 = (float)(HIWORD(v27) & 0x7FFF) / 32767.0;
if ( (unsigned __int64)v12 | *((_QWORD *)&v49 + 1) | Neighbor | (unsigned __int64)v49 )
{
if ( *((_QWORD *)&v49 + 1) )
{
if ( v12 )
return (v28 <= 0.5) + 869;
v43 = v28 <= 0.5;
v44 = 872;
v15 = 1267;
}
else
{
v43 = v28 <= 0.5;
v44 = 871;
v15 = 1266;
}
if ( !v43 )
return v44;
}
else
{
return (v28 <= 0.5) + 867;
}
}
}
else
{
if ( v7 != 2703 )
{
if ( v7 == 2704 )
{
v16 = (_QWORD)v49 != 0 || Neighbor == 0;
v17 = v16 || *((_QWORD *)&v49 + 1) == 0;
v15 = 2823;
if ( !v17 && v12 != nullptr )
return v15;
v18 = Neighbor != 0 || (_QWORD)v49 == 0;
v19 = v18 || *((_QWORD *)&v49 + 1) == 0;
v15 = 2824;
if ( !v19 && v12 != nullptr )
return v15;
v20 = *((_QWORD *)&v49 + 1) != 0;
v21 = Neighbor == 0 || (_QWORD)v49 == 0;
v15 = 2825;
if ( *((_QWORD *)&v49 + 1) == 0 && !v21 && v12 != nullptr )
return v15;
v15 = 2826;
if ( v12 == nullptr && *((_QWORD *)&v49 + 1) != 0 && !v21 )
return v15;
v15 = 2827;
if ( v12 == nullptr && *((_QWORD *)&v49 + 1) == 0 && Neighbor != 0 && (_QWORD)v49 != 0 )
return v15;
v22 = Neighbor != 0 || (_QWORD)v49 != 0;
v23 = v22 || *((_QWORD *)&v49 + 1) == 0;
v15 = 2828;
if ( !v23 && v12 != nullptr )
return v15;
v24 = v20 || v16;
v15 = 2829;
if ( !v24 && v12 != nullptr )
return v15;
v15 = 2830;
if ( v12 == nullptr && !v17 )
return v15;
v25 = v20 || v18;
v15 = 2831;
if ( !v25 && v12 != nullptr )
return v15;
v15 = 2832;
if ( v12 == nullptr && !v19 )
return v15;
v15 = 2833;
if ( v12 == nullptr && !v24 )
return v15;
v15 = 2834;
if ( v12 == nullptr && !v25 )
return v15;
v26 = v20 || v22;
v15 = 2835;
if ( !v26 && v12 != nullptr )
return v15;
v15 = 2836;
if ( v12 == nullptr && !v23 )
return v15;
v15 = 2837;
if ( v12 == nullptr && !v26 )
return v15;
}
return v48;
}
v30 = (_QWORD)v49 != 0 || Neighbor == 0;
v31 = v30 || *((_QWORD *)&v49 + 1) == 0;
v15 = 2808;
if ( v31 || v12 == nullptr )
{
v32 = Neighbor != 0 || (_QWORD)v49 == 0;
v33 = v32 || *((_QWORD *)&v49 + 1) == 0;
v15 = 2809;
if ( v33 || v12 == nullptr )
{
v34 = *((_QWORD *)&v49 + 1) != 0;
v35 = Neighbor == 0 || (_QWORD)v49 == 0;
v36 = *((_QWORD *)&v49 + 1) != 0 || v35;
v15 = 2810;
if ( v36 || v12 == nullptr )
{
v37 = *((_QWORD *)&v49 + 1) == 0 || v35;
v15 = 2811;
if ( v12 != nullptr || v37 )
{
v15 = 2812;
if ( v12 != nullptr || v36 )
{
v38 = Neighbor != 0 || (_QWORD)v49 != 0;
v39 = v38 || *((_QWORD *)&v49 + 1) == 0;
v15 = 2813;
if ( v39 || v12 == nullptr )
{
v40 = v34 || v30;
v15 = 2814;
if ( v40 || v12 == nullptr )
{
v15 = 2815;
if ( v12 != nullptr || v31 )
{
v41 = v34 || v32;
v15 = 2816;
if ( v41 || v12 == nullptr )
{
v15 = 2817;
if ( v12 != nullptr || v33 )
{
v15 = 2818;
if ( v12 != nullptr || v40 )
{
v15 = 2819;
if ( v12 != nullptr || v41 )
{
v42 = v34 || v38;
v15 = 2820;
if ( v42 || v12 == nullptr )
{
v15 = 2821;
if ( v12 != nullptr || v39 )
{
v15 = 2822;
if ( v12 != nullptr || v42 )
{
v15 = 2703;
if ( v12 == nullptr || v37 )
return v48;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return v15;
}