//
// EditorUI::findObject from 0x1401c8dd0 to 0x1401c9567 (1943 bytes)
//
// 3 xrefs:
// > FindObjectPopup::runFind @ 0x140180a71
// > EditorUI::handleEditorAction @ 0x1401c3a9b
// > ??> @ 0x14091a870
//
// 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:28:06 +0000
//
// Hidden C++ exception states: #wind=4
void __fastcall EditorUI::findObject(__int64 a1, int a2, unsigned __int8 a3, int a4)
{
__int64 v6; // r15
__int64 v7; // rbx
__int64 v8; // rbx
struct cocos2d::CCString *v9; // rax
void *v10; // rcx
__int64 v11; // rcx
__int64 *v12; // rcx
char GameVariable; // si
__int64 v14; // r8
__int64 v15; // rax
__int64 *i; // r8
__int64 v17; // rdi
_QWORD *v18; // rbx
__int64 Group; // rax
void *v20; // rcx
unsigned int *v21; // r15
__int64 v22; // rax
__int64 *v23; // r15
__int64 *v24; // rax
__int64 *v25; // rbx
__int64 v26; // r14
bool v27; // zf
__int64 v28; // rdi
unsigned __int64 v29; // r8
unsigned __int64 v30; // rdx
unsigned __int64 v31; // rcx
__int64 v32; // r13
_QWORD *v33; // rsi
__int64 *v34; // rdx
_QWORD *v35; // rcx
size_t v36; // r8
cocos2d::CCArray *v37; // rdi
unsigned __int64 v38; // rbx
struct cocos2d::CCObject **v39; // rdx
__int64 v40; // rcx
__int64 MainObject; // rax
__int64 v42; // rsi
int v43; // eax
const struct cocos2d::CCPoint *v44; // rdx
cocos2d::CCPoint *v45; // rcx
__int64 v46; // r8
int v47; // edx
__int64 v48; // rcx
int v49; // edx
int *v50; // rbx
__int64 v51; // rcx
float *v52; // rax
void *v53; // rcx
void *Src[2]; // [rsp+38h] [rbp-41h]
__int64 *v56; // [rsp+48h] [rbp-31h]
char v57; // [rsp+50h] [rbp-29h]
__int64 *v58; // [rsp+58h] [rbp-21h] BYREF
__int64 v59; // [rsp+60h] [rbp-19h] BYREF
int v60; // [rsp+68h] [rbp-11h]
unsigned int v61; // [rsp+6Ch] [rbp-Dh]
void *Block[2]; // [rsp+70h] [rbp-9h] BYREF
__int64 v63; // [rsp+80h] [rbp+7h]
unsigned __int64 v64; // [rsp+88h] [rbp+Fh]
v60 = a4;
v61 = a2;
v6 = a1;
v59 = a1;
v7 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v58 = (__int64 *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v58);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v7 = qword_14090BFD0;
}
*(_OWORD *)Block = 0;
v63 = 3;
v64 = 15;
LODWORD(Block[0]) = 6256231;
sub_140044D80(Block, "0230", 4u);
v8 = *(_QWORD *)(v7 + 432);
v9 = cocos2d::CCString::createWithFormat((const char *)&word_1406ED6F8, (unsigned int)a2);
cocos2d::CCDictionary::setObject(v8, v9, Block);
if ( v64 > 0xF )
{
v10 = Block[0];
if ( v64 + 1 >= 0x1000 )
{
v10 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v10 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v10);
}
v63 = 0;
v64 = 15;
LOBYTE(Block[0]) = 0;
v11 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v58 = (__int64 *)operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v58);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v11 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v11, "0231");
v57 = GameVariable;
*(_OWORD *)Src = 0;
v56 = nullptr;
if ( a3 )
{
v12 = *(__int64 **)(v6 + 1512);
v14 = v12[442];
if ( v14 )
{
v12 = *(__int64 **)(v14 + 56);
v15 = *(unsigned int *)v12;
if ( (_DWORD)v15 )
{
v12 = (__int64 *)v12[2];
for ( i = &v12[v15 - 1]; v12 <= i; ++v12 )
{
v17 = *v12;
if ( !*v12 )
break;
if ( *(_DWORD *)(v17 + 924) == a2 )
{
if ( !GameVariable || EditorUI::findPassesFilters((__int64)v12, *v12) )
{
v18 = sub_14003D460(8u);
*v18 = v17;
memmove(v18, nullptr, 0);
v12 = nullptr;
Src[0] = v18;
Src[1] = v18 + 1;
v56 = v18 + 1;
v6 = v59;
goto LABEL_52;
}
break;
}
}
}
}
}
else if ( a2 > 0 )
{
Group = GJBaseGameLayer::getGroup(*(_QWORD *)(v6 + 1512), (unsigned int)a2);
if ( Group
&& (v21 = *(unsigned int **)(Group + 56), v22 = *v21, (_DWORD)v22)
&& (v23 = *((__int64 **)v21 + 2), v24 = &v23[v22 - 1], v58 = v24, v23 <= v24) )
{
v25 = nullptr;
do
{
v26 = *v23;
if ( !*v23 )
break;
if ( GameVariable )
{
v25 = (__int64 *)Src[1];
v27 = !EditorUI::findPassesFilters((__int64)v20, *v23);
v24 = v58;
if ( v27 )
continue;
}
if ( v25 == v56 )
{
v28 = ((char *)v25 - (char *)Src[0]) >> 3;
if ( v28 == 0x1FFFFFFFFFFFFFFFLL )
sub_14005A170();
v29 = v28 + 1;
v30 = ((char *)v56 - (char *)Src[0]) >> 3;
if ( v30 <= 0x1FFFFFFFFFFFFFFFLL - (v30 >> 1) )
{
v31 = v28 + 1;
if ( (v30 >> 1) + v30 >= v29 )
v31 = (v30 >> 1) + v30;
if ( v31 > 0x1FFFFFFFFFFFFFFFLL )
sub_140009CF0(v31, v30, v29);
}
else
{
v31 = 0x1FFFFFFFFFFFFFFFLL;
}
v32 = v31;
v33 = sub_14003D460(8 * v31);
v33[v28] = v26;
v34 = (__int64 *)Src[0];
v35 = v33;
if ( v25 == Src[1] )
{
v36 = (char *)Src[1] - (char *)Src[0];
}
else
{
memmove(v33, Src[0], (char *)v25 - (char *)Src[0]);
v36 = (char *)Src[1] - (char *)v25;
v35 = &v33[v28 + 1];
v34 = v25;
}
memmove(v35, v34, v36);
v20 = Src[0];
if ( Src[0] )
{
if ( (((char *)v56 - (char *)Src[0]) & 0xFFFFFFFFFFFFFFF8uLL) >= 0x1000 )
{
v20 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v20 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v20);
}
Src[0] = v33;
v25 = &v33[v28 + 1];
v56 = &v33[v32];
v24 = v58;
GameVariable = v57;
}
else
{
*v25 = v26;
v25 = (__int64 *)((char *)Src[1] + 8);
}
Src[1] = v25;
++v23;
}
while ( v23 <= v24 );
}
else
{
v25 = nullptr;
}
sub_1401C9920(Src[0], v25, ((char *)v25 - (char *)Src[0]) >> 3, a3);
v6 = v59;
}
v18 = Src[0];
LABEL_52:
if ( v18 == Src[1] )
{
Block[1] = (void *)46;
v63 = 9;
v64 = 15;
Block[0] = (void *)0x686374614D206F4ELL;
EditorUI::showTextAlert(v6, Block, 0, 1, 0);
}
else
{
if ( v60 )
{
v46 = ((char *)Src[1] - (char *)v18) >> 3;
v47 = 0;
if ( (int)v46 <= 0 )
goto LABEL_67;
v48 = 0;
while ( *(_DWORD *)(v18[v48] + 924LL) != *(_DWORD *)(v6 + 1504) )
{
++v47;
if ( ++v48 >= (int)v46 )
goto LABEL_67;
}
if ( v47 < 0 )
{
LABEL_67:
if ( v60 <= 0 )
v49 = v46 - 1;
else
v49 = 0;
}
else
{
v49 = ((int)v46 + v60 + v47) % (int)v46;
}
v50 = (int *)v18[v49];
*(_DWORD *)(v6 + 1504) = v50[231];
v51 = *(_QWORD *)(v6 + 1568);
if ( !v51 || *(_DWORD *)(v51 + 924) != v50[231] )
EditorUI::createUndoSelectObject(v6, 0);
EditorUI::selectObject(v6, v50, 0);
EditorUI::updateButtons(v6);
EditorUI::updateSpecialUIElements(v6);
v44 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(int *))(*(_QWORD *)v50 + 200LL))(v50);
v45 = (cocos2d::CCPoint *)&v59;
}
else
{
v37 = (cocos2d::CCArray *)cocos2d::CCArray::create(v12);
v38 = 0;
v39 = (struct cocos2d::CCObject **)Src[0];
v40 = ((char *)Src[1] - (char *)Src[0]) >> 3;
if ( v40 )
{
do
{
cocos2d::CCArray::addObject(v37, v39[v38++]);
v39 = (struct cocos2d::CCObject **)Src[0];
}
while ( v38 < ((char *)Src[1] - (char *)Src[0]) >> 3 );
}
if ( a3
|| (MainObject = GJBaseGameLayer::tryGetMainObject(*(_QWORD *)(v6 + 1512), v61), (v42 = MainObject) == 0)
|| (void *)sub_140677140(Src[0], Src[1], MainObject) == Src[1] )
{
v43 = 0;
}
else
{
v43 = *(_DWORD *)(v42 + 924);
}
*(_DWORD *)(v6 + 1504) = v43;
EditorUI::getGroupCenter(v40, &v59, v37, 0);
EditorUI::processSelectObjects(v6, v37);
v44 = (const struct cocos2d::CCPoint *)&v59;
v45 = (cocos2d::CCPoint *)&v58;
}
cocos2d::CCPoint::CCPoint(v45, v44);
EditorUI::centerCameraOnPoint(v6, v52);
}
v53 = Src[0];
if ( Src[0] )
{
if ( (((char *)v56 - (char *)Src[0]) & 0xFFFFFFFFFFFFFFF8uLL) >= 0x1000 )
{
v53 = *((void **)Src[0] - 1);
if ( (unsigned __int64)((char *)Src[0] - (char *)v53 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v53);
}
}