//
// EditorUI::convertKeyBasedOnNeighbors from 0x9cb838 to 0x9cbd8c (1364 bytes)
//
// 3 xrefs:
// > EditorUI::processSmartObjectsFromType @ 0x68a3e8
// > EditorUI::processSmartObjectsFromType @ 0x68a52c
// > ??> @ 0x5ea70
//
// 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 EditorUI::convertKeyBasedOnNeighbors(EditorUI *a1, int a2, int a3, cocos2d::CCPoint a4, cocos2d::CCArray *a5)
{
int v8; // w20
unsigned int v9; // w26
unsigned int v10; // w27
bool v11; // zf
cocos2d::CCArray *v12; // x1
unsigned int v13; // w25
unsigned int v14; // w19
int result; // w0
unsigned int v16; // w1
unsigned int v17; // w1
cocos2d::CCPoint v18; // [xsp+60h] [xbp+60h] BYREF
cocos2d::CCPoint v19; // 0:s0.4,4:s1.4
cocos2d::CCPoint v20; // 0:s0.4,4:s1.4
cocos2d::CCPoint v21; // 0:s0.4,4:s1.4
cocos2d::CCPoint v22; // 0:s0.4,4:s1.4
v8 = EditorUI::convertToBaseKey(a1, a2);
cocos2d::CCPoint::CCPoint(&v18, (const cocos2d::CCPoint *)a5);
v9 = EditorUI::getNeighbor(a1, a3, v19, (GJSmartDirection)&v18, (cocos2d::CCArray *)((char *)&dword_0 + 1)) != nullptr;
cocos2d::CCPoint::CCPoint(&v18, (const cocos2d::CCPoint *)a5);
v10 = EditorUI::getNeighbor(a1, a3, v20, (GJSmartDirection)&v18, (cocos2d::CCArray *)((char *)&dword_0 + 2)) != nullptr;
cocos2d::CCPoint::CCPoint(&v18, (const cocos2d::CCPoint *)a5);
v11 = EditorUI::getNeighbor(a1, a3, v21, (GJSmartDirection)&v18, (cocos2d::CCArray *)((char *)&dword_0 + 3)) == nullptr;
v12 = a5;
v13 = !v11;
cocos2d::CCPoint::CCPoint(&v18, (const cocos2d::CCPoint *)v12);
v14 = EditorUI::getNeighbor(a1, a3, v22, (GJSmartDirection)&v18, (cocos2d::CCArray *)&byte_4) != nullptr;
if ( v8 == 2838 )
{
if ( !v9 || !v10 || !v13 || (result = 2838, !v14) )
{
result = 2842;
if ( v13 >= (v9 ^ 1) )
{
if ( v13 < (v10 ^ 1) )
return 2846;
else
return 2838;
}
}
return result;
}
if ( v8 > 2838 )
{
if ( v8 == 2840 )
{
if ( !v9 || !v10 || !v13 || (result = 2840, !v14) )
{
result = 2844;
if ( v13 >= (v9 ^ 1) )
{
if ( v13 < (v10 ^ 1) )
return 2848;
else
return 2840;
}
}
}
else
{
if ( v8 >= 2840 )
{
if ( v8 == 2841 )
{
if ( !v9 || !v10 || !v13 || (result = 2841, !v14) )
{
result = 2845;
if ( v14 >= (v9 ^ 1) )
{
if ( v14 < (v10 ^ 1) )
return 2849;
else
return 2841;
}
}
return result;
}
return v8;
}
if ( !v9 || !v10 || !v13 || (result = 2839, !v14) )
{
result = 2843;
if ( v14 >= (v9 ^ 1) )
{
if ( v14 < (v10 ^ 1) )
return 2847;
else
return 2839;
}
}
}
return result;
}
if ( v8 != 2703 )
{
if ( v8 != 2704 )
{
if ( v8 != 869 )
return v8;
qword_1243DC8 = 214013 * qword_1243DC8 + 2531011;
if ( v10 && v9 )
{
if ( v14 )
{
result = 869;
if ( v13 )
return result;
goto LABEL_44;
}
}
else if ( v9 < (v10 ^ 1) && v13 < (v14 ^ 1) )
{
if ( (float)((float)(((unsigned __int64)qword_1243DC8 >> 16) & 0x7FFF) / 32767.0) <= 0.5 )
return 868;
else
return 867;
}
if ( v13 )
{
if ( v14 )
{
if ( (float)((float)(((unsigned __int64)qword_1243DC8 >> 16) & 0x7FFF) / 32767.0) <= 0.5 )
return 870;
else
return 869;
}
else if ( (float)((float)(((unsigned __int64)qword_1243DC8 >> 16) & 0x7FFF) / 32767.0) <= 0.5 )
{
return 1267;
}
else
{
return 872;
}
}
LABEL_44:
if ( (float)((float)(((unsigned __int64)qword_1243DC8 >> 16) & 0x7FFF) / 32767.0) <= 0.5 )
return 1266;
else
return 871;
}
if ( v9 >= v10 )
{
if ( v9 > v10 && v13 )
{
result = 2824;
if ( v14 )
return result;
if ( !v10 )
goto LABEL_103;
goto LABEL_26;
}
}
else if ( v14 )
{
result = 2823;
if ( v13 )
return result;
}
if ( !v10 )
goto LABEL_103;
LABEL_26:
if ( v9 )
{
result = 2825;
if ( v13 >= v14 )
{
result = 2826;
if ( v13 <= v14 )
{
if ( v13 < (v14 ^ 1) )
return 2827;
else
return 2704;
}
}
return result;
}
LABEL_103:
v17 = v10 ^ 1;
if ( v9 < (v10 ^ 1) )
{
if ( v13 )
{
result = 2828;
if ( v14 )
return result;
}
}
if ( v9 < v10 )
{
result = 2829;
if ( v13 < v14 )
return result;
result = 2830;
if ( v13 > v14 )
return result;
result = 2833;
if ( v13 < (v14 ^ 1) )
return result;
}
else if ( v9 > v10 )
{
result = 2831;
if ( v13 < v14 )
return result;
result = 2832;
if ( v13 > v14 )
return result;
result = 2834;
if ( v13 < (v14 ^ 1) )
return result;
result = 2704;
if ( v9 >= v17 )
return result;
LABEL_112:
result = 2836;
if ( v13 <= v14 )
{
if ( v13 < (v14 ^ 1) )
return 2837;
else
return 2704;
}
return result;
}
result = 2704;
if ( v9 >= v17 )
return result;
result = 2835;
if ( v13 < v14 )
return result;
goto LABEL_112;
}
if ( v9 < v10 )
{
if ( v14 )
{
result = 2808;
if ( v13 )
return result;
}
LABEL_65:
if ( v10 )
goto LABEL_66;
goto LABEL_93;
}
if ( v9 <= v10 || !v13 )
goto LABEL_65;
result = 2809;
if ( v14 )
return result;
if ( v10 )
{
LABEL_66:
if ( v9 )
{
result = 2810;
if ( v13 >= v14 )
{
result = 2811;
if ( v13 <= v14 )
{
if ( v13 >= (v14 ^ 1) )
return 2703;
else
return 2812;
}
}
return result;
}
}
LABEL_93:
v16 = v10 ^ 1;
if ( v9 < (v10 ^ 1) )
{
if ( v13 )
{
result = 2813;
if ( v14 )
return result;
}
}
if ( v9 < v10 )
{
result = 2814;
if ( v13 < v14 )
return result;
result = 2815;
if ( v13 > v14 )
return result;
result = 2818;
if ( v13 < (v14 ^ 1) )
return result;
}
else if ( v9 > v10 )
{
result = 2816;
if ( v13 >= v14 )
{
result = 2817;
if ( v13 <= v14 )
{
result = 2819;
if ( v13 >= (v14 ^ 1) )
{
if ( v9 < v16 )
{
if ( v13 <= v14 )
return 2703;
else
return 2821;
}
else
{
return 2703;
}
}
}
}
return result;
}
result = 2703;
if ( v9 < v16 )
{
result = 2820;
if ( v13 >= v14 )
{
result = 2821;
if ( v13 <= v14 )
{
if ( v13 >= (v14 ^ 1) )
return 2703;
else
return 2822;
}
}
}
return result;
}