//
// GJBaseGameLayer::updateParticles from 0x888994 to 0x888c2c (664 bytes)
//
// 3 xrefs:
// > PlayLayer::updateVisibility @ 0x5cea38
// > LevelEditorLayer::updateVisibility @ 0x66310c
// > ??> @ 0x6d3f8
//
// 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 GJBaseGameLayer::updateParticles(GJBaseGameLayer *a1, float a2)
{
unsigned int v3; // w21
__int64 *p_m_customParticlesUIDs; // x22
stl::StringData::Internal *v6; // x0
__int64 v7; // x0
__int64 v8; // x20
unsigned int v9; // w20
cocos2d::CCObject *v10; // x21
unsigned __int64 m_uUnknown; // x26
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 v12; // x27
_QWORD *v13; // x0
cocos2d::CCArray *v14; // x0
char *v15; // x27
unsigned int *v16; // x21
int v17; // w0
int v18; // w0
void (__fastcall *v19)(__int64, float); // x2
__int64 v20; // x0
int v21; // w5
std::string v22[2]; // [xsp+90h] [xbp+90h] BYREF
v3 = 0;
p_m_customParticlesUIDs = (__int64 *)&a1->m_customParticlesUIDs;
v6 = (stl::StringData::Internal *)_stack_chk_guard;
a1->m_particleCount = 0;
v22[1].m_data.m_data = v6;
while ( v3 < (unsigned int)cocos2d::CCArray::count(a1->m_temporaryParticles) )
{
while ( 1 )
{
v7 = cocos2d::CCArray::objectAtIndex(a1->m_temporaryParticles, v3);
v8 = v7;
if ( !*(_BYTE *)(v7 + 535) )
break;
LODWORD(v22[0].m_data.m_data) = *(_DWORD *)(v7 + 8);
sub_888850(p_m_customParticlesUIDs, (int *)v22);
cocos2d::CCArray::fastRemoveObjectAtIndex(a1->m_temporaryParticles, v3);
if ( v3 >= (unsigned int)cocos2d::CCArray::count(a1->m_temporaryParticles) )
goto LABEL_5;
}
++v3;
v18 = (*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v7 + 1480LL))(v7);
v19 = *(void (__fastcall **)(__int64, float))(*(_QWORD *)v8 + 40LL);
a1->m_particleCount += v18;
v19(v8, a2);
}
LABEL_5:
v9 = 0;
while ( v9 < (unsigned int)cocos2d::CCArray::count(a1->m_unclaimedParticles) )
{
while ( 1 )
{
v10 = (cocos2d::CCObject *)cocos2d::CCArray::objectAtIndex(a1->m_unclaimedParticles, v9);
if ( !((unsigned int (__fastcall *)(cocos2d::CCObject *))v10->__vftable[11].~CCObject_0)(v10) )
break;
if ( ++v9 >= (unsigned int)cocos2d::CCArray::count(a1->m_unclaimedParticles) )
return;
}
m_uUnknown = v10[13].m_uUnknown;
v12 = m_uUnknown % a1->m_particleCountToParticleString._M_h._M_bucket_count;
v13 = sub_8562F8(&a1->m_particleCountToParticleString._M_h._M_buckets, v12, &v10[13].m_uUnknown);
if ( !v13 || !*v13 )
{
v20 = operator new(0x18u);
v21 = v10[13].m_uUnknown;
*(_QWORD *)v20 = 0;
*(_DWORD *)(v20 + 8) = v21;
*(_QWORD *)(v20 + 16) = &byte_124B6C8;
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(
(char **)&a1->m_particleCountToParticleString,
v12,
m_uUnknown,
(char *)v20);
}
sub_D18D28(v22);
v14 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(a1->m_customParticles, v22);
if ( v14 )
cocos2d::CCArray::addObject(v14, v10);
cocos2d::CCArray::fastRemoveObjectAtIndex(a1->m_unclaimedParticles, v9);
v15 = (char *)v22[0].m_data.m_data - 24;
if ( (__int64 *)v22[0].m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v16 = (unsigned int *)((char *)v22[0].m_data.m_data - 8);
do
v17 = __ldaxr(v16);
while ( __stlxr(v17 - 1, v16) );
}
else
{
v17 = *((_DWORD *)v22[0].m_data.m_data - 2);
*((_DWORD *)v22[0].m_data.m_data - 2) = v17 - 1;
}
if ( v17 <= 0 )
operator delete(v15);
}
}
}