//
// GJBaseGameLayer::claimRotationAction from 0x86e04c to 0x86e35c (784 bytes)
//
// 3 xrefs:
// > GJBaseGameLayer::processRotationActions @ 0x86e550
// > GJBaseGameLayer::processTransformActions @ 0x86ed74
// > ??> @ 0x79e60
//
// 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::claimRotationAction(GJBaseGameLayer *a1, int a2, int a3, float *a4, float *a5, bool a6, bool a7)
{
GJEffectManager *m_effectManager; // x21
std::_rb_tree_base *m_parent; // x22
std::_rb_tree_base *p_m_header; // x20
std::_rb_tree_base *v10; // x6
std::_rb_tree_base *v11; // x0
int v12; // w19
int v13; // w0
std::_rb_tree_base *v14; // x6
std::_rb_tree_base *v15; // x0
int v16; // w7
int v18; // w0
std::_rb_tree_base *m_left; // x3
std::_rb_tree_base *v20; // x0
double v21; // d0
int v22; // w6
__int64 v23; // x6
float v24; // s0
std::_rb_tree_base *v25; // x0
std::_rb_tree_base *v26; // x19
std::_rb_tree_base *v27; // x0
std::_rb_tree_base *v28; // x0
std::_rb_tree_base *v29; // x23
int v30; // w6
int v31; // w3
std::_rb_tree_base *v32; // x19
std::_rb_tree_base *v33; // x0
std::_rb_tree_base *m_right; // x3
int v35; // w4
int v36; // w0
std::map,std::vector> *p_m_unkMap770; // x24
__int64 v38; // x21
__int64 v39; // x19
void *v40; // x0
void *v41; // x0
m_effectManager = a1->m_effectManager;
m_parent = m_effectManager->m_unkMap770.m_header.m_parent;
p_m_header = &m_effectManager->m_unkMap770.m_header;
if ( !m_parent )
return;
v10 = &m_effectManager->m_unkMap770.m_header;
v11 = m_effectManager->m_unkMap770.m_header.m_parent;
do
{
while ( 1 )
{
v12 = *(_DWORD *)&v11[1].m_isblack;
if ( a2 > v12 || a2 >= v12 && a3 > *((_DWORD *)&v11[1].m_isblack + 1) )
break;
v10 = v11;
v11 = v11->m_left;
if ( !v11 )
goto LABEL_7;
}
v11 = v11->m_right;
}
while ( v11 );
LABEL_7:
if ( p_m_header == v10 )
return;
v13 = *(_DWORD *)&v10[1].m_isblack;
if ( a2 < v13 || a2 <= v13 && a3 < *((_DWORD *)&v10[1].m_isblack + 1) )
return;
v14 = &m_effectManager->m_unkMap770.m_header;
v15 = m_effectManager->m_unkMap770.m_header.m_parent;
do
{
while ( 1 )
{
v16 = *(_DWORD *)&v15[1].m_isblack;
if ( a2 > v16 || a2 >= v16 && a3 > *((_DWORD *)&v15[1].m_isblack + 1) )
break;
v14 = v15;
v15 = v15->m_left;
if ( !v15 )
goto LABEL_16;
}
v15 = v15->m_right;
}
while ( v15 );
LABEL_16:
if ( p_m_header == v14
|| (v18 = *(_DWORD *)&v14[1].m_isblack, a2 < v18)
|| a2 <= v18 && a3 < *((_DWORD *)&v14[1].m_isblack + 1) )
{
sub_D13BA8("map::at", a2, a3, a4, a5, a6);
}
m_left = v14[1].m_left;
if ( v14[1].m_parent != m_left )
{
v20 = v14[1].m_parent;
do
{
v23 = *(_QWORD *)&v20->m_isblack;
if ( !*(_BYTE *)(*(_QWORD *)&v20->m_isblack + 424LL) )
{
*(_BYTE *)(v23 + 424) = 1;
v21 = a6 ? *(double *)(v23 + 168) - *(double *)(v23 + 280) : *(double *)(v23 + 160) - *(double *)(v23 + 272);
v24 = v21;
v22 = *(unsigned __int8 *)(v23 + 184);
*a4 = *a4 + v24;
if ( !v22 )
*a5 = *a5 + v24;
}
v20 = (std::_rb_tree_base *)((char *)v20 + 8);
}
while ( m_left != v20 );
}
v29 = &m_effectManager->m_unkMap770.m_header;
v25 = m_parent;
while ( 1 )
{
while ( 1 )
{
v30 = *(_DWORD *)&v25[1].m_isblack;
if ( a2 <= v30 )
break;
LABEL_29:
v25 = v25->m_right;
if ( !v25 )
goto LABEL_30;
}
if ( a2 >= v30 )
break;
LABEL_65:
v29 = v25;
v25 = v25->m_left;
if ( !v25 )
{
LABEL_30:
if ( m_effectManager->m_unkMap770.m_header.m_left != v29 || p_m_header != v29 )
return;
goto LABEL_32;
}
}
v31 = *((_DWORD *)&v25[1].m_isblack + 1);
if ( a3 > v31 )
goto LABEL_29;
if ( a3 < v31 )
goto LABEL_65;
v32 = v25;
v33 = v25->m_left;
m_right = v32->m_right;
while ( v33 )
{
while ( 1 )
{
v35 = *(_DWORD *)&v33[1].m_isblack;
if ( a2 > v35 || a2 >= v35 && a3 > *((_DWORD *)&v33[1].m_isblack + 1) )
break;
v32 = v33;
v33 = v33->m_left;
if ( !v33 )
goto LABEL_52;
}
v33 = v33->m_right;
}
LABEL_52:
while ( m_right )
{
while ( 1 )
{
v36 = *(_DWORD *)&m_right[1].m_isblack;
if ( a2 >= v36 && (a2 > v36 || a3 >= *((_DWORD *)&m_right[1].m_isblack + 1)) )
break;
v29 = m_right;
m_right = m_right->m_left;
if ( !m_right )
goto LABEL_57;
}
m_right = m_right->m_right;
}
LABEL_57:
if ( p_m_header != v29 || v32 != m_effectManager->m_unkMap770.m_header.m_left )
{
p_m_unkMap770 = &m_effectManager->m_unkMap770;
if ( v29 != v32 )
{
do
{
v38 = sub_CFAB74(v32);
v39 = sub_CFAF34(v32, p_m_header);
v40 = *(void **)(v39 + 40);
if ( v40 )
operator delete(v40);
v41 = (void *)v39;
v32 = (std::_rb_tree_base *)v38;
operator delete(v41);
--p_m_unkMap770->m_nodecount;
}
while ( v29 != (std::_rb_tree_base *)v38 );
}
return;
}
do
{
LABEL_32:
std::_Rb_tree,std::pair const,std::vector>,std::_Select1st const,std::vector>>,std::less>,std::allocator const,std::vector>>>::_M_erase(
(__int64)&m_effectManager->m_unkMap770,
&m_parent->m_right->m_isblack);
v26 = m_parent->m_left;
v27 = m_parent[1].m_parent;
if ( v27 )
operator delete(v27);
v28 = m_parent;
m_parent = v26;
operator delete(v28);
}
while ( v26 );
m_effectManager->m_unkMap770.m_header.m_left = p_m_header;
m_effectManager->m_unkMap770.m_header.m_parent = nullptr;
m_effectManager->m_unkMap770.m_header.m_right = p_m_header;
m_effectManager->m_unkMap770.m_nodecount = 0;
}