//
// GJBaseGameLayer::playerTouchedObject from 0x8877e0 to 0x887948 (360 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::canBeActivatedByPlayer @ 0x8879a4
// > GJBaseGameLayer::canBeActivatedByPlayer @ 0x8879e0
// > ??> @ 0x65d30
//
// 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 GJBaseGameLayer::playerTouchedObject(GJBaseGameLayer *a1, PlayerObject *a2, GameObject *a3)
{
std::_rb_tree_base *p_m_header; // x23
std::_rb_tree_base *m_parent; // x0
int m_uniqueID; // w22
std::_rb_tree_base *v7; // x20
int v8; // w19
int v9; // w1
int v10; // w0
__int64 insert_hint_unique_pos; // x0
__int64 v12; // x1
std::_rb_tree_base *v13; // x3
__int64 v14; // x2
int v15; // w3
_BOOL8 v16; // x0
int v17; // w1
std::_rb_tree_base *v18; // x0
__int64 v19; // [xsp+48h] [xbp+48h]
p_m_header = &a1->m_gameState.m_activatedObjectIDs.m_header;
m_parent = a1->m_gameState.m_activatedObjectIDs.m_header.m_parent;
m_uniqueID = a2->m_uniqueID;
v7 = p_m_header;
v8 = a3->m_uniqueID;
if ( !m_parent )
goto LABEL_8;
do
{
while ( 1 )
{
v9 = *(_DWORD *)&m_parent[1].m_isblack;
if ( v8 > v9 || v8 >= v9 && m_uniqueID > *((_DWORD *)&m_parent[1].m_isblack + 1) )
break;
v7 = m_parent;
m_parent = m_parent->m_left;
if ( !m_parent )
goto LABEL_6;
}
m_parent = m_parent->m_right;
}
while ( m_parent );
LABEL_6:
if ( p_m_header == v7 )
goto LABEL_8;
v10 = *(_DWORD *)&v7[1].m_isblack;
if ( v8 < v10 )
goto LABEL_8;
if ( v8 > v10 )
{
LABEL_15:
LODWORD(v7[1].m_parent) = a1->m_gameState.m_commandIndex;
return;
}
if ( m_uniqueID < *((_DWORD *)&v7[1].m_isblack + 1) )
{
LABEL_8:
v19 = (__int64)v7;
v7 = (std::_rb_tree_base *)operator new(0x30u);
*(_DWORD *)&v7[1].m_isblack = v8;
*((_DWORD *)&v7[1].m_isblack + 1) = m_uniqueID;
LODWORD(v7[1].m_parent) = 0;
insert_hint_unique_pos = std::_Rb_tree,std::pair const,int>,std::_Select1st const,int>>,std::less>,std::allocator const,int>>>::_M_get_insert_hint_unique_pos(
&a1->m_gameState.m_activatedObjectIDs.compare.pad,
v19,
&v7[1].m_isblack);
v13 = (std::_rb_tree_base *)insert_hint_unique_pos;
v14 = v12;
if ( v12 )
{
if ( insert_hint_unique_pos || p_m_header == (std::_rb_tree_base *)v12 )
{
v16 = 1;
}
else
{
v15 = *(_DWORD *)&v7[1].m_isblack;
v16 = 1;
v17 = *(_DWORD *)(v12 + 32);
if ( v15 >= v17 )
{
v16 = 0;
if ( v15 <= v17 )
v16 = *((_DWORD *)&v7[1].m_isblack + 1) < *(_DWORD *)(v14 + 36);
}
}
sub_CFAD74(v16, v7, v14, p_m_header);
++a1->m_gameState.m_activatedObjectIDs.m_nodecount;
}
else
{
v18 = v7;
v7 = v13;
operator delete(v18);
}
goto LABEL_15;
}
LODWORD(v7[1].m_parent) = a1->m_gameState.m_commandIndex;
}