//
// GJBaseGameLayer::triggerAdvancedFollowEditCommand from 0x100147d80 to 0x100148483 (1795 bytes)
//
// 1 xrefs:
// > EffectGameObject::triggerObject @ 0x1001b9813
//
// 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::triggerAdvancedFollowEditCommand(
GJBaseGameLayer *m_groupDict,
AdvancedFollowEditObject *a2)
{
GJBaseGameLayer *v2; // rbx
int m_objectID; // eax
int v4; // ecx
std::__vector_base
::pointer v5; // rdx
std::__vector_base::pointer v6; // rax
AdvancedFollowTriggerObject *m_gameObject; // rax
int v8; // ecx
int m_group; // edx
unsigned __int64 v10; // rsi
int v11; // ecx
unsigned __int64 value; // r8
int v13; // r13d
__int64 v14; // rdx
unsigned __int64 v15; // r10
__int64 **v16; // rax
__int64 *v17; // r9
unsigned __int64 v18; // r8
unsigned __int64 v19; // rax
__int64 v20; // rax
char v21; // r14
bool v22; // zf
__int64 v23; // rax
intptr_t v24; // r13
cocos2d::CCObject *v25; // r12
unsigned int *v26; // rax
unsigned __int64 v27; // r12
unsigned __int64 v28; // r13
unsigned __int64 v29; // rcx
unsigned __int64 v30; // r9
std::__hash_node_base, void *> *> *v31; // rax
std::__hash_node_base, void *> *>::__next_pointer next; // r8
std::__hash_node_base, void *> *>::__next_pointer v33; // rax
unsigned __int64 v34; // rax
int m_centerGroupID; // r12d
int m_targetGroupID; // eax
std::__vector_base::pointer begin; // rcx
std::__vector_base::pointer end; // rdx
int v39; // eax
intptr_t v40; // r15
cocos2d::CCArray *v41; // rdx
cocos2d::CCArray *v42; // r12
int v43; // ecx
intptr_t v44; // r14
cocos2d::CCArray *v45; // r15
cocos2d::ccArray *data; // rax
__int64 num; // rcx
cocos2d::CCObject **arr; // rax
unsigned __int64 v49; // rcx
AdvancedFollowTriggerObject *v50; // rdx
std::__vector_base::pointer v51; // rsi
std::__vector_base::pointer v52; // rdi
int *v53; // [rsp+8h] [rbp-68h] BYREF
__int64 v54; // [rsp+10h] [rbp-60h]
AdvancedFollowInstance *v55; // [rsp+18h] [rbp-58h]
std::__vector_base::pointer v56; // [rsp+20h] [rbp-50h]
GJBaseGameLayer *p_m_targetGroups; // [rsp+28h] [rbp-48h]
int v58; // [rsp+30h] [rbp-40h] BYREF
int v59; // [rsp+34h] [rbp-3Ch]
int v60; // [rsp+38h] [rbp-38h]
char v61; // [rsp+3Fh] [rbp-31h] BYREF
AdvancedFollowEditObject *v62; // [rsp+40h] [rbp-30h]
v2 = m_groupDict;
v62 = a2;
m_objectID = a2->m_objectID;
if ( m_objectID == 3661 )
{
m_centerGroupID = -1;
if ( v62->m_targetPlayer1
|| (m_centerGroupID = -2, v62->m_targetPlayer2)
|| (m_centerGroupID = -3, v62->m_followCPP)
|| (m_centerGroupID = v62->m_centerGroupID) != 0 )
{
m_targetGroupID = v62->m_targetGroupID;
if ( v62->m_targetControlID )
{
begin = m_groupDict->m_gameState.m_advanceFollowInstances.__begin_;
end = m_groupDict->m_gameState.m_advanceFollowInstances.__end_;
while ( begin != end )
{
if ( begin->m_controlId == m_targetGroupID )
begin->m_objectKey = m_centerGroupID;
++begin;
}
}
else
{
v43 = 9999;
if ( m_targetGroupID < 9999 )
v43 = v62->m_targetGroupID;
v44 = 0;
if ( v43 > 0 )
v44 = (unsigned int)v43;
v45 = m_groupDict->m_groups.__begin_[v44];
if ( v45
|| (v45 = (cocos2d::CCArray *)sub_10071F9E0(m_groupDict, a2),
cocos2d::CCDictionary::setObject(m_groupDict->m_groupDict, v45, v44),
(m_groupDict->m_groups.__begin_[v44] = v45) != nullptr) )
{
data = v45->data;
num = data->num;
if ( data->num )
{
arr = data->arr;
v49 = (unsigned __int64)&arr[num - 1];
do
{
v50 = (AdvancedFollowTriggerObject *)*arr;
if ( !*arr )
break;
if ( v50->m_objectID == 3016 )
{
v51 = v2->m_gameState.m_advanceFollowInstances.__begin_;
v52 = v2->m_gameState.m_advanceFollowInstances.__end_;
while ( v51 != v52 )
{
if ( v51->m_gameObject == v50 )
v51->m_objectKey = m_centerGroupID;
++v51;
}
}
++arr;
}
while ( (unsigned __int64)arr <= v49 );
}
}
}
}
}
else if ( m_objectID == 3660 )
{
v4 = v62->m_targetGroupID;
if ( v62->m_targetControlID )
{
v5 = m_groupDict->m_gameState.m_advanceFollowInstances.__begin_;
v6 = m_groupDict->m_gameState.m_advanceFollowInstances.__end_;
if ( v5 != v6 )
{
p_m_targetGroups = (GJBaseGameLayer *)&m_groupDict->m_targetGroups;
v60 = v4;
v55 = v6;
do
{
if ( v5->m_controlId != v4 )
goto LABEL_7;
m_gameObject = v5->m_gameObject;
v8 = 100000000;
if ( v5->m_gameObject->m_ignoreGroupParent )
v8 = 110000000;
v56 = v5;
m_group = v5->m_group;
v10 = (unsigned int)(v8 + m_group);
v11 = v8 + m_group + 1000000;
if ( !m_gameObject->m_ignoreLinkedObjects )
v11 = v10;
v58 = v11;
value = v2->m_targetGroups.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
v13 = 0;
v14 = 0;
if ( value )
{
v10 = v11;
v15 = (0x101010101010101LL
* ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)
+ ((((value - ((value >> 1) & 0x5555555555555555LL)) & 0x3333333333333333LL)
+ (((value - ((value >> 1) & 0x5555555555555555LL)) >> 2) & 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v15 > 1 )
{
m_groupDict = (GJBaseGameLayer *)v11;
if ( value <= v11 )
{
if ( (value | v11) >> 32 )
m_groupDict = (GJBaseGameLayer *)(v11 % value);
else
m_groupDict = (GJBaseGameLayer *)(v11 % (unsigned int)value);
}
}
else
{
m_groupDict = (GJBaseGameLayer *)(v11 & (value - 1));
}
v16 = *((__int64 ***)&p_m_targetGroups->copyWithZone + (_QWORD)m_groupDict);
v14 = 0;
if ( v16 )
{
v17 = *v16;
v14 = 0;
if ( *v16 )
{
if ( (unsigned int)v15 < 2 )
{
v18 = value - 1;
while ( 1 )
{
v20 = v17[1];
if ( v20 == v11 )
{
if ( *((_DWORD *)v17 + 4) == v11 )
goto LABEL_39;
}
else if ( (GJBaseGameLayer *)(v18 & v20) != m_groupDict )
{
goto LABEL_38;
}
v17 = (__int64 *)*v17;
if ( !v17 )
goto LABEL_38;
}
}
while ( 1 )
{
v19 = v17[1];
if ( v19 == v11 )
{
if ( *((_DWORD *)v17 + 4) == v11 )
{
LABEL_39:
v10 = (unsigned __int64)&v58;
v53 = &v58;
m_groupDict = p_m_targetGroups;
v14 = *(unsigned int *)(sub_100167180(p_m_targetGroups, &v58, &unk_100816AE0, &v53, &v61) + 20);
break;
}
}
else
{
if ( v19 < value )
goto LABEL_30;
if ( (value | v19) >> 32 )
{
v19 %= value;
LABEL_30:
if ( (GJBaseGameLayer *)v19 != m_groupDict )
goto LABEL_38;
goto LABEL_25;
}
if ( (GJBaseGameLayer *)((unsigned int)v19 % (unsigned int)value) != m_groupDict )
{
LABEL_38:
v14 = 0;
break;
}
}
LABEL_25:
v17 = (__int64 *)*v17;
if ( !v17 )
goto LABEL_38;
}
}
}
}
v59 = v14 - 1;
v21 = 1;
v54 = v14;
do
{
if ( (int)v14 <= 0 )
{
v24 = (unsigned int)v56->m_group;
if ( (int)v24 >= 9999 )
v24 = 9999;
if ( (int)v24 <= 0 )
v24 = 0;
v23 = (__int64)v2->m_groups.__begin_[v24];
if ( v23
|| (v25 = (cocos2d::CCObject *)sub_10071F9E0(m_groupDict, v10),
m_groupDict = (GJBaseGameLayer *)v2->m_groupDict,
v10 = (unsigned __int64)v25,
cocos2d::CCDictionary::setObject((cocos2d::CCDictionary *)m_groupDict, v25, v24),
v23 = (__int64)v25,
(v2->m_groups.__begin_[v24] = (cocos2d::CCArray *)v25) != nullptr) )
{
LABEL_51:
v26 = *(unsigned int **)(v23 + 56);
if ( !*v26 )
goto LABEL_41;
v27 = *((_QWORD *)v26 + 2);
v28 = v27 + 8LL * *v26 - 8;
while ( *(_QWORD *)v27 )
{
m_groupDict = (GJBaseGameLayer *)v2->m_gameState.m_gameObjectPhysics.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
if ( m_groupDict )
{
v29 = *(int *)(*(_QWORD *)v27 + 916LL);
v30 = (0x101010101010101LL
* (((((unsigned __int64)m_groupDict
- (((unsigned __int64)m_groupDict >> 1) & 0x5555555555555555LL))
& 0x3333333333333333LL)
+ ((((unsigned __int64)m_groupDict
- (((unsigned __int64)m_groupDict >> 1) & 0x5555555555555555LL)) >> 2)
& 0x3333333333333333LL)
+ (((((unsigned __int64)m_groupDict
- (((unsigned __int64)m_groupDict >> 1) & 0x5555555555555555LL))
& 0x3333333333333333LL)
+ ((((unsigned __int64)m_groupDict
- (((unsigned __int64)m_groupDict >> 1) & 0x5555555555555555LL)) >> 2)
& 0x3333333333333333LL)) >> 4))
& 0xF0F0F0F0F0F0F0FLL)) >> 56;
if ( v30 <= 1 )
{
v10 = v29 & (unsigned __int64)(&m_groupDict[-1].m_clickOnSteps + 5);
v31 = v2->m_gameState.m_gameObjectPhysics.__table_.__bucket_list_.__ptr_.__value_[v10];
if ( !v31 )
goto LABEL_54;
LABEL_64:
next = v31->__next_;
if ( !v31->__next_ )
goto LABEL_54;
if ( (unsigned int)v30 < 2 )
{
m_groupDict = (GJBaseGameLayer *)((char *)m_groupDict - 1);
while ( 1 )
{
v33 = next[1].__next_;
if ( v33 == (std::__hash_node_base, void *> *>::__next_pointer)v29 )
{
if ( LODWORD(next[2].__next_) == (_DWORD)v29 )
goto LABEL_53;
}
else if ( ((unsigned __int64)m_groupDict & (unsigned __int64)v33) != v10 )
{
goto LABEL_54;
}
next = next->__next_;
if ( !next )
goto LABEL_54;
}
}
while ( 2 )
{
v34 = (unsigned __int64)next[1].__next_;
if ( v34 == v29 )
{
if ( LODWORD(next[2].__next_) == (_DWORD)v29 )
{
LABEL_53:
m_groupDict = v2;
v10 = (unsigned __int64)v62;
GJBaseGameLayer::modifyObjectPhysics(v2, v62, (GameObjectPhysics *)&next[3]);
goto LABEL_54;
}
}
else if ( v34 < (unsigned __int64)m_groupDict )
{
LABEL_78:
if ( v34 != v10 )
goto LABEL_54;
}
else
{
if ( ((unsigned __int64)m_groupDict | v34) >> 32 )
{
v34 %= (unsigned __int64)m_groupDict;
goto LABEL_78;
}
if ( (unsigned int)v34 % (unsigned int)m_groupDict != v10 )
goto LABEL_54;
}
next = next->__next_;
if ( !next )
goto LABEL_54;
continue;
}
}
v10 = *(int *)(*(_QWORD *)v27 + 916LL);
if ( (unsigned __int64)m_groupDict > v29 )
{
LABEL_63:
v31 = v2->m_gameState.m_gameObjectPhysics.__table_.__bucket_list_.__ptr_.__value_[v10];
if ( !v31 )
goto LABEL_54;
goto LABEL_64;
}
if ( ((unsigned __int64)m_groupDict | v29) >> 32 )
{
v10 = v29 % (unsigned __int64)m_groupDict;
goto LABEL_63;
}
v10 = (unsigned int)v29 % (unsigned int)m_groupDict;
v31 = v2->m_gameState.m_gameObjectPhysics.__table_.__bucket_list_.__ptr_.__value_[v10];
if ( v31 )
goto LABEL_64;
}
LABEL_54:
v27 += 8LL;
if ( v27 > v28 )
break;
continue;
}
}
}
else
{
m_groupDict = (GJBaseGameLayer *)v2->m_targetGroupsArray;
v10 = (unsigned int)(v59 + v13);
v23 = sub_1007200C0(m_groupDict, v10);
if ( v23 )
goto LABEL_51;
}
LABEL_41:
LODWORD(v14) = v54;
v13 = 1;
v22 = ((unsigned __int8)v21 & ((int)v54 > 0)) == 0;
v21 = 0;
}
while ( !v22 );
v4 = v60;
v5 = v56;
v6 = v55;
LABEL_7:
++v5;
}
while ( v5 != v6 );
}
}
else
{
v39 = 9999;
if ( v4 < 9999 )
v39 = v62->m_targetGroupID;
v40 = 0;
if ( v39 > 0 )
v40 = (unsigned int)v39;
v41 = m_groupDict->m_groups.__begin_[v40];
if ( !v41 )
{
v42 = (cocos2d::CCArray *)sub_10071F9E0(m_groupDict, a2);
cocos2d::CCDictionary::setObject(m_groupDict->m_groupDict, v42, v40);
v41 = v42;
m_groupDict->m_groups.__begin_[v40] = v42;
}
GJBaseGameLayer::modifyGroupPhysics(m_groupDict, v62, v41);
}
}
}