//
// GJBaseGameLayer::addCustomEnterEffect from 0x10011e5c0 to 0x10011e9d8 (1048 bytes)
//
// 2 xrefs:
// > GJBaseGameLayer::updateActiveEnterEffect @ 0x10011e114
// > GJBaseGameLayer::updateActiveEnterEffect @ 0x10011e35d
//
// 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::addCustomEnterEffect(GJBaseGameLayer *a1, EnterEffectObject *a2, bool a3)
{
EnterEffectObject *v3; // r14
std::unordered_map> *p_m_enterEffectInstanceVectors; // rdi
__int64 v6; // rax
_QWORD *v7; // rbx
__int64 v8; // r15
int m_effectID; // ecx
__int64 v10; // rsi
__int64 v11; // rax
__int64 v12; // rdx
EnterEffectInstance *v13; // rdi
EnterEffectObject *m_gameObject; // rax
int m_targetGroupID; // r8d
int v16; // edx
unsigned int v17; // ecx
unsigned __int64 value; // r10
int v19; // r9d
std::unordered_map> *p_m_targetGroups; // r12
unsigned __int64 v21; // r13
unsigned __int64 v22; // rdi
std::__hash_node_base>, void *> *> *v23; // rax
std::__hash_node_base>, void *> *>::__next_pointer next; // r11
unsigned __int64 v25; // r10
unsigned __int64 v26; // rax
std::__hash_node_base>, void *> *>::__next_pointer v27; // rax
__int64 v28; // rax
int v29; // ecx
int m_centerGroupID; // eax
int m_controlID; // edx
unsigned __int64 v32; // r12
__int64 v33; // r12
EnterEffectObject *v34; // [rsp+18h] [rbp-58h] BYREF
unsigned int m_enterChannel; // [rsp+24h] [rbp-4Ch] BYREF
int v36; // [rsp+28h] [rbp-48h] BYREF
int v37; // [rsp+2Ch] [rbp-44h] BYREF
int v38; // [rsp+30h] [rbp-40h] BYREF
int v39; // [rsp+34h] [rbp-3Ch] BYREF
int v40; // [rsp+38h] [rbp-38h] BYREF
unsigned int v41; // [rsp+3Ch] [rbp-34h] BYREF
_QWORD v42[6]; // [rsp+40h] [rbp-30h] BYREF
v34 = a2;
m_enterChannel = a2->m_enterChannel;
if ( m_enterChannel > 0x64 )
return;
v3 = a2;
if ( a3 )
p_m_enterEffectInstanceVectors = &a1->m_gameState.m_enterEffectInstanceVectors;
else
p_m_enterEffectInstanceVectors = &a1->m_gameState.m_exitEffectInstanceVectors;
v42[0] = &m_enterChannel;
v6 = sub_100166C80(p_m_enterEffectInstanceVectors, &m_enterChannel, &unk_100816AE0, v42, &v41);
v7 = (_QWORD *)v6;
v8 = v6 + 24;
m_effectID = a2->m_effectID;
if ( m_effectID > 0 )
{
v10 = *(_QWORD *)(v6 + 24);
v11 = *(_QWORD *)(v6 + 32) - v10;
if ( v11 )
{
v12 = (0xEEEEEEEEEEEEEEEFLL * (v11 >> 4) == 0) - 0x1111111111111111LL * (v11 >> 4);
v13 = (EnterEffectInstance *)v7[3];
while ( 1 )
{
m_gameObject = v13->m_gameObject;
if ( m_gameObject->m_effectID == m_effectID )
break;
++v13;
if ( !--v12 )
goto LABEL_16;
}
if ( m_gameObject->m_uniqueID == v3->m_uniqueID
&& v13->m_targetID == v3->m_targetGroupID
&& v13->m_centerID == v3->m_centerGroupID )
{
EnterEffectInstance::loadValuesFromObject(v13, v13->m_gameObject);
return;
}
sub_10011ECC0(v8, v10 + 240, v12);
v3 = v34;
}
}
LABEL_16:
m_targetGroupID = v3->m_targetGroupID;
v16 = m_targetGroupID + 110000000;
if ( !v3->m_ignoreGroupParent )
v16 = m_targetGroupID + 100000000;
v17 = v16 + 1000000;
if ( !v3->m_ignoreLinkedObjects )
v17 = v16;
v41 = v17;
v38 = 0;
v39 = 0;
value = a1->m_targetGroups.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
v19 = 0;
if ( value )
{
p_m_targetGroups = &a1->m_targetGroups;
v21 = (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 ( v21 <= 1 )
{
v22 = (int)v17 & (value - 1);
v23 = p_m_targetGroups->__table_.__bucket_list_.__ptr_.__value_[v22];
if ( !v23 )
goto LABEL_48;
goto LABEL_28;
}
v22 = (int)v17;
if ( value <= (int)v17 )
{
if ( !((value | (int)v17) >> 32) )
{
v22 = v17 % (unsigned int)value;
v23 = p_m_targetGroups->__table_.__bucket_list_.__ptr_.__value_[v22];
if ( !v23 )
goto LABEL_48;
goto LABEL_28;
}
v22 = (int)v17 % value;
}
v23 = p_m_targetGroups->__table_.__bucket_list_.__ptr_.__value_[v22];
if ( !v23 )
goto LABEL_48;
LABEL_28:
next = v23->__next_;
if ( !v23->__next_ )
goto LABEL_48;
if ( (unsigned int)v21 < 2 )
{
v25 = value - 1;
while ( 1 )
{
v27 = next[1].__next_;
if ( v27 == (std::__hash_node_base>, void *> *>::__next_pointer)(int)v17 )
{
if ( LODWORD(next[2].__next_) == v17 )
goto LABEL_46;
}
else if ( (v25 & (unsigned __int64)v27) != v22 )
{
goto LABEL_48;
}
next = next->__next_;
if ( !next )
goto LABEL_48;
}
}
while ( 1 )
{
v26 = (unsigned __int64)next[1].__next_;
if ( v26 == v17 )
{
if ( LODWORD(next[2].__next_) == v17 )
{
LABEL_46:
v42[0] = &v41;
v28 = sub_100167180(p_m_targetGroups, &v41, &unk_100816AE0, v42, &v40);
v29 = *(_DWORD *)(v28 + 20);
v38 = v29;
v19 = *(_DWORD *)(v28 + 24);
v39 = v19;
m_targetGroupID = v3->m_targetGroupID;
goto LABEL_49;
}
}
else
{
if ( v26 < value )
goto LABEL_37;
if ( (value | v26) >> 32 )
{
v26 %= value;
LABEL_37:
if ( v26 != v22 )
goto LABEL_40;
goto LABEL_32;
}
if ( (unsigned int)v26 % (unsigned int)value != v22 )
{
LABEL_40:
v19 = 0;
break;
}
}
LABEL_32:
next = next->__next_;
if ( !next )
goto LABEL_40;
}
}
LABEL_48:
v29 = 0;
LABEL_49:
LODWORD(v42[0]) = m_targetGroupID;
m_centerGroupID = v3->m_centerGroupID;
v40 = m_centerGroupID;
v36 = 0;
m_controlID = v3->m_controlID;
v37 = m_controlID;
v32 = v7[4];
if ( v32 >= v7[5] )
{
v33 = sub_100167620(
v8,
(unsigned int)&v34,
(unsigned int)v42,
(unsigned int)&v40,
(unsigned int)&v36,
(unsigned int)&v38,
(__int64)&v39,
(__int64)&v37);
}
else
{
*(_OWORD *)(v32 + 8) = 0;
*(_QWORD *)v32 = v32 + 8;
*(_BYTE *)(v32 + 176) = 0;
*(_DWORD *)(v32 + 195) = 0;
*(_OWORD *)(v32 + 208) = 0;
*(_QWORD *)(v32 + 224) = 0;
*(_QWORD *)(v32 + 168) = v3;
*(_DWORD *)(v32 + 180) = m_targetGroupID;
*(_DWORD *)(v32 + 184) = m_centerGroupID;
*(_QWORD *)(v32 + 188) = 0;
*(_DWORD *)(v32 + 200) = v29;
*(_DWORD *)(v32 + 232) = m_controlID;
if ( v19 > 0 )
{
sub_100165950(v32 + 208, (unsigned int)v19);
v3 = *(EnterEffectObject **)(v32 + 168);
}
EnterEffectInstance::loadValuesFromObject((EnterEffectInstance *)v32, v3);
v33 = v32 + 240;
v7[4] = v33;
}
v7[4] = v33;
}