//
// GJEffectManager::runCountTrigger from 0x4a3a80 to 0x4a3c28 (424 bytes)
//
// 1 xrefs:
// > CountTriggerGameObject::triggerObject @ 0x3ee8e2
//
// 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 GJEffectManager::runCountTrigger(
GJEffectManager *a1,
int a2,
int a3,
bool a4,
int a5,
bool a6,
std::vector *const a7,
int a8,
int a9)
{
std::unordered_map> *p_m_countTriggerActions; // r6
std::_Hashtable>, std::allocator>>, std::__detail::_Select1st, std::equal_to, std::hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits>::size_type v14; // r4
_DWORD **v15; // r0
CountTriggerAction **v16; // r4
int v17; // r0
CountTriggerAction *v18; // r3
int v19; // r11
int v20; // r5
int v21; // r3
int v22; // r1
bool v23; // cf
unsigned int v24; // r3
CountTriggerAction *v25; // r6
int v26; // r1
bool *v27; // r3
CountTriggerAction *v28; // r7
CountTriggerAction *v29; // r9
CountTriggerAction *v30; // r0
CountTriggerAction *v31; // r8
CountTriggerAction *v32; // r7
CountTriggerAction *v33; // r9
void **p_m_start; // r0
_DWORD *v35; // r0
_DWORD v36[2]; // [sp+4h] [bp-4h] BYREF
v36[1] = a3;
p_m_countTriggerActions = &a1->m_countTriggerActions;
v36[0] = a2;
v14 = a2 % a1->m_countTriggerActions._M_h._M_bucket_count;
v15 = sub_498DCA(&a1->m_countTriggerActions._M_h._M_buckets, v14, v36);
if ( v15 && *v15 )
{
v16 = (CountTriggerAction **)(*v15 + 2);
}
else
{
v35 = (_DWORD *)operator new(0x14u);
*v35 = 0;
v35[1] = a2;
v35[2] = 0;
v35[3] = 0;
v35[4] = 0;
v16 = (CountTriggerAction **)(std::_Hashtable>,std::allocator>>,std::__detail::_Select1st,std::equal_to,std::hash,std::__detail::_Mod_range_hashing,std::__detail::_Default_ranged_hash,std::__detail::_Prime_rehash_policy,std::__detail::_Hashtable_traits>::_M_insert_unique_node(
(int)p_m_countTriggerActions,
v14,
a2,
v35)
+ 2);
}
v17 = GJEffectManager::countForItem(a1, a2);
v18 = v16[1];
v19 = v17;
if ( v18 == v16[2] )
{
v20 = 89478485;
v21 = -1431655765 * (((char *)v18 - (char *)*v16) >> 4);
if ( v21 )
v22 = v21;
else
v22 = 1;
v23 = __CFADD__(v22, v21);
v24 = v22 + v21;
if ( v23 || v24 > 0x5555555 || (v20 = v24) != 0 )
v25 = (CountTriggerAction *)operator new(48 * v20);
else
v25 = nullptr;
v26 = (char *)v16[1] - (char *)*v16;
v27 = &v25->m_disabled + v26;
if ( (char *)v25 + v26 )
{
*(&v25->m_disabled + v26) = 0;
*((_DWORD *)v27 + 7) = a2;
*((_DWORD *)v27 + 3) = a5;
*((_DWORD *)v27 + 9) = 0;
*((_DWORD *)v27 + 10) = 0;
*((_DWORD *)v27 + 5) = a8;
*((_DWORD *)v27 + 11) = 0;
*((_DWORD *)v27 + 2) = a3;
v27[16] = a6;
v27[32] = a4;
*((_DWORD *)v27 + 1) = v19;
*((_DWORD *)v27 + 6) = a9;
std::vector::operator=((void **)v27 + 9, (void **)&a7->m_start);
}
v28 = *v16;
v29 = v16[1];
v30 = v25;
while ( 1 )
{
v31 = v30 + 1;
if ( v28 == v29 )
break;
if ( v30 )
CountTriggerAction::CountTriggerAction(v30);
v30 = v31;
++v28;
}
v32 = *v16;
v33 = v16[1];
while ( v32 != v33 )
{
p_m_start = (void **)&v32->m_remapKeys.m_start;
++v32;
std::_Vector_base::~_Vector_base(p_m_start);
}
if ( *v16 )
operator delete(*v16);
*v16 = v25;
v16[1] = v31;
v16[2] = &v25[v20];
}
else
{
if ( v18 )
{
v18->m_previousCount = v17;
v18->m_disabled = 0;
v18->m_targetGroupID = a5;
v18->m_remapKeys.m_start = nullptr;
v18->m_remapKeys.m_finish = nullptr;
v18->m_triggerUniqueID = a8;
v18->m_remapKeys.m_reserveEnd = nullptr;
v18->m_targetCount = a3;
v18->m_activateGroup = a6;
v18->m_multiActivate = a4;
v18->m_itemID = a2;
v18->m_controlID = a9;
std::vector::operator=((void **)&v18->m_remapKeys.m_start, (void **)&a7->m_start);
}
++v16[1];
}
}