//
// SFXSearchResult::updateObjects from 0x83230c to 0x832b08 (2044 bytes)
//
// 2 xrefs:
// > ??> @ 0x83da8
// > ??> @ 0x118a190
//
// 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 SFXSearchResult::updateObjects(SFXSearchResult *a1, AudioSortType a2)
{
unsigned __int8 *m_data; // x19
__int64 v4; // x0
stl::StringData::Internal *v5; // x3
unsigned __int8 *v6; // x3
signed __int64 v7; // x0
__int64 v8; // x2
unsigned __int8 *v9; // x0
MusicDownloadManager *v10; // x19
int v11; // w0
cocos2d::CCArray *SFXObject; // x0
cocos2d::CCObject *v13; // x1
cocos2d::CCObject *v14; // x0
cocos2d::CCArray *v15; // x19
cocos2d::CCArray *v16; // x1
SFXFolderObject *m_folderObject; // x0
cocos2d::CCArray *m_sfxID; // x0
cocos2d::CCArray *FilesMatchingSearch; // x26
cocos2d::CCObject *v20; // x1
cocos2d::CCArray *v21; // x21
__int64 Object; // x19
__int64 v23; // x0
unsigned int *v24; // x0
__int64 *v25; // x19
__int64 *v26; // x20
int (*v27)(const void *, const void *); // x3
cocos2d::CCArray *m_filterObjects; // x0
cocos2d::CCArray *m_sfxObjects; // x19
cocos2d::CCArray *v30; // x0
unsigned int v31; // w1
cocos2d::ccArray *data; // x1
cocos2d::ccArray *v33; // x0
unsigned int num; // w1
cocos2d::CCObject **v35; // x0
cocos2d::CCObject **j; // x2
cocos2d::CCObject *v37; // x1
GameManager *v38; // x0
cocos2d::CCObject *v39; // x1
_QWORD *v40; // x19
unsigned int v41; // w21
__int64 v42; // x20
_BYTE *v43; // x19
unsigned __int8 *v44; // x0
_BYTE *v45; // x19
cocos2d::CCArray *v46; // x24
SFXInfoObject *v47; // x19
bool v48; // w21
SFXInfoObject_vtbl *v49; // x0
bool (__fastcall *canEncode)(cocos2d::CCObject *__hidden); // x0
__int64 *v51; // x19
__int64 *i; // x20
__int64 v53; // x1
int v54; // w0
void *v55; // x0
unsigned int *v56; // x1
int v57; // w2
__int64 v58; // x1
__int64 *v59; // x2
void *v60; // x0
unsigned int *v61; // x2
int v62; // w1
char *v63; // x0
MusicDownloadManager *v64; // x0
cocos2d::CCObject **arr; // x19
__int64 v66; // x0
char *v67; // x20
cocos2d::CCObject *v68; // x1
unsigned int *v69; // x3
int v70; // w1
cocos2d::CCArray *v71; // x0
unsigned int v72; // w1
__int64 v73; // [xsp+0h] [xbp+0h] BYREF
__int64 *v74; // [xsp+68h] [xbp+68h]
std::string *p_m_searchQuery; // [xsp+70h] [xbp+70h]
AudioSortType v76; // [xsp+7Ch] [xbp+7Ch]
char v77; // [xsp+80h] [xbp+80h] BYREF
_QWORD *v78; // [xsp+88h] [xbp+88h] BYREF
__int64 v79; // [xsp+90h] [xbp+90h] BYREF
p_m_searchQuery = &a1->m_searchQuery;
m_data = (unsigned __int8 *)a1->m_searchQuery.m_data.m_data;
v76 = a2;
v4 = *((_QWORD *)m_data - 3);
if ( !v4 )
{
LABEL_31:
m_folderObject = a1->m_folderObject;
a1->m_sortType = v76;
if ( m_folderObject )
{
if ( !*((_QWORD *)a1->m_searchQuery.m_data.m_data - 3) )
{
m_sfxObjects = m_folderObject->m_sfxObjects;
LABEL_54:
v30 = (cocos2d::CCArray *)cocos2d::CCArray::count(m_sfxObjects);
FilesMatchingSearch = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v30, v31);
if ( m_sfxObjects )
{
data = m_sfxObjects->data;
if ( data->num )
{
arr = data->arr;
v66 = 8LL * data->num - 8;
v67 = (char *)arr + v66;
if ( arr <= (cocos2d::CCObject **)((char *)arr + v66) )
{
do
{
v68 = *arr;
if ( !*arr )
break;
++arr;
cocos2d::CCArray::addObject(FilesMatchingSearch, v68);
}
while ( v67 >= (char *)arr );
}
}
}
goto LABEL_56;
}
m_sfxID = (cocos2d::CCArray *)(unsigned int)m_folderObject->m_sfxID;
if ( (_DWORD)m_sfxID != 1 )
{
FilesMatchingSearch = (cocos2d::CCArray *)cocos2d::CCArray::create(m_sfxID);
v21 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)a1->m_folderObject, v20);
LABEL_35:
while ( (unsigned int)cocos2d::CCArray::count(v21) )
{
while ( 1 )
{
Object = cocos2d::CCArray::lastObject(v21);
cocos2d::CCArray::removeLastObject(v21, 1);
v23 = *(_QWORD *)(Object + 88);
if ( !v23 )
break;
v24 = *(unsigned int **)(v23 + 56);
if ( !*v24 )
break;
v25 = *((__int64 **)v24 + 2);
v26 = &v25[*v24 - 1];
if ( v25 <= v26 )
{
do
{
v58 = *v25;
if ( !*v25 )
break;
if ( *(_BYTE *)(v58 + 72) )
cocos2d::CCArray::addObject(v21, (cocos2d::CCObject *)v58);
else
cocos2d::CCArray::addObject(FilesMatchingSearch, (cocos2d::CCObject *)v58);
++v25;
}
while ( v26 >= v25 );
goto LABEL_35;
}
if ( !(unsigned int)cocos2d::CCArray::count(v21) )
goto LABEL_40;
}
}
LABEL_40:
if ( FilesMatchingSearch )
{
if ( !*((_QWORD *)a1->m_searchQuery.m_data.m_data - 3) )
{
LABEL_42:
if ( (unsigned int)cocos2d::CCArray::count(FilesMatchingSearch) > 1 )
{
switch ( v76 )
{
case NameDescending:
v27 = (int (*)(const void *, const void *))sfxNameCompareDesc;
break;
case LengthAscending:
v27 = (int (*)(const void *, const void *))sfxLengthCompare;
break;
case LengthDescending:
v27 = (int (*)(const void *, const void *))sfxLengthCompareDesc;
break;
case IDAscending:
v27 = (int (*)(const void *, const void *))sfxIDCompare;
break;
case IDDescending:
v27 = (int (*)(const void *, const void *))sfxIDCompareDesc;
break;
default:
v27 = (int (*)(const void *, const void *))sfxNameCompare;
break;
}
qsort(FilesMatchingSearch->data->arr, FilesMatchingSearch->data->num, 8u, v27);
}
m_filterObjects = a1->m_filterObjects;
if ( FilesMatchingSearch != m_filterObjects )
{
if ( FilesMatchingSearch )
{
cocos2d::CCObject::retain(FilesMatchingSearch);
m_filterObjects = a1->m_filterObjects;
}
if ( m_filterObjects )
cocos2d::CCObject::release(m_filterObjects);
a1->m_filterObjects = FilesMatchingSearch;
}
return;
}
goto LABEL_58;
}
v71 = (cocos2d::CCArray *)cocos2d::CCArray::count(nullptr);
FilesMatchingSearch = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v71, v72);
LABEL_56:
if ( !*((_QWORD *)a1->m_searchQuery.m_data.m_data - 3) )
goto LABEL_42;
if ( !FilesMatchingSearch )
{
LABEL_62:
v38 = GameManager::sharedState();
if ( GameManager::getGameVariable(v38, "0147") && a1->m_folderObject )
{
sub_D18D28(&v78);
v40 = v78;
v41 = *(v78 - 3);
if ( v41 )
{
v42 = 0;
while ( 1 )
{
if ( (*(_DWORD *)(v40 - 1) & 0x80000000) != 0 )
{
v45 = (char *)v40 + v42++;
*v45 = tolower((unsigned __int8)*v45);
if ( v41 <= (unsigned int)v42 )
break;
}
else
{
sub_D176A8(&v78);
v43 = (char *)v78 + v42;
if ( (*(_DWORD *)(v78 - 1) & 0x80000000) == 0 )
sub_D176A8(&v78);
v44 = (unsigned __int8 *)v78 + v42++;
*v43 = tolower(*v44);
if ( v41 <= (unsigned int)v42 )
break;
}
v40 = v78;
}
}
v46 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)a1->m_folderObject, v39);
v74 = (__int64 *)&v77;
while ( (unsigned int)cocos2d::CCArray::count(v46) )
{
v47 = (SFXInfoObject *)cocos2d::CCArray::lastObject(v46);
cocos2d::CCArray::removeLastObject(v46, 1);
SFXInfoObject::getLowerCaseName(v47, &v79);
v48 = 1;
if ( !v47->m_unk049 )
v48 = sub_D1641C((unsigned int)&v73 + 144, v78) != -1;
v49 = v47[1].__vftable;
if ( v49 )
{
canEncode = v49->canEncode;
if ( *(_DWORD *)canEncode )
{
v51 = *((__int64 **)canEncode + 2);
for ( i = &v51[*(unsigned int *)canEncode - 1]; i >= v51; ++v51 )
{
v53 = *v51;
if ( !*v51 )
break;
v54 = *(unsigned __int8 *)(v53 + 72);
*(_BYTE *)(v53 + 73) = v48;
if ( v54 )
cocos2d::CCArray::addObject(v46, (cocos2d::CCObject *)v53);
}
}
}
v55 = (void *)(v79 - 24);
if ( (__int64 *)(v79 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v56 = (unsigned int *)(v79 - 8);
do
v57 = __ldaxr(v56);
while ( __stlxr(v57 - 1, v56) );
}
else
{
v57 = *(_DWORD *)(v79 - 8);
*(_DWORD *)(v79 - 8) = v57 - 1;
}
if ( v57 <= 0 )
operator delete(v55);
}
}
v63 = (char *)(v78 - 3);
if ( v78 - 3 == &qword_124B6B0 )
{
v59 = &v79;
}
else
{
v69 = (unsigned int *)(v78 - 1);
if ( &pthread_create )
{
do
v70 = __ldaxr(v69);
while ( __stlxr(v70 - 1, v69) );
}
else
{
v70 = *((_DWORD *)v78 - 2);
*((_DWORD *)v78 - 2) = v70 - 1;
}
v59 = &v79;
if ( v70 <= 0 )
{
v74 = &v79;
operator delete(v63);
v59 = v74;
}
}
}
else
{
v59 = &v79;
}
v74 = v59;
sub_D18D28(v59);
FilesMatchingSearch = MusicSearchResult::getFilesMatchingSearch(
(__int64)a1,
(__int64)FilesMatchingSearch,
(__int64)v74);
v60 = (void *)(v79 - 24);
if ( (__int64 *)(v79 - 24) != &qword_124B6B0 )
{
v61 = (unsigned int *)(v79 - 8);
if ( &pthread_create )
{
do
v62 = __ldaxr(v61);
while ( __stlxr(v62 - 1, v61) );
}
else
{
v62 = *(_DWORD *)(v79 - 8);
*(_DWORD *)(v79 - 8) = v62 - 1;
}
if ( v62 <= 0 )
operator delete(v60);
}
goto LABEL_42;
}
LABEL_58:
v33 = FilesMatchingSearch->data;
num = v33->num;
if ( v33->num )
{
v35 = v33->arr;
for ( j = &v35[num - 1]; j >= v35; BYTE1(v37[1].m_nTag) = 0 )
{
v37 = *v35;
if ( !*v35 )
break;
++v35;
}
}
goto LABEL_62;
}
}
v64 = MusicDownloadManager::sharedState();
m_sfxObjects = MusicDownloadManager::getAllSFXObjects(v64, 1);
goto LABEL_54;
}
v5 = (stl::StringData::Internal *)m_data;
if ( (*((_DWORD *)m_data - 2) & 0x80000000) == 0 )
{
sub_D176A8(p_m_searchQuery);
m_data = (unsigned __int8 *)a1->m_searchQuery.m_data.m_data;
if ( (*((_DWORD *)m_data - 2) & 0x80000000) != 0 )
{
v4 = *((_QWORD *)m_data - 3);
v5 = a1->m_searchQuery.m_data.m_data;
}
else
{
sub_D176A8(p_m_searchQuery);
v5 = a1->m_searchQuery.m_data.m_data;
v4 = *((_QWORD *)v5 - 3);
}
}
v6 = (unsigned __int8 *)v5 + v4;
v7 = v6 - m_data;
v8 = (v6 - m_data) >> 2;
if ( v8 <= 0 )
{
LABEL_18:
if ( v7 != 2 )
{
if ( v7 != 3 )
{
if ( v7 != 1 )
goto LABEL_21;
goto LABEL_117;
}
if ( (unsigned int)*m_data - 48 > 9 )
goto LABEL_30;
++m_data;
}
if ( (unsigned int)*m_data - 48 > 9 )
goto LABEL_30;
++m_data;
LABEL_117:
if ( (unsigned int)*m_data - 48 <= 9 )
goto LABEL_21;
goto LABEL_30;
}
if ( (unsigned int)*m_data - 48 > 9 )
{
v9 = m_data;
LABEL_29:
m_data = v9;
}
else if ( (unsigned int)m_data[1] - 48 > 9 )
{
++m_data;
}
else if ( (unsigned int)m_data[2] - 48 > 9 )
{
m_data += 2;
}
else if ( (unsigned int)m_data[3] - 48 <= 9 )
{
while ( 1 )
{
--v8;
v9 = m_data + 4;
if ( !v8 )
{
m_data += 4;
v7 = v6 - v9;
goto LABEL_18;
}
if ( (unsigned int)m_data[4] - 48 > 9 )
goto LABEL_29;
if ( (unsigned int)m_data[5] - 48 > 9 )
{
m_data += 5;
goto LABEL_30;
}
if ( (unsigned int)m_data[6] - 48 > 9 )
{
m_data += 6;
goto LABEL_30;
}
if ( (unsigned int)m_data[7] - 48 > 9 )
break;
m_data += 4;
}
m_data += 7;
}
else
{
m_data += 3;
}
LABEL_30:
if ( v6 != m_data )
goto LABEL_31;
LABEL_21:
v10 = MusicDownloadManager::sharedState();
v11 = atoi((const char *)a1->m_searchQuery.m_data.m_data);
SFXObject = (cocos2d::CCArray *)MusicDownloadManager::getSFXObject(v10, v11);
if ( !SFXObject )
goto LABEL_31;
v14 = (cocos2d::CCObject *)cocos2d::CCArray::createWithObject(SFXObject, v13);
v15 = (cocos2d::CCArray *)v14;
v16 = a1->m_filterObjects;
if ( v14 != v16 )
{
if ( v14 )
{
cocos2d::CCObject::retain(v14);
v16 = a1->m_filterObjects;
}
if ( v16 )
cocos2d::CCObject::release(v16);
a1->m_filterObjects = v15;
}
}