//
// EditorUI::findObject from 0x1005b96d0 to 0x1005b9b5b (1163 bytes)
//
// 5 xrefs:
// > EditorUI::handleEditorAction @ 0x10060be14
// > sub_100906580 @ 0x1009065bd
// > sub_1009065D0 @ 0x100906633
// > sub_100906690 @ 0x1009066d8
// > FindObjectPopup::onFieldEnter @ 0x10090688d
//
// 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 12:32:43 +0000
//
void __fastcall EditorUI::findObject(__int64 a1, int a2, int a3, unsigned int a4, double a5)
{
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rdi
__int64 GameObject; // rax
__int64 v11; // rbx
char *v12; // r14
__int64 *v13; // r13
__int64 v14; // rdi
void *v15; // rdi
__int64 Group; // rax
unsigned int *v17; // rax
__int64 *v18; // r12
__int64 *v19; // rbx
unsigned __int64 v20; // r15
__int64 v21; // r13
unsigned __int64 v22; // rdx
signed __int64 v23; // rbx
__int64 v24; // r15
unsigned __int64 v25; // rax
__int64 v26; // rdx
unsigned __int64 v27; // r14
char *v28; // rcx
char *v29; // r15
unsigned __int64 v30; // rax
__int64 v31; // rax
__int64 v32; // rdx
unsigned __int64 v33; // r13
__int64 v34; // rax
int v35; // edx
__int64 v36; // r12
__int64 v37; // rbx
__int64 v38; // r15
int v39; // r14d
__int64 MainObject; // rax
__int64 v41; // rcx
char *v42; // rdx
int *v43; // rbx
int v44; // eax
_QWORD *v45; // r15
__int64 v46; // rcx
_QWORD *v47; // rbx
__int64 v48; // [rsp+8h] [rbp-88h] BYREF
__int64 v49; // [rsp+10h] [rbp-80h] BYREF
unsigned __int64 v50; // [rsp+18h] [rbp-78h]
char v51; // [rsp+20h] [rbp-70h] BYREF
_BYTE v52[23]; // [rsp+21h] [rbp-6Fh] BYREF
char *v53; // [rsp+38h] [rbp-58h]
int v54; // [rsp+40h] [rbp-50h]
int v55; // [rsp+44h] [rbp-4Ch]
__int64 v56; // [rsp+48h] [rbp-48h]
unsigned int v57; // [rsp+54h] [rbp-3Ch]
void *__src; // [rsp+58h] [rbp-38h]
char GameVariable; // [rsp+67h] [rbp-29h]
v7 = GameManager::sharedState();
GameManager::setIntGameVariable(v7, "0230");
v8 = GameManager::sharedState();
GameVariable = GameManager::getGameVariable(v8, "0231");
v56 = a1;
if ( a3 )
{
v57 = a4;
v9 = *(_QWORD *)(a1 + 1440);
GameObject = LevelEditorLayer::findGameObject(v9, a2);
if ( GameObject )
{
v11 = GameObject;
if ( !GameVariable || sub_1005B9640(a5, v9, GameObject) )
{
v54 = a3;
v55 = a2;
v12 = (char *)operator new(8u);
*(_QWORD *)v12 = v11;
v13 = (__int64 *)(v12 + 8);
v14 = v57;
goto LABEL_35;
}
}
goto LABEL_29;
}
if ( a2 <= 0 )
{
LABEL_29:
v12 = nullptr;
goto LABEL_43;
}
v15 = *(void **)(a1 + 1440);
Group = GJBaseGameLayer::getGroup((__int64)v15, a2);
v55 = a2;
v54 = 0;
v57 = a4;
if ( !Group || (v17 = *(unsigned int **)(Group + 56), !*v17) )
{
v13 = nullptr;
v12 = nullptr;
goto LABEL_32;
}
v18 = *((__int64 **)v17 + 2);
v50 = (unsigned __int64)&v18[*v17 - 1];
v12 = nullptr;
v19 = nullptr;
v20 = 0;
while ( 1 )
{
v21 = *v18;
if ( !*v18 )
break;
if ( GameVariable )
{
__src = v12;
if ( !sub_1005B9640(a5, (__int64)v15, v21) )
goto LABEL_11;
}
if ( (unsigned __int64)v19 < v20 )
{
*v19++ = v21;
LABEL_11:
v13 = v19;
if ( (unsigned __int64)++v18 > v50 )
goto LABEL_32;
}
else
{
v22 = v20;
v23 = (char *)v19 - v12;
v24 = v23 >> 3;
v25 = (v23 >> 3) + 1;
__src = v12;
if ( v25 > 0x1FFFFFFFFFFFFFFFLL )
sub_1000991E0();
v26 = v22 - (_QWORD)v12;
v27 = v26 >> 2;
if ( v26 >> 2 <= v25 )
v27 = (v23 >> 3) + 1;
if ( (unsigned __int64)v26 >= 0x7FFFFFFFFFFFFFF8LL )
v27 = 0x1FFFFFFFFFFFFFFFLL;
if ( v27 )
{
if ( v27 > 0x1FFFFFFFFFFFFFFFLL )
sub_10001ADB0();
v28 = (char *)operator new(8 * v27);
}
else
{
v28 = nullptr;
}
v53 = &v28[8 * v27];
*(_QWORD *)&v28[8 * v24] = v21;
v13 = (__int64 *)&v28[8 * v24 + 8];
v29 = v28;
v15 = v28;
memcpy(v28, __src, v23);
if ( __src )
{
v15 = __src;
operator delete(__src);
}
v12 = v29;
v20 = (unsigned __int64)v53;
++v18;
v19 = v13;
if ( (unsigned __int64)v18 > v50 )
goto LABEL_32;
}
}
v13 = v19;
LABEL_32:
_BitScanReverse64(&v30, ((char *)v13 - v12) >> 3);
v31 = (2 * ((unsigned int)v30 ^ 0x3F)) ^ 0x7ELL;
v32 = 0;
if ( v13 != (__int64 *)v12 )
v32 = v31;
sub_1005B9E30(v12, v13, v32, 1);
v14 = v57;
if ( v13 == (__int64 *)v12 )
{
LABEL_43:
v51 = 18;
strcpy(v52, "No Match.");
EditorUI::showTextAlert(v56, &v51, 0, 1, 0);
if ( (v51 & 1) != 0 )
operator delete(*(void **)&v52[15]);
if ( v12 )
goto LABEL_65;
return;
}
LABEL_35:
if ( (_DWORD)v14 )
{
v33 = (unsigned __int64)((char *)v13 - v12) >> 3;
if ( (int)v33 <= 0 )
{
LABEL_40:
v35 = 0;
if ( (int)v14 <= 0 )
v35 = v33 - 1;
}
else
{
v34 = 0;
while ( *(_DWORD *)(*(_QWORD *)&v12[8 * v34] + 916LL) != *(_DWORD *)(v56 + 1432) )
{
if ( (v33 & 0x7FFFFFFF) == ++v34 )
goto LABEL_40;
}
v35 = ((int)v33 + (int)v14 + (int)v34) % (int)v33;
}
v43 = *(int **)&v12[8 * v35];
v44 = v43[229];
v45 = (_QWORD *)v56;
*(_DWORD *)(v56 + 1432) = v44;
v46 = v45[187];
if ( !v46 || *(_DWORD *)(v46 + 916) != v44 )
EditorUI::createUndoSelectObject((__int64)v45, 0);
EditorUI::selectObject((__int64)v45, v43, 0);
EditorUI::updateButtons((__int64)v45);
EditorUI::updateSpecialUIElements(v45);
sub_1000103E0((__int64)v45, (__int64)v43);
goto LABEL_65;
}
__src = v12;
v36 = sub_1007FE900(v14);
v37 = (char *)v13 - v12;
if ( v13 != (__int64 *)v12 )
{
v38 = 0;
do
sub_1007FEBF0(v36, *((_QWORD *)__src + v38++));
while ( (v37 >> 3 == 0) + (v37 >> 3) != v38 );
}
v39 = 0;
if ( !(_BYTE)v54 )
{
MainObject = GJBaseGameLayer::tryGetMainObject(*(_QWORD **)(v56 + 1440), v55);
if ( MainObject )
{
v41 = 0;
while ( *(_QWORD *)((char *)__src + v41) != MainObject )
{
v42 = (char *)__src + v41 + 8;
v41 += 8;
if ( v42 == (char *)v13 )
{
v41 = v37;
break;
}
}
if ( (char *)__src + v41 == (char *)v13 )
v39 = 0;
else
v39 = *(_DWORD *)(MainObject + 916);
}
}
v47 = (_QWORD *)v56;
*(_DWORD *)(v56 + 1432) = v39;
EditorUI::getGroupCenter(&v48, v47, v36, 0);
EditorUI::processSelectObjects(v47, v36, a5);
sub_1002782D0(&v49, &v48);
EditorUI::centerCameraOnObject((__int64)v47, (float *)&v49);
v12 = (char *)__src;
if ( __src )
LABEL_65:
operator delete(v12);
}