//
// GJEffectManager::updateCountForItem from 0x5cf314 to 0x5cf506 (498 bytes)
//
// 6 xrefs:
// > GJBaseGameLayer::activateProgressTrigger @ 0x5bd096
// > GJBaseGameLayer::addPickupTrigger @ 0x5bd172
// > GJBaseGameLayer::activateItemEditTrigger @ 0x5bd348
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x5bd4d2
// > GJBaseGameLayer::activatePersistentItemTrigger @ 0x5bd51a
// > GJEffectManager::addCountToItem @ 0x5cf546
//
// 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::updateCountForItem(GJEffectManager *this, int a2, int a3)
{
unsigned int v5; // r1
_DWORD *v6; // r8
int *v7; // r0
unsigned int v8; // r7
unsigned int v9; // r10
unsigned int v10; // r9
_DWORD *v11; // r2
_DWORD *i; // r4
unsigned int v13; // r0
int v14; // r1
char **v15; // r0
int v16; // r1
int (__fastcall *v17)(int, int); // r3
unsigned int v18; // r8
int v19; // r1
int v20; // r11
int v21; // r1
int v22; // r3
int v23; // r10
int v24; // r9
int j; // r3
int v26; // r1
int v27; // r0
int v28; // r1
int v29; // r0
int v30; // r9
int v31; // [sp+8h] [bp-34h]
int v32; // [sp+Ch] [bp-30h]
int v33; // [sp+10h] [bp-2Ch]
int v34; // [sp+18h] [bp-24h]
int v35; // [sp+18h] [bp-24h]
unsigned int v36[2]; // [sp+1Ch] [bp-20h] BYREF
int (__fastcall *v37)(int, int); // [sp+24h] [bp-18h] BYREF
char *v38[3]; // [sp+28h] [bp-14h] BYREF
v36[0] = a2;
if ( a2 > 9998 )
v5 = 9999;
else
v5 = a2 & ~(a2 >> 31);
v36[0] = v5;
v6 = GJEffectManager::countForItem(this, v5, 0x270Eu);
v7 = (int *)((char *)this + 460);
if ( a3 )
*std::unordered_map::operator[]((int)v7, v36) = a3;
else
std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::__erase_unique(
v7,
v36);
if ( std::__hash_table,std::__unordered_map_hasher,std::hash,true>,std::__unordered_map_equal,std::equal_to,true>,std::allocator>>::find(
(_DWORD *)this + 120,
v36) )
{
*std::unordered_map::operator[]((int)this + 480, v36) = a3;
}
v8 = *((_DWORD *)this + 86);
if ( v8 )
{
v9 = v8 - 1;
v10 = ((v8 - 1) & v8) != 0 ? v36[0] % v8 : v9 & v36[0];
v11 = *(_DWORD **)(*((_DWORD *)this + 85) + 4 * v10);
if ( v11 )
{
for ( i = (_DWORD *)*v11; ; i = (_DWORD *)*i )
{
if ( !i )
return;
v13 = i[1];
v14 = ((v8 - 1) & v8) != 0 ? v13 % v8 : v9 & v13;
if ( v14 != v10 )
return;
if ( i[2] == v36[0] )
break;
}
v15 = (char **)i[3];
v16 = i[4];
if ( (int)v6 > a3 )
v17 = (int (__fastcall *)(int, int))countSortDec;
else
v17 = (int (__fastcall *)(int, int))countSortAsc;
v18 = 0;
v37 = v17;
std::__sort(v15, v16, &v37);
while ( 1 )
{
do
{
v19 = i[3];
if ( v18 >= -1431655765 * ((i[4] - v19) >> 4) )
return;
v20 = v19 + 48 * v18;
if ( *(_BYTE *)v20 )
break;
v21 = *(_DWORD *)(v20 + 4);
if ( v21 == a3 )
break;
v22 = *(_DWORD *)(v20 + 8);
*(_DWORD *)(v20 + 4) = a3;
if ( v21 >= v22 )
{
if ( v21 <= v22 || a3 > v22 )
break;
}
else if ( a3 < v22 )
{
break;
}
v23 = *(unsigned __int8 *)(v20 + 16);
v31 = *(_DWORD *)(v20 + 12);
v32 = *(_DWORD *)(v20 + 20);
v33 = *(_DWORD *)(v20 + 24);
if ( *(_BYTE *)(v20 + 32) )
{
v30 = 0;
}
else
{
v24 = 48 * v18 + 48 + i[3];
for ( j = i[4]; ; j = v34 )
{
v26 = v24 - 48;
if ( v24 == j )
break;
v27 = v24 - 48;
v28 = v24;
v34 = j;
v24 += 48;
CountTriggerAction::operator=(v27, v28);
}
while ( 1 )
{
v29 = i[4];
if ( v26 == v29 )
break;
i[4] = v29 - 48;
v35 = v26;
std::__vector_base::~__vector_base((char **)(v29 - 12));
v26 = v35;
}
v30 = 1;
}
if ( *((_DWORD *)this + 66) )
{
std::vector::vector((int)v38, (const void **)(v20 + 36));
(***((void (__fastcall ****)(_DWORD, int, int, char **, int, int))this + 66))(
*((_DWORD *)this + 66),
v31,
v23,
v38,
v32,
v33);
std::__vector_base::~__vector_base(v38);
}
else
{
GJEffectManager::toggleGroup(this, v31, v23);
}
}
while ( v30 );
++v18;
}
}
}
}