//
// cocos2d::CCTouchDispatcher::addTargetedDelegate from 0x1800b2b20 to 0x1800b2bf0 (208 bytes)
//
// 5 xrefs:
// > cocos2d::CCLayer::registerWithTouchDispatcher @ 0x180050989
// > cocos2d::CCMenu::registerWithTouchDispatcher @ 0x1800598fa
// > cocos2d::CCTouchDispatcher::addPrioTargetedDelegate @ 0x1800b2a70
// > ??> @ 0x1801438a8
// > ??> @ 0x1801b8634
//
// 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
//
void __fastcall cocos2d::CCTouchDispatcher::addTargetedDelegate(
cocos2d::CCTouchDispatcher *this,
struct cocos2d::CCTouchDelegate *a2,
int a3,
bool a4)
{
unsigned int m_targetPrio; // esi
struct cocos2d::CCTargetedTouchHandler *v8; // rax
struct cocos2d::CCObject *v9; // rsi
m_targetPrio = a3;
if ( this->m_forcePrio <= 0
|| a3 <= this->m_targetPrio
|| ((unsigned int (__fastcall *)(struct cocos2d::CCTouchDelegate *))a2->getPreviousPriority)(a2) )
{
if ( ((unsigned int (__fastcall *)(struct cocos2d::CCTouchDelegate *))a2->getPreviousPriority)(a2) )
m_targetPrio = ((__int64 (__fastcall *)(struct cocos2d::CCTouchDelegate *))a2->getPreviousPriority)(a2);
}
else
{
m_targetPrio = this->m_targetPrio;
}
((void (__fastcall *)(struct cocos2d::CCTouchDelegate *, _QWORD))a2->setPreviousPriority)(a2, m_targetPrio);
v8 = cocos2d::CCTargetedTouchHandler::handlerWithDelegate(a2, m_targetPrio, a4);
v9 = v8;
if ( this->m_bLocked )
{
if ( sub_18009E1B0((__int64)this->m_pHandlersToRemove, (__int64)a2) )
{
sub_18009E300((__int64)this->m_pHandlersToRemove, (__int64)a2);
}
else
{
cocos2d::CCArray::addObject(this->m_pHandlersToAdd, v9);
this->m_bToAdd = 1;
}
}
else
{
cocos2d::CCTouchDispatcher::forceAddHandler(this, v8, this->m_pTargetedHandlers);
}
}