//
// EditorUI::ccTouchEnded from 0x1401c0cf0 to 0x1401c19fd (3341 bytes)
//
// 2 xrefs:
// > ??> @ 0x1407511d0
// > ??> @ 0x14091a6b4
//
// 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:03 +0000
//
// Hidden C++ exception states: #wind=2
double __fastcall EditorUI::ccTouchEnded(__int64 a1, __int64 a2, __int64 a3)
{
double result; // xmm0_8
int v7; // eax
__int64 v8; // rcx
__int64 v9; // rcx
__int64 v10; // rcx
char GameVariable; // r15
__int64 v12; // rcx
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
const struct cocos2d::CCPoint *v16; // r8
const struct cocos2d::CCPoint *v17; // r8
float v18; // xmm0_4
char v19; // bl
float v20; // xmm0_4
char v21; // r12
__int64 v22; // rcx
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rcx
__int64 v27; // rcx
float v28; // xmm0_4
unsigned __int8 v29; // r15
float *v30; // rax
__int64 v31; // rbx
cocos2d::CCPoint *v32; // rax
__int64 v33; // rbx
__int64 v34; // rax
const struct cocos2d::CCPoint *v35; // rax
unsigned int i; // ebx
struct cocos2d::CCObject *v37; // rsi
__int64 v38; // rax
__int64 v39; // rax
__int64 v40; // rax
__int64 v41; // rax
cocos2d::CCPoint *v42; // rax
__int64 v43; // rax
struct cocos2d::CCObject *v44; // r14
__int64 v45; // rsi
unsigned int v46; // ebx
cocos2d::CCObject *v47; // rcx
__int64 v48; // rbx
__int64 v49; // rcx
__int64 v50; // rax
__int64 v51; // rax
__int64 v52; // rax
const struct cocos2d::CCPoint *v53; // r8
__int64 v54; // rbx
__int64 v55; // rax
cocos2d::CCArray *v56; // r15
unsigned int *v57; // rbx
unsigned int v58; // r14d
struct cocos2d::CCObject *v59; // rax
__int64 v60; // rcx
unsigned int *v61; // rsi
struct cocos2d::CCArray *v62; // rax
__int64 v63; // rax
const struct cocos2d::CCRect *v64; // rax
__int64 v65; // rbx
__int64 v66; // rax
cocos2d::CCArray *v67; // rbx
__int64 v68; // rax
__int64 v69; // rcx
__int64 v70; // rax
__int64 v71; // rax
__int64 v72; // rax
const struct cocos2d::CCPoint *v73; // r8
float v74; // xmm0_4
__int64 v75; // rbx
__int64 v76; // rax
cocos2d::CCArray *v77; // r15
unsigned int *v78; // rbx
unsigned int v79; // r14d
struct cocos2d::CCObject *v80; // rax
__int64 v81; // rcx
unsigned int *v82; // rsi
__int64 v83; // rsi
__int64 v84; // rcx
struct cocos2d::CCObject *Object; // rax
struct cocos2d::CCArray *v86; // rax
__int64 v87; // rax
_BYTE *v88; // rcx
__int64 v89; // rax
char v90; // bl
_BYTE v91[8]; // [rsp+38h] [rbp-59h] BYREF
float v92; // [rsp+40h] [rbp-51h] BYREF
float v93; // [rsp+44h] [rbp-4Dh]
void *v94; // [rsp+48h] [rbp-49h] BYREF
_BYTE v95[8]; // [rsp+50h] [rbp-41h] BYREF
_BYTE v96[8]; // [rsp+58h] [rbp-39h] BYREF
_BYTE v97[16]; // [rsp+60h] [rbp-31h] BYREF
_BYTE v98[16]; // [rsp+70h] [rbp-21h] BYREF
_BYTE v99[56]; // [rsp+80h] [rbp-11h] BYREF
void *v100; // [rsp+F8h] [rbp+67h] BYREF
char v101; // [rsp+100h] [rbp+6Fh] BYREF
float v102; // [rsp+110h] [rbp+7Fh] BYREF
float v103; // [rsp+114h] [rbp+83h]
if ( *(_BYTE *)(a1 + 478) && *(_DWORD *)(a1 + 432) == *(_DWORD *)(a2 + 56) )
{
cocos2d::CCNode::stopActionByTag((cocos2d::CCNode *)(a1 - 320), 128);
EditorUI::finishTouchDelay(a1 - 320);
}
*(_BYTE *)(a1 + 504) = 0;
cocos2d::CCNode::stopActionByTag((cocos2d::CCNode *)(a1 - 320), 123);
v7 = *(_DWORD *)(a2 + 56);
if ( *(_DWORD *)(a1 + 424) == v7 )
{
*(_DWORD *)(a1 + 424) = -1;
v8 = *(_QWORD *)(a1 + 488);
LABEL_6:
(*(void (__fastcall **)(__int64, __int64, __int64))(*(_QWORD *)(v8 + 320) + 24LL))(v8 + 320, a2, a3);
return result;
}
if ( *(_DWORD *)(a1 + 428) == v7 )
{
*(_DWORD *)(a1 + 428) = -1;
v8 = *(_QWORD *)(a1 + 512);
goto LABEL_6;
}
if ( *(_DWORD *)(a1 + 440) == v7 )
{
*(_DWORD *)(a1 + 440) = -1;
v8 = *(_QWORD *)(a1 + 520);
goto LABEL_6;
}
v9 = *(_QWORD *)(a1 + 1192);
if ( *(_DWORD *)(v9 + 2204) == 1 )
{
v8 = *(_QWORD *)(v9 + 13888);
goto LABEL_6;
}
if ( *(_BYTE *)(a1 + 476) )
{
*(_DWORD *)(a1 + 444) = -1;
*(_DWORD *)(a1 + 432) = -1;
*(_BYTE *)(a1 + 476) = 0;
*(_BYTE *)(a1 + 1264) = 0;
return result;
}
if ( *(_DWORD *)(a1 + 432) == v7 )
{
v10 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v100 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v100);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v10 = qword_14090BFD0;
}
GameVariable = GameManager::getGameVariable(v10, "0059");
cocos2d::CCTouch::getLocationInView(a2, &v101);
v13 = cocos2d::CCDirector::sharedDirector(v12);
v14 = cocos2d::CCDirector::convertToGL(v13, &v100, &v101);
cocos2d::CCPoint::operator=(&v101, v14);
cocos2d::CCNode::convertToWorldSpace(a1 - 320, &v100, &v101);
cocos2d::CCPoint::operator=(&v101, v15);
v18 = cocos2d::ccpDistance((cocos2d *)(a1 + 1200), (const struct cocos2d::CCPoint *)&v101, v16);
if ( GameVariable && v18 < 2.0 )
{
v19 = 1;
v20 = cocos2d::ccpDistance((cocos2d *)(a1 + 1224), (const struct cocos2d::CCPoint *)&v101, v17);
}
else
{
v20 = cocos2d::ccpDistance((cocos2d *)(a1 + 1224), (const struct cocos2d::CCPoint *)&v101, v17);
v19 = 0;
if ( !GameVariable )
goto LABEL_24;
}
if ( v20 < 2.0 )
{
v21 = 1;
LABEL_25:
*(_DWORD *)(a1 + 432) = -1;
if ( *(_BYTE *)(a1 + 593) && *(_BYTE *)(a1 + 591) && *(_QWORD *)(a1 + 1256) )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v102, (const struct cocos2d::CCPoint *)&unk_14090A708);
cocos2d::CCTouch::getLocationInView(a2, &v100);
v23 = cocos2d::CCDirector::sharedDirector(v22);
v24 = cocos2d::CCDirector::convertToGL(v23, &v94, &v100);
cocos2d::CCPoint::operator=(&v100, v24);
cocos2d::CCNode::convertToWorldSpace(a1 - 320, &v94, &v100);
cocos2d::CCPoint::operator=(&v100, v25);
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(*(_QWORD *)(a1 + 1192) + 4296LL), v95, &v100);
v26 = qword_14090BFD0;
if ( !qword_14090BFD0 )
{
v94 = operator new(0x6E8u);
qword_14090BFD0 = GameManager::GameManager(v94);
(*(void (__fastcall **)(__int64))(*(_QWORD *)qword_14090BFD0 + 72LL))(qword_14090BFD0);
v26 = qword_14090BFD0;
}
if ( (unsigned __int8)GameManager::getGameVariable(v26, "0008")
&& (v27 = *(_QWORD *)(a1 + 1256)) != 0
&& (v28 = (*(float (__fastcall **)(__int64))(*(_QWORD *)v27 + 360LL))(v27), (int)v28 == 90 * ((int)v28 / 90))
&& !cocos2d::CCPoint::equals((cocos2d::CCPoint *)&v100, (const struct cocos2d::CCPoint *)(a1 + 1200)) )
{
v29 = 1;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v91, (const struct cocos2d::CCPoint *)v95);
EditorUI::getGridSnappedPos(a1 - 320, (__int64)&v92, v30);
v31 = *(_QWORD *)(a1 + 1256);
v32 = offsetForKey((cocos2d::CCPoint *)v99, *(_DWORD *)(v31 + 1036));
GameToolbox::getRelativeOffset((cocos2d::CCPoint *)v91, v31, v32);
v33 = *(_QWORD *)(a1 + 1256);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v97, (const struct cocos2d::CCPoint *)&v92);
EditorUI::applySpecialOffset(a1 - 320, (unsigned int)v96, (unsigned int)v91, v33, v34);
cocos2d::CCPoint::operator+(&v92, v91, v96);
cocos2d::CCPoint::operator=(&v92, v91);
v35 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 1256) + 200LL))(*(_QWORD *)(a1 + 1256));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v94, v35);
(*(void (__fastcall **)(_QWORD, float *))(**(_QWORD **)(a1 + 1256) + 184LL))(*(_QWORD *)(a1 + 1256), &v92);
cocos2d::CCPoint::operator-(&v92, v91, &v94);
cocos2d::CCPoint::operator=(&v102, v91);
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 624)) )
{
for ( i = 0; i < cocos2d::CCArray::count(*(cocos2d::CCArray **)(a1 + 624)); ++i )
{
v37 = cocos2d::CCArray::objectAtIndex(*(cocos2d::CCArray **)(a1 + 624), i);
if ( *((_DWORD *)v37 + 231) != *(_DWORD *)(*(_QWORD *)(a1 + 1256) + 924LL) )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v97, (const struct cocos2d::CCPoint *)&v102);
EditorUI::moveObject(a1 - 320, v37, v38);
}
}
}
cocos2d::CCPoint::operator+(a1 + 496, v91, &v102);
cocos2d::CCPoint::operator=(a1 + 496, v91);
if ( (*(unsigned __int8 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 488) + 344LL))(*(_QWORD *)(a1 + 488)) )
{
v39 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 488) + 200LL))(*(_QWORD *)(a1 + 488));
cocos2d::CCPoint::operator+(v39, v91, &v102);
(*(void (__fastcall **)(_QWORD, _BYTE *))(**(_QWORD **)(a1 + 488) + 184LL))(*(_QWORD *)(a1 + 488), v91);
}
else if ( (*(unsigned __int8 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 512) + 344LL))(*(_QWORD *)(a1 + 512)) )
{
v40 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 512) + 200LL))(*(_QWORD *)(a1 + 512));
cocos2d::CCPoint::operator+(v40, v91, &v102);
(*(void (__fastcall **)(_QWORD, _BYTE *))(**(_QWORD **)(a1 + 512) + 184LL))(*(_QWORD *)(a1 + 512), v91);
}
else if ( (*(unsigned __int8 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 520) + 344LL))(*(_QWORD *)(a1 + 520)) )
{
v41 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 520) + 200LL))(*(_QWORD *)(a1 + 520));
cocos2d::CCPoint::operator+(v41, v91, &v102);
(*(void (__fastcall **)(_QWORD, _BYTE *))(**(_QWORD **)(a1 + 520) + 184LL))(*(_QWORD *)(a1 + 520), v91);
GJTransformControl::refreshControl(*(_QWORD *)(a1 + 520));
}
}
else
{
v29 = 0;
}
v42 = (cocos2d::CCPoint *)(*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 1256) + 200LL))(*(_QWORD *)(a1 + 1256));
if ( cocos2d::CCPoint::equals(v42, (const struct cocos2d::CCPoint *)(a1 + 616)) )
*(_BYTE *)(a1 + 417) = 1;
v43 = (*(__int64 (__fastcall **)(_QWORD))(**(_QWORD **)(a1 + 1256) + 200LL))(*(_QWORD *)(a1 + 1256));
cocos2d::CCPoint::operator-(v43, v98, a1 + 616);
if ( !*(_BYTE *)(a1 + 417) )
{
v44 = *(struct cocos2d::CCObject **)(a1 + 408);
if ( v44 )
{
v45 = *(_QWORD *)(a1 + 1192);
cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(v45 + 14920));
v46 = 1000;
if ( !*(_BYTE *)(v45 + 14663) )
v46 = 200;
if ( cocos2d::CCArray::count(*(cocos2d::CCArray **)(v45 + 14912)) >= v46 )
cocos2d::CCArray::removeObjectAtIndex(*(cocos2d::CCArray **)(v45 + 14912), 0, 1);
cocos2d::CCArray::addObject(*(cocos2d::CCArray **)(v45 + 14912), v44);
v47 = *(cocos2d::CCObject **)(a1 + 408);
if ( v47 )
{
cocos2d::CCObject::release(v47);
*(_QWORD *)(a1 + 408) = 0;
}
}
}
goto LABEL_99;
}
if ( !*(_BYTE *)(a1 + 589) || v19 )
{
if ( *(_BYTE *)(a1 + 1264) )
{
*(_BYTE *)(a1 + 1264) = 0;
goto LABEL_98;
}
cocos2d::CCTouch::getLocationInView(a2, &v100);
v70 = cocos2d::CCDirector::sharedDirector(v69);
v71 = cocos2d::CCDirector::convertToGL(v70, &v102, &v100);
cocos2d::CCPoint::operator=(&v100, v71);
cocos2d::CCNode::convertToWorldSpace(a1 - 320, &v102, &v100);
cocos2d::CCPoint::operator=(&v100, v72);
v74 = cocos2d::ccpDistance((cocos2d *)(a1 + 1200), (const struct cocos2d::CCPoint *)&v100, v73);
if ( !*(_BYTE *)(a1 + 590) || v74 < 20.0 )
{
if ( *(_DWORD *)(a1 + 1188) != 3 )
{
if ( !*(_BYTE *)(a1 + 1320) )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v100, (const struct cocos2d::CCPoint *)(a1 + 1200));
EditorUI::clickOnPosition(a1 - 320, v87);
}
goto LABEL_98;
}
cocos2d::CCNode::convertToNodeSpace(*(_QWORD *)(*(_QWORD *)(a1 + 1192) + 4296LL), &v100, a1 + 1200);
if ( !*(_QWORD *)(a1 + 1256) || !*(_BYTE *)(a1 + 418) )
{
v75 = *(_QWORD *)(a1 + 1192);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v102, (const struct cocos2d::CCPoint *)&v100);
v77 = (cocos2d::CCArray *)LevelEditorLayer::objectsAtPosition(v75, v76);
v78 = nullptr;
v79 = 0;
if ( cocos2d::CCArray::count(v77) )
{
do
{
v80 = cocos2d::CCArray::objectAtIndex(v77, v79);
v82 = (unsigned int *)v80;
if ( !*((_BYTE *)v80 + 1141) )
{
if ( !v78 || (v81 = v78[286], *((_DWORD *)v80 + 286) < (int)v81) )
{
if ( (unsigned __int8)EditorUI::canSelectObject(v81, v80) )
v78 = v82;
}
}
++v79;
}
while ( v79 < cocos2d::CCArray::count(v77) );
if ( v78 )
{
v78[286] = *(_DWORD *)(a1 + 1292);
EditorUI::createUndoSelectObject(a1 - 320, 0);
if ( *(_BYTE *)(a1 + 589) )
{
if ( v21 )
{
if ( *(_QWORD *)(a1 + 1248) )
{
v83 = a1 - 320;
cocos2d::CCNode::stopActionByTag((cocos2d::CCNode *)(a1 - 320), 124);
v84 = *(_QWORD *)(a1 - 320 + 1568);
if ( v84 )
{
*(_BYTE *)(v84 + 1141) = 0;
GameObject::updateObjectEditorColor(v84);
}
*(_QWORD *)(v83 + 1568) = 0;
EditorUI::toggleEditObjectButton(a1 - 320);
*(_BYTE *)(v83 + 824) = 1;
cocos2d::CCPoint::operator=(v83 + 1544, &unk_14090A748);
}
else
{
Object = cocos2d::CCArray::lastObject(*(cocos2d::CCArray **)(a1 + 624));
if ( Object )
{
*((_BYTE *)Object + 1141) = 0;
GameObject::updateObjectEditorColor(Object);
cocos2d::CCArray::removeLastObject(*(cocos2d::CCArray **)(a1 + 624), 1);
}
}
}
v86 = cocos2d::CCArray::createWithObject((struct cocos2d::CCObject *)v78);
EditorUI::selectObjects(a1 - 320, v86, 0);
goto LABEL_98;
}
EditorUI::selectObject(a1 - 320, v78, 0);
goto LABEL_68;
}
}
}
}
}
else
{
v48 = *(_QWORD *)(*(_QWORD *)(a1 + 1192) + 4296LL);
cocos2d::CCNode::convertToNodeSpace(v48, &v92, a1 + 1200);
cocos2d::CCNode::convertToNodeSpace(v48, &v102, a1 + 1208);
cocos2d::CCRect::CCRect(
(cocos2d::CCRect *)v97,
fminf(v92, v102),
fminf(v93, v103),
fabs(v92 - v102),
fabs(v93 - v103));
cocos2d::CCTouch::getLocationInView(a2, &v100);
v50 = cocos2d::CCDirector::sharedDirector(v49);
v51 = cocos2d::CCDirector::convertToGL(v50, v98, &v100);
cocos2d::CCPoint::operator=(&v100, v51);
cocos2d::CCNode::convertToWorldSpace(a1 - 320, v98, &v100);
cocos2d::CCPoint::operator=(&v100, v52);
if ( cocos2d::ccpDistance((cocos2d *)(a1 + 1200), (const struct cocos2d::CCPoint *)&v100, v53) >= 2.0 )
{
v64 = (const struct cocos2d::CCRect *)cocos2d::CCRect::CCRect(
(cocos2d::CCRect *)v98,
(const struct cocos2d::CCRect *)v97);
v65 = *(_QWORD *)(a1 + 1192);
v66 = cocos2d::CCRect::CCRect((cocos2d::CCRect *)v99, v64);
v67 = (cocos2d::CCArray *)LevelEditorLayer::objectsInRect(v65, v66, 0);
if ( cocos2d::CCArray::count(v67) )
{
v68 = EditorSFXManager::sharedState();
EditorSFXManager::playAction(v68, 122);
EditorUI::processSelectObjects(a1 - 320, v67);
}
goto LABEL_98;
}
v54 = *(_QWORD *)(a1 + 1192);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v100, (const struct cocos2d::CCPoint *)&v102);
v56 = (cocos2d::CCArray *)LevelEditorLayer::objectsAtPosition(v54, v55);
v57 = nullptr;
v58 = 0;
if ( cocos2d::CCArray::count(v56) )
{
do
{
v59 = cocos2d::CCArray::objectAtIndex(v56, v58);
v61 = (unsigned int *)v59;
if ( !*((_BYTE *)v59 + 1141) )
{
if ( !v57 || (v60 = v57[286], *((_DWORD *)v59 + 286) < (int)v60) )
{
if ( (unsigned __int8)EditorUI::canSelectObject(v60, v59) )
v57 = v61;
}
}
++v58;
}
while ( v58 < cocos2d::CCArray::count(v56) );
if ( v57 )
{
v57[286] = *(_DWORD *)(a1 + 1292);
EditorUI::createUndoSelectObject(a1 - 320, 0);
v62 = cocos2d::CCArray::createWithObject((struct cocos2d::CCObject *)v57);
EditorUI::selectObjects(a1 - 320, v62, 0);
LABEL_68:
v63 = EditorSFXManager::sharedState();
EditorSFXManager::playAction(v63, 121);
}
}
}
LABEL_98:
v29 = 0;
LABEL_99:
v88 = *(_BYTE **)(a1 + 1256);
if ( v88 )
{
if ( *(_BYTE *)(a1 + 593) && *(_BYTE *)(a1 + 591) )
{
if ( v88[1141] )
{
LOWORD(v100) = -256;
BYTE2(v100) = 0;
(*(void (__fastcall **)(_BYTE *, void **))(*(_QWORD *)v88 + 1376LL))(v88, &v100);
}
else
{
v88[1141] = 0;
GameObject::updateObjectEditorColor(v88);
}
v89 = EditorSFXManager::sharedState();
EditorSFXManager::playAction(v89, v29 + 105);
}
*(_QWORD *)(a1 + 1256) = 0;
}
*(_WORD *)(a1 + 589) = 0;
*(_BYTE *)(a1 + 593) = 0;
*(_BYTE *)(a1 + 417) = 0;
cocos2d::CCPoint::operator=(a1 + 600, &unk_14090A708);
*(_BYTE *)(a1 + 591) = 0;
*(_BYTE *)(a1 + 418) = 0;
cocos2d::CCPoint::operator=(a1 + 1216, a1 + 1200);
*(_BYTE *)(a1 + 1265) = 0;
v90 = *(_BYTE *)(a1 + 504);
EditorUI::updateButtons(a1 - 320);
++*(_DWORD *)(a1 + 1292);
cocos2d::CCArray::removeAllObjects(*(cocos2d::CCArray **)(a1 + 608));
if ( v90 )
{
EditorUI::updateSpecialUIElements(a1 - 320);
(*(void (__fastcall **)(__int64))(*(_QWORD *)(a1 + 120) + 96LL))(a1 + 120);
*(_BYTE *)(a1 + 504) = 0;
}
return cocos2d::CCPoint::operator=(a1 + 1224, &v101);
}
LABEL_24:
v21 = 0;
goto LABEL_25;
}
return result;
}