//
// GJBaseGameLayer::reAddToStickyGroup from 0x10013e200 to 0x10013e421 (545 bytes)
//
// 1 xrefs:
// > LevelEditorLayer::addSpecial @ 0x1000e02b7
//
// 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::reAddToStickyGroup(GJBaseGameLayer *a1, GameObject *a2)
{
__m128 v2; // xmm0
unsigned __int64 value; // r10
std::unordered_map *p_m_stickyGroups; // rbx
int m_uniqueID; // ecx
unsigned __int64 v6; // r14
unsigned __int64 v7; // r9
std::__hash_node_base, void *> *> *v8; // rax
std::__hash_node_base, void *> *>::__next_pointer next; // r11
unsigned __int64 v10; // r10
std::__hash_node_base, void *> *>::__next_pointer v11; // rax
unsigned __int64 v12; // rax
int v13; // r15d
cocos2d::CCObject *v14; // rax
int v15; // [rsp-3Ch] [rbp-3Ch] BYREF
_DWORD *v16[7]; // [rsp-38h] [rbp-38h] BYREF
value = a1->m_stickyGroups.__table_.__bucket_list_.__ptr_.__value_.__data_.__value_;
if ( !value )
return;
p_m_stickyGroups = &a1->m_stickyGroups;
m_uniqueID = a2->m_uniqueID;
v6 = (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 ( v6 <= 1 )
{
v7 = m_uniqueID & (value - 1);
v8 = p_m_stickyGroups->__table_.__bucket_list_.__ptr_.__value_[v7];
if ( !v8 )
return;
goto LABEL_9;
}
v7 = m_uniqueID;
if ( value <= m_uniqueID )
{
if ( !((value | m_uniqueID) >> 32) )
{
v7 = m_uniqueID % (unsigned int)value;
v8 = p_m_stickyGroups->__table_.__bucket_list_.__ptr_.__value_[v7];
if ( !v8 )
return;
goto LABEL_9;
}
v7 = m_uniqueID % value;
}
v8 = p_m_stickyGroups->__table_.__bucket_list_.__ptr_.__value_[v7];
if ( !v8 )
return;
LABEL_9:
next = v8->__next_;
if ( !v8->__next_ )
return;
if ( (unsigned int)v6 < 2 )
{
v10 = value - 1;
while ( 1 )
{
v11 = next[1].__next_;
if ( v11 == (std::__hash_node_base, void *> *>::__next_pointer)m_uniqueID )
{
if ( LODWORD(next[2].__next_) == m_uniqueID )
goto LABEL_27;
}
else if ( (v10 & (unsigned __int64)v11) != v7 )
{
return;
}
next = next->__next_;
if ( !next )
return;
}
}
while ( 1 )
{
v12 = (unsigned __int64)next[1].__next_;
if ( v12 == m_uniqueID )
break;
if ( v12 < value )
goto LABEL_23;
if ( (value | v12) >> 32 )
{
v12 %= value;
LABEL_23:
if ( v12 != v7 )
return;
goto LABEL_18;
}
if ( (unsigned int)v12 % (unsigned int)value != v7 )
return;
LABEL_18:
next = next->__next_;
if ( !next )
return;
}
if ( LODWORD(next[2].__next_) != m_uniqueID )
goto LABEL_18;
LABEL_27:
if ( !a2->m_linkedGroup )
{
v15 = a2->m_uniqueID;
v16[0] = &v15;
v13 = *((_DWORD *)sub_100105AF0((float *)&a1->m_stickyGroups, &v15, v2, (__int64)&unk_100816AE0, v16) + 5);
v14 = cocos2d::CCDictionary::objectForKey(a1->m_linkedGroupDict, v13);
if ( v14 )
{
sub_10071FCD0(v14, a2);
a2->m_linkedGroup = v13;
LODWORD(v16[0]) = a2->m_uniqueID;
sub_1000569A0(p_m_stickyGroups, (int *)v16);
}
}
}