//
// GJBaseGameLayer::processAdvancedFollowActions from 0x494570 to 0x494776 (518 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::processMoveActionsStep @ 0x496d00
//
// 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::processAdvancedFollowActions(GJBaseGameLayer *a1, float a2)
{
float v3; // s16
AdvancedFollowInstance *m_start; // r7
int *m_finish; // r6
int *v6; // r4
AdvancedFollowInstance *v7; // r6
AdvancedFollowInstance *i; // r4
GJBaseGameLayer *v9; // r0
AdvancedFollowInstance *v10; // r1
char m_started; // r2
AdvancedFollowInstance *v12; // lr
AdvancedFollowInstance *v13; // r4
int j; // r3
AdvancedFollowInstance *v15; // r3
int v16; // r2
AdvancedFollowInstance *k; // r12
AdvancedFollowInstance *v18; // r6
int m_group; // r1
int m_objectKey; // r2
int m_controlId; // r3
int m_relatedToGJGameStateUnkUint7; // r1
int v23; // r2
std::__detail::_Hash_node_base *M_nxt; // r4
std::_Hashtable
, std::allocator>, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits>::size_type M_bucket_count; // r11
std::_Hashtable, std::allocator>, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits>::__bucket_type *M_buckets; // r10
int v27; // r7
std::__detail::_Hash_node_base *m; // r6
std::__detail::_Hash_node_base *v29; // r2
int v30; // r1
std::_Hashtable, std::allocator>, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits>::__bucket_type *v31; // r3
int v32; // r1
std::__detail::_Hash_node_base *v33; // r6
v3 = a2 * 240.0;
if ( a1->m_gameState.m_unkBool27 )
{
m_start = a1->m_gameState.m_advanceFollowInstances.m_start;
m_finish = (int *)a1->m_gameState.m_advanceFollowInstances.m_finish;
if ( m_start != (AdvancedFollowInstance *)m_finish )
{
std::__introsort_loop<__gnu_cxx::__normal_iterator>,int,__gnu_cxx::__ops::_Iter_comp_iter>(
(int)a1->m_gameState.m_advanceFollowInstances.m_start,
m_finish,
2 * (31 - __clz(-1227133513 * (((char *)m_finish - (char *)m_start) >> 2))),
(int (__fastcall *)(int *, int *))compAdvFollowSort);
if ( (char *)m_finish - (char *)m_start < 476 )
{
std::__insertion_sort<__gnu_cxx::__normal_iterator>,__gnu_cxx::__ops::_Iter_comp_iter>(
(int)m_start,
m_finish,
(int (__fastcall *)(int, int))compAdvFollowSort);
}
else
{
v6 = (int *)&m_start[16];
std::__insertion_sort<__gnu_cxx::__normal_iterator>,__gnu_cxx::__ops::_Iter_comp_iter>(
(int)m_start,
(int *)&m_start[16],
(int (__fastcall *)(int, int))compAdvFollowSort);
while ( v6 != m_finish )
{
std::__unguarded_linear_insert<__gnu_cxx::__normal_iterator>,__gnu_cxx::__ops::_Val_comp_iter>(
v6,
(int (__fastcall *)(int *, int *))compAdvFollowSort);
v6 += 7;
}
}
}
a1->m_gameState.m_unkBool27 = 0;
}
v7 = a1->m_gameState.m_advanceFollowInstances.m_finish;
for ( i = a1->m_gameState.m_advanceFollowInstances.m_start; i != v7; ++i )
{
if ( i->m_finished )
{
if ( !i->m_doStart )
continue;
v9 = a1;
v10 = i;
m_started = 1;
i->m_doStart = 0;
}
else
{
v9 = a1;
v10 = i;
m_started = i->m_started;
}
GJBaseGameLayer::processAdvancedFollowAction(v9, v10, m_started, v3);
}
v12 = a1->m_gameState.m_advanceFollowInstances.m_finish;
v13 = a1->m_gameState.m_advanceFollowInstances.m_start;
for ( j = (-1227133513 * (((char *)v12 - (char *)v13) >> 2)) >> 2; j > 0; --j )
{
if ( v13->m_started )
goto LABEL_37;
if ( v13[1].m_started )
{
++v13;
goto LABEL_37;
}
if ( v13[2].m_started )
{
v13 += 2;
goto LABEL_37;
}
if ( v13[3].m_started )
{
v13 += 3;
goto LABEL_37;
}
v13 += 4;
}
v15 = v13;
v16 = -1227133513 * (((char *)v12 - (char *)v13) >> 2);
switch ( v16 )
{
case 2:
LABEL_33:
if ( !v15->m_started )
{
++v15;
LABEL_35:
if ( !v15->m_started )
goto LABEL_44;
}
v13 = v15;
break;
case 3:
if ( !v13->m_started )
{
v15 = v13 + 1;
goto LABEL_33;
}
break;
case 1:
goto LABEL_35;
default:
goto LABEL_44;
}
LABEL_37:
if ( v13 != v12 )
{
for ( k = v13 + 1; k != v12; ++k )
{
if ( !k->m_started )
{
v18 = v13;
m_group = k->m_group;
m_objectKey = k->m_objectKey;
m_controlId = k->m_controlId;
++v13;
v18->m_gameObject = k->m_gameObject;
v18->m_group = m_group;
v18->m_objectKey = m_objectKey;
v18->m_controlId = m_controlId;
v18 = (AdvancedFollowInstance *)((char *)v18 + 16);
m_relatedToGJGameStateUnkUint7 = k->m_relatedToGJGameStateUnkUint7;
v23 = *(_DWORD *)&k->m_finished;
v18->m_gameObject = (AdvancedFollowTriggerObject *)k->m_otherObjectKey;
v18->m_group = m_relatedToGJGameStateUnkUint7;
v18->m_objectKey = v23;
}
}
v12 = v13;
}
LABEL_44:
M_nxt = a1->m_gameState.m_gameObjectPhysics._M_h._M_before_begin._M_nxt;
if ( v12 != a1->m_gameState.m_advanceFollowInstances.m_finish )
a1->m_gameState.m_advanceFollowInstances.m_finish = v12;
while ( M_nxt )
{
if ( (int)M_nxt[10]._M_nxt < (signed int)a1->m_gameState.m_commandIndex )
{
M_bucket_count = a1->m_gameState.m_gameObjectPhysics._M_h._M_bucket_count;
M_buckets = a1->m_gameState.m_gameObjectPhysics._M_h._M_buckets;
v27 = (unsigned int)M_nxt[1]._M_nxt % M_bucket_count;
for ( m = M_buckets[v27]; m->_M_nxt != M_nxt; m = m->_M_nxt )
;
if ( m == M_buckets[(unsigned int)M_nxt[1]._M_nxt % a1->m_gameState.m_gameObjectPhysics._M_h._M_bucket_count] )
{
v29 = M_nxt->_M_nxt;
if ( !M_nxt->_M_nxt )
goto LABEL_55;
v30 = (unsigned int)v29[1]._M_nxt % M_bucket_count;
if ( v30 != v27 )
{
v29 = M_nxt->_M_nxt;
M_buckets[v30] = m;
LABEL_55:
v31 = a1->m_gameState.m_gameObjectPhysics._M_h._M_buckets;
if ( v31[v27] == &a1->m_gameState.m_gameObjectPhysics._M_h._M_before_begin )
a1->m_gameState.m_gameObjectPhysics._M_h._M_before_begin._M_nxt = v29;
v31[v27] = nullptr;
}
}
else if ( M_nxt->_M_nxt )
{
v32 = (unsigned int)M_nxt->_M_nxt[1]._M_nxt % M_bucket_count;
if ( v32 != v27 )
M_buckets[v32] = m;
}
m->_M_nxt = M_nxt->_M_nxt;
v33 = M_nxt->_M_nxt;
operator delete(M_nxt);
M_nxt = v33;
--a1->m_gameState.m_gameObjectPhysics._M_h._M_element_count;
continue;
}
M_nxt = M_nxt->_M_nxt;
}
}