//
// GJBaseGameLayer::stopSFXTrigger from 0x100136940 to 0x100136aeb (427 bytes)
//
// 1 xrefs:
// > GJBaseGameLayer::controlTriggersInGroup @ 0x100136536
//
// 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::stopSFXTrigger(GJBaseGameLayer *a1, SFXTriggerGameObject *a2)
{
__int64 v3; // rax
int *v4; // r15
int *v5; // rbx
std::__compressed_pair *>> *p_pair1; // r14
FMODAudioEngine *v7; // rax
std::__tree_end_node *>::pointer left; // rdi
int v9; // eax
std::__compressed_pair *>> *v10; // r13
std::__tree_end_node *>::pointer v11; // rcx
int v12; // edx
int v13; // ecx
std::__tree_end_node *> *v14; // rcx
std::__compressed_pair *>> *v15; // rdx
std::__tree_end_node *> *v16; // rax
bool v17; // zf
__int64 v18; // rax
std::unordered_map> *p_m_unkUMap8; // [rsp-50h] [rbp-50h]
int *p_m_uniqueID; // [rsp-40h] [rbp-40h] BYREF
int m_uniqueID; // [rsp-38h] [rbp-38h] BYREF
_BYTE v22[49]; // [rsp-31h] [rbp-31h] BYREF
if ( a2->m_objectID == 3602 )
{
m_uniqueID = a2->m_uniqueID;
p_m_uniqueID = &m_uniqueID;
p_m_unkUMap8 = &a1->m_gameState.m_unkUMap8;
v3 = sub_100173400(&a1->m_gameState.m_unkUMap8, &m_uniqueID, &unk_100816AE0, &p_m_uniqueID, v22);
v4 = *(int **)(v3 + 24);
v5 = *(int **)(v3 + 32);
if ( v4 != v5 )
{
p_pair1 = &a1->m_gameState.m_proximityVolumeRelated.__tree_.__pair1_;
do
{
v7 = FMODAudioEngine::sharedEngine();
FMODAudioEngine::stopChannel_2(v7, *v4);
left = p_pair1->__value_.__left_;
if ( p_pair1->__value_.__left_ )
{
v9 = *v4;
v10 = &a1->m_gameState.m_proximityVolumeRelated.__tree_.__pair1_;
v11 = p_pair1->__value_.__left_;
do
{
v12 = *((_DWORD *)v11 + 8);
if ( v12 < v9 )
{
v11 = (std::__tree_end_node *>::pointer)((char *)v11 + 8);
}
else if ( v12 <= v9 )
{
if ( *((int *)v11 + 9) >= 0 )
v10 = (std::__compressed_pair *>> *)v11;
v11 = (std::__tree_end_node *>::pointer)((char *)v11
+ 8 * (*((_DWORD *)v11 + 9) >> 31));
}
else
{
v10 = (std::__compressed_pair *>> *)v11;
}
v11 = *(std::__tree_end_node *>::pointer *)v11;
}
while ( v11 );
if ( v10 != p_pair1 )
{
v13 = (int)v10[4].__value_.__left_;
if ( v9 >= v13 && (v9 > v13 || SHIDWORD(v10[4].__value_.__left_) <= 0) )
{
v14 = (std::__tree_end_node *> *)v10[1].__value_.__left_;
v15 = v10;
if ( v14 )
{
do
{
v16 = v14;
v14 = (std::__tree_end_node *> *)v14->__left_;
}
while ( v14 );
}
else
{
do
{
v16 = (std::__tree_end_node *> *)v15[2].__value_.__left_;
v17 = v16->__left_ == (std::__tree_end_node *>::pointer)v15;
v15 = (std::__compressed_pair *>> *)v16;
}
while ( !v17 );
}
if ( (std::__compressed_pair *>> *)a1->m_gameState.m_proximityVolumeRelated.__tree_.__begin_node_ == v10 )
a1->m_gameState.m_proximityVolumeRelated.__tree_.__begin_node_ = v16;
--a1->m_gameState.m_proximityVolumeRelated.__tree_.__pair3_.__value_;
sub_100165F60(left, v10);
operator delete(v10);
}
}
}
++v4;
}
while ( v4 != v5 );
}
m_uniqueID = a2->m_uniqueID;
p_m_uniqueID = &m_uniqueID;
v18 = sub_100173400(p_m_unkUMap8, &m_uniqueID, &unk_100816AE0, &p_m_uniqueID, v22);
*(_QWORD *)(v18 + 32) = *(_QWORD *)(v18 + 24);
}
}