//
// SelectEventLayer::onCustomToggleTriggerValue from 0xa53e54 to 0xa5410c (696 bytes)
//
// 2 xrefs:
// > ??> @ 0x45db0
// > ??> @ 0x11e55c0
//
// 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 SelectEventLayer::onCustomToggleTriggerValue(SelectEventLayer *a1, cocos2d::CCObject *a2)
{
cocos2d::CCObject_vtbl *v4; // x1
std::_Rb_tree_node_base *p_M_header; // x24
std::_Rb_tree_node_base *v6; // x25
int v7; // w0
std::_Rb_tree_node_base::_Base_ptr M_parent; // x20
__int64 v9; // x19
int v10; // w1
cocos2d::CCDictionary *m_customValueToggles; // x0
cocos2d::CCDictElement *m_pElements; // x0
CCMenuItemToggler *m_pObject; // x19
_QWORD *next; // x20
int v15; // w0
std::_Rb_tree_node_base::_Base_ptr v16; // x1
SelectEventLayer *v17; // x3
_QWORD *v18; // x0
std::_Rb_tree_node_base::_Base_ptr v19; // x0
__int64 v20; // x2
__int64 v21; // x1
__int64 v22; // x2
__int64 v23; // x0
void *v24; // x0
int v25; // [xsp+54h] [xbp+54h] BYREF
if ( a2 )
{
v4 = a2->__vftable;
a1->m_eventsChanged = 1;
p_M_header = &a1->m_eventIDs._M_t._M_impl._M_header;
v25 = v4->getTag(a2);
if ( &a1->m_eventIDs._M_t._M_impl._M_header == (std::_Rb_tree_node_base *)std::_Rb_tree,std::less,std::allocator>::find(
(__int64)&a1->m_eventIDs,
&v25) )
{
v25 = a2->getTag(a2);
std::_Rb_tree,std::less,std::allocator>::_M_insert_unique(
&a1->m_eventIDs._M_t._M_impl._M_key_compare.pad,
&v25);
goto LABEL_8;
}
v6 = &a1->m_eventIDs._M_t._M_impl._M_header;
v7 = a2->getTag(a2);
M_parent = a1->m_eventIDs._M_t._M_impl._M_header._M_parent;
v9 = (__int64)M_parent;
if ( M_parent )
{
while ( 1 )
{
while ( 1 )
{
v10 = *(_DWORD *)(v9 + 32);
if ( v7 <= v10 )
break;
v9 = *(_QWORD *)(v9 + 24);
if ( !v9 )
goto LABEL_6;
}
if ( v7 >= v10 )
break;
v6 = (std::_Rb_tree_node_base *)v9;
v9 = *(_QWORD *)(v9 + 16);
if ( !v9 )
{
LABEL_6:
if ( v6 != a1->m_eventIDs._M_t._M_impl._M_header._M_left || p_M_header != v6 )
goto LABEL_8;
do
{
LABEL_26:
std::_Rb_tree,std::less,std::allocator>::_M_erase(
(__int64)&a1->m_eventIDs,
M_parent->_M_right);
v19 = M_parent;
M_parent = M_parent->_M_left;
operator delete(v19);
}
while ( M_parent );
goto LABEL_27;
}
}
v20 = *(_QWORD *)(v9 + 16);
v21 = *(_QWORD *)(v9 + 24);
while ( v20 )
{
while ( v7 <= *(_DWORD *)(v20 + 32) )
{
v9 = v20;
v20 = *(_QWORD *)(v20 + 16);
if ( !v20 )
goto LABEL_31;
}
v20 = *(_QWORD *)(v20 + 24);
}
LABEL_31:
while ( v21 )
{
while ( v7 < *(_DWORD *)(v21 + 32) )
{
v6 = (std::_Rb_tree_node_base *)v21;
v21 = *(_QWORD *)(v21 + 16);
if ( !v21 )
goto LABEL_34;
}
v21 = *(_QWORD *)(v21 + 24);
}
LABEL_34:
if ( v6 == p_M_header && a1->m_eventIDs._M_t._M_impl._M_header._M_left == (std::_Rb_tree_node_base::_Base_ptr)v9 )
goto LABEL_26;
if ( (std::_Rb_tree_node_base *)v9 != v6 )
{
do
{
v22 = sub_CFAB74(v9);
v23 = v9;
v9 = v22;
v24 = (void *)sub_CFAF34(v23, &a1->m_eventIDs._M_t._M_impl._M_header);
operator delete(v24);
--a1->m_eventIDs._M_t._M_impl._M_node_count;
}
while ( v6 != (std::_Rb_tree_node_base *)v9 );
}
}
else if ( p_M_header == a1->m_eventIDs._M_t._M_impl._M_header._M_left )
{
LABEL_27:
a1->m_eventIDs._M_t._M_impl._M_header._M_left = p_M_header;
a1->m_eventIDs._M_t._M_impl._M_header._M_parent = nullptr;
a1->m_eventIDs._M_t._M_impl._M_header._M_right = p_M_header;
a1->m_eventIDs._M_t._M_impl._M_node_count = 0;
}
}
LABEL_8:
m_customValueToggles = a1->m_customValueToggles;
if ( m_customValueToggles )
{
m_pElements = m_customValueToggles->m_pElements;
if ( m_pElements )
{
m_pObject = (CCMenuItemToggler *)m_pElements->m_pObject;
next = m_pElements->hh.next;
v15 = m_pObject->getTag(m_pObject);
v16 = a1->m_eventIDs._M_t._M_impl._M_header._M_parent;
if ( !v16 )
goto LABEL_17;
LABEL_11:
v17 = (SelectEventLayer *)&a1->m_eventIDs._M_t._M_impl._M_header;
do
{
while ( v15 <= (int)v16[1]._M_color )
{
v17 = (SelectEventLayer *)v16;
v16 = v16->_M_left;
if ( !v16 )
goto LABEL_14;
}
v16 = v16->_M_right;
}
while ( v16 );
LABEL_14:
if ( &a1->m_eventIDs._M_t._M_impl._M_header == (std::_Rb_tree_node_base *)v17 )
{
LABEL_17:
while ( 1 )
{
CCMenuItemToggler::toggle(m_pObject, 0);
if ( !next )
break;
LABEL_16:
v18 = next;
next = (_QWORD *)next[36];
m_pObject = (CCMenuItemToggler *)v18[33];
v15 = m_pObject->getTag(m_pObject);
v16 = a1->m_eventIDs._M_t._M_impl._M_header._M_parent;
if ( v16 )
goto LABEL_11;
}
}
else
{
CCMenuItemToggler::toggle(m_pObject, v15 >= v17->m_uIndexInArray);
if ( next )
goto LABEL_16;
}
}
}
}