//
// BrowseSmartKeyLayer::updateChanceValues from 0x9e1af4 to 0x9e1d4c (600 bytes)
//
// 3 xrefs:
// > BrowseSmartKeyLayer::deletedSelectedItems @ 0x9e1e1c
// > BrowseSmartKeyLayer::addChanceToSelected @ 0x9e2014
// > ??> @ 0x9b478
//
// 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 BrowseSmartKeyLayer::updateChanceValues(BrowseSmartKeyLayer *a1)
{
GJSmartTemplate *m_template; // x19
int TotalChanceForPrefab; // w27
char *v4; // x0
unsigned int i; // w28
unsigned int v6; // w19
cocos2d::CCArray *v7; // x22
__int64 v8; // x0
GJSmartBlockPreview *v9; // x20
GJSmartTemplate *v10; // x23
long double v11; // q0
int v12; // w0
__int64 PrefabWithID; // x23
char *v14; // x0
unsigned int *v15; // x1
int v16; // w2
unsigned int *v17; // x3
int v18; // w1
std::string v19; // [xsp+80h] [xbp+80h] BYREF
m_template = a1->m_template;
sub_D18D28(&v19);
TotalChanceForPrefab = GJSmartTemplate::getTotalChanceForPrefab((__int64)m_template);
v4 = (char *)v19.m_data.m_data - 24;
if ( (__int64 *)v19.m_data.m_data - 3 != &qword_124B6B0 )
{
v17 = (unsigned int *)((char *)v19.m_data.m_data - 8);
if ( &pthread_create )
{
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *((_DWORD *)v19.m_data.m_data - 2);
*((_DWORD *)v19.m_data.m_data - 2) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v4);
}
for ( i = 0; i < (unsigned int)cocos2d::CCArray::count(a1->m_pages); ++i )
{
v6 = 0;
v7 = (cocos2d::CCArray *)cocos2d::CCArray::objectAtIndex(a1->m_pages, i);
if ( (unsigned int)cocos2d::CCArray::count(v7) )
{
do
{
v8 = cocos2d::CCArray::objectAtIndex(v7, v6);
v9 = (GJSmartBlockPreview *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v8 + 1056LL))(v8);
v10 = a1->m_template;
*(__n128 *)&v11 = sub_D18D28(&v19);
v12 = ((__int64 (__fastcall *)(GJSmartBlockPreview *, long double))v9->getTag)(v9, v11);
PrefabWithID = GJSmartTemplate::getPrefabWithID((__int64)v10, &v19, v12);
v14 = (char *)v19.m_data.m_data - 24;
if ( (__int64 *)v19.m_data.m_data - 3 != &qword_124B6B0 )
{
if ( &pthread_create )
{
v15 = (unsigned int *)((char *)v19.m_data.m_data - 8);
do
v16 = __ldaxr(v15);
while ( __stlxr(v16 - 1, v15) );
}
else
{
v16 = *((_DWORD *)v19.m_data.m_data - 2);
*((_DWORD *)v19.m_data.m_data - 2) = v16 - 1;
}
if ( v16 <= 0 )
operator delete(v14);
}
if ( PrefabWithID )
GJSmartBlockPreview::addChance(v9, *(_DWORD *)(PrefabWithID + 76), TotalChanceForPrefab);
++v6;
}
while ( v6 < (unsigned int)cocos2d::CCArray::count(v7) );
}
}
}