//
// GJBaseGameLayer::triggerAdvancedFollowCommand from 0x1001ef750 to 0x1001ef928 (472 bytes)
//
// 1 xrefs:
// > EffectGameObject::triggerObject @ 0x100385cac
//
// 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 GJBaseGameLayer::triggerAdvancedFollowCommand(GJBaseGameLayer *a1, AdvancedFollowTriggerObject *a2)
{
int m_centerGroupID; // w21
std::__vector_base
::pointer begin; // x9
std::__vector_base::pointer end; // x8
char v7; // w11
std::__vector_base::pointer v8; // x10
int v10; // w11
int m_unkUint8; // w10
int m_controlID; // w22
AdvancedFollowInstance *value; // x11
int v14; // w9
AdvancedFollowInstance *v15; // x21
__int64 v16; // x23
unsigned __int64 v17; // x8
__int64 v18; // x9
unsigned __int64 v19; // x1
char *v20; // x0
char *v21; // x8
AdvancedFollowInstance *v22; // x23
int m_targetGroupID; // w9
std::__vector_base::pointer v24; // x1
char *v25; // x2
AdvancedFollowInstance *v26; // x20
std::__vector_base::pointer v27; // x0
if ( a2->m_targetPlayer1 )
{
m_centerGroupID = -1;
}
else if ( a2->m_targetPlayer2 )
{
m_centerGroupID = -2;
}
else if ( a2->m_followCPP )
{
m_centerGroupID = -3;
}
else
{
m_centerGroupID = a2->m_centerGroupID;
}
begin = a1->m_gameState.m_advanceFollowInstances.__begin_;
end = a1->m_gameState.m_advanceFollowInstances.__end_;
if ( begin != end )
{
v7 = 0;
v8 = a1->m_gameState.m_advanceFollowInstances.__begin_;
LABEL_10:
++v8;
do
{
if ( v8[-1].m_gameObject == a2
&& v8[-1].m_group == a2->m_targetGroupID
&& v8[-1].m_objectKey == m_centerGroupID
&& v8[-1].m_controlId == a2->m_controlID )
{
*(_WORD *)&v8[-1].m_finished = 0;
v10 = a1->m_gameState.m_unkUint8 + 1;
a1->m_gameState.m_unkUint8 = v10;
v8[-1].m_relatedToGJGameStateUnkUint7 = v10;
v7 = 1;
if ( v8 != end )
goto LABEL_10;
goto LABEL_35;
}
}
while ( v8++ != end );
if ( (v7 & 1) != 0 )
goto LABEL_35;
}
m_unkUint8 = a1->m_gameState.m_unkUint8 + 1;
a1->m_gameState.m_unkUint8 = m_unkUint8;
m_controlID = a2->m_controlID;
value = a1->m_gameState.m_advanceFollowInstances.__end_cap_.__value_;
if ( end >= value )
{
v16 = end - begin;
v17 = v16 + 1;
if ( (unsigned __int64)(v16 + 1) >> 59 )
sub_10000A5F8();
v18 = (char *)value - (char *)begin;
if ( v18 >> 4 > v17 )
v17 = v18 >> 4;
if ( (unsigned __int64)v18 >= 0x7FFFFFFFFFFFFFE0LL )
v19 = 0x7FFFFFFFFFFFFFFLL;
else
v19 = v17;
if ( v19 )
{
v20 = (char *)sub_100125E78((__int64)&a1->m_gameState.m_advanceFollowInstances, v19);
m_unkUint8 = a1->m_gameState.m_unkUint8;
}
else
{
v20 = nullptr;
}
v21 = &v20[32 * v16];
v22 = (AdvancedFollowInstance *)&v20[32 * v19];
m_targetGroupID = a2->m_targetGroupID;
*(_QWORD *)v21 = a2;
*((_DWORD *)v21 + 2) = m_targetGroupID;
*((_DWORD *)v21 + 3) = m_centerGroupID;
*((_DWORD *)v21 + 4) = m_controlID;
*((_DWORD *)v21 + 5) = 0;
*((_DWORD *)v21 + 6) = m_unkUint8;
*((_DWORD *)v21 + 7) = 0;
v15 = (AdvancedFollowInstance *)(v21 + 32);
v24 = a1->m_gameState.m_advanceFollowInstances.__begin_;
v25 = (char *)((char *)a1->m_gameState.m_advanceFollowInstances.__end_ - (char *)v24);
v26 = (AdvancedFollowInstance *)(v21 - v25);
memcpy((void *)(v21 - v25), v24, (size_t)v25);
v27 = a1->m_gameState.m_advanceFollowInstances.__begin_;
a1->m_gameState.m_advanceFollowInstances.__begin_ = v26;
a1->m_gameState.m_advanceFollowInstances.__end_ = v15;
a1->m_gameState.m_advanceFollowInstances.__end_cap_.__value_ = v22;
if ( v27 )
operator delete(v27);
}
else
{
v14 = a2->m_targetGroupID;
end->m_gameObject = a2;
end->m_group = v14;
end->m_objectKey = m_centerGroupID;
end->m_controlId = m_controlID;
end->m_otherObjectKey = 0;
end->m_relatedToGJGameStateUnkUint7 = m_unkUint8;
*(_DWORD *)&end->m_finished = 0;
v15 = end + 1;
}
a1->m_gameState.m_advanceFollowInstances.__end_ = v15;
LABEL_35:
a1->m_gameState.m_unkBool27 = 1;
}