//
// GJEffectManager::toggleGroup from 0x5ced8c to 0x5cef56 (458 bytes)
//
// 5 xrefs:
// > LevelEditorLayer::toggleGroupPreview @ 0x461f74
// > GJBaseGameLayer::toggleGroup @ 0x590946
// > GJEffectManager::handleObjectCollision @ 0x5ceff0
// > GJEffectManager::playerButton @ 0x5cf2d6
// > GJEffectManager::updateCountForItem @ 0x5cf4d8
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 11:54:03 +0000
//
void __fastcall GJEffectManager::toggleGroup(GJEffectManager *this, int a2, int a3)
{
int v3; // r6
int v5; // r0
unsigned int v6; // r1
unsigned int v7; // r4
int v8; // r3
int v9; // r1
unsigned int v10; // r4
unsigned int v11; // r8
unsigned int v12; // r11
_DWORD *v13; // r3
_DWORD *i; // r9
unsigned int v15; // r0
int v16; // r1
float v17; // s13
float v18; // s15
bool v19; // r6
unsigned int v20; // r6
unsigned int v21; // r1
void **v22; // r3
unsigned int v23; // r0
int v24; // r1
unsigned int v25; // [sp+4h] [bp-18h] BYREF
void *v26; // [sp+8h] [bp-14h] BYREF
v25 = a2;
v5 = *((_DWORD *)this + 152);
if ( a2 > 9998 )
v6 = 9999;
else
v6 = a2 & ~(a2 >> 31);
v25 = v6;
v7 = v6 >> 5;
v8 = 1 << (v6 & 0x1F);
v9 = *(_DWORD *)(v5 + 4 * (v6 >> 5));
if ( a3 )
{
*(_DWORD *)(v5 + 4 * v7) = v8 | v9;
std::__hash_table,std::equal_to,std::allocator>::__erase_unique(
(int *)this + 155,
&v25);
return;
}
*(_DWORD *)(v5 + 4 * v7) = v9 & ~v8;
v10 = *((_DWORD *)this + 156);
v11 = v25;
if ( v10 )
{
v12 = v10 - 1;
v3 = ((v10 - 1) & v10) != 0 ? v25 % v10 : v12 & v25;
v13 = *(_DWORD **)(*((_DWORD *)this + 155) + 4 * v3);
if ( v13 )
{
for ( i = (_DWORD *)*v13; i; i = (_DWORD *)*i )
{
v15 = i[1];
v16 = ((v10 - 1) & v10) != 0 ? v15 % v10 : v12 & v15;
if ( v16 != v3 )
break;
if ( i[2] == v25 )
return;
}
}
}
std::__hash_table,std::equal_to,std::allocator>::__construct_node_hash(
(int)&v26,
(int)this + 620,
v25,
&v25);
v17 = *((float *)this + 159);
v18 = (float)(unsigned int)(*((_DWORD *)this + 158) + 1);
if ( v18 > (float)((float)v10 * v17) )
{
v19 = v10 > 2 && ((v10 - 1) & v10) == 0;
goto LABEL_20;
}
if ( !v10 )
{
v19 = 0;
LABEL_20:
v20 = 2 * v10 + !v19;
v21 = (unsigned int)ceilf(v18 / v17);
if ( v21 < v20 )
v21 = v20;
std::__hash_table,std::equal_to,std::allocator>::rehash((int)this + 620, v21);
v10 = *((_DWORD *)this + 156);
if ( ((v10 - 1) & v10) != 0 )
v3 = v11 % v10;
else
v3 = (v10 - 1) & v11;
}
v22 = *(void ***)(*((_DWORD *)this + 155) + 4 * v3);
if ( v22 )
{
*(_DWORD *)v26 = *v22;
*v22 = v26;
}
else
{
*(_DWORD *)v26 = *((_DWORD *)this + 157);
*((_DWORD *)this + 157) = v26;
*(_DWORD *)(*((_DWORD *)this + 155) + 4 * v3) = (char *)this + 628;
if ( *(_DWORD *)v26 )
{
v23 = *(_DWORD *)(*(_DWORD *)v26 + 4);
if ( ((v10 - 1) & v10) != 0 )
v24 = v23 % v10;
else
v24 = (v10 - 1) & v23;
*(_DWORD *)(*((_DWORD *)this + 155) + 4 * v24) = v26;
}
}
++*((_DWORD *)this + 158);
}