//
// SFXSearchResult::updateObjects from 0x45d730 to 0x45daa6 (886 bytes)
//
// 0 xrefs:
//
// 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 *SFXObject, AudioSortType a2)
{
SFXSearchResult *v2; // r4
std::string *p_m_searchQuery; // r5
unsigned __int8 *v4; // r10
int v5; // r8
int i; // r9
unsigned __int8 *v7; // r5
int v8; // r3
SFXFolderObject *m_folderObject; // r3
MusicDownloadManager *v10; // r0
cocos2d::CCArray *m_sfxObjects; // r7
cocos2d::CCArray *FilesMatchingSearch; // r5
cocos2d::CCObject *v13; // r1
cocos2d::CCArray *v14; // r9
int Object; // r7
int v16; // r3
_DWORD *v17; // r3
int v18; // r7
int *v19; // r3
unsigned int v20; // r7
int *v21; // r8
int v22; // r1
int v23; // t1
MusicDownloadManager *v24; // r5
int v25; // r0
cocos2d::CCObject *v26; // r1
cocos2d::CCObject *v27; // r1
cocos2d::CCObject **p_m_filterObjects; // r0
cocos2d::CCArray *v29; // r0
unsigned int v30; // r1
cocos2d::ccArray *data; // r2
int v32; // r3
cocos2d::CCObject **arr; // r2
unsigned int v34; // r7
cocos2d::CCObject **v35; // r8
cocos2d::CCArray *v36; // r0
cocos2d::CCObject *v37; // r1
cocos2d::CCObject *v38; // t1
GameManager *v39; // r0
cocos2d::ccArray *v40; // r2
unsigned int num; // r3
cocos2d::CCObject **v42; // r2
cocos2d::CCObject **v43; // r3
int v44; // r1
int v45; // t1
int v46; // r11
cocos2d::CCObject *v47; // r1
int v48; // r7
cocos2d::CCArray *v49; // r9
int (**v50)(const void *, const void *); // r3
cocos2d::CCArray *v51; // r0
unsigned int v52; // r1
int v53; // r9
int v54; // r7
bool v55; // r3
int v56; // r3
_DWORD *v57; // r2
int *v58; // r7
int v59; // r1
int v60; // t1
bool v61; // [sp+0h] [bp-24h]
int *v63; // [sp+8h] [bp-1Ch]
int v64; // [sp+10h] [bp-14h] BYREF
char v65; // [sp+14h] [bp-10h] BYREF
int (**v66)(int); // [sp+18h] [bp-Ch] BYREF
v2 = SFXObject;
if ( !*((_DWORD *)SFXObject->m_searchQuery.m_data.m_data - 3) )
goto LABEL_21;
p_m_searchQuery = &SFXObject->m_searchQuery;
v4 = (unsigned __int8 *)sub_7756C4(&SFXObject->m_searchQuery);
v66 = &isdigit;
v5 = sub_7756FC(p_m_searchQuery);
for ( i = (v5 - (int)v4) >> 2; i > 0; --i )
{
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v4);
if ( SFXObject )
goto LABEL_19;
v7 = v4 + 1;
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v4 + 1);
if ( SFXObject )
goto LABEL_20;
v7 = v4 + 2;
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v4 + 2);
if ( SFXObject )
goto LABEL_20;
v7 = v4 + 3;
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v4 + 3);
if ( SFXObject )
goto LABEL_20;
v4 += 4;
}
v8 = v5 - (_DWORD)v4;
v7 = v4;
if ( v5 - (_DWORD)v4 == 2 )
goto LABEL_15;
if ( v8 == 3 )
{
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v4);
if ( SFXObject )
{
LABEL_19:
v7 = v4;
goto LABEL_20;
}
v7 = v4 + 1;
LABEL_15:
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v7);
if ( SFXObject )
goto LABEL_20;
++v7;
goto LABEL_17;
}
if ( v8 != 1 )
goto LABEL_34;
LABEL_17:
SFXObject = (SFXSearchResult *)__gnu_cxx::__ops::_Iter_negate::operator()<__gnu_cxx::__normal_iterator>(
(int (__fastcall **)(_DWORD))&v66,
v7);
if ( !SFXObject )
goto LABEL_34;
LABEL_20:
if ( (unsigned __int8 *)v5 != v7 )
goto LABEL_21;
LABEL_34:
v24 = MusicDownloadManager::sharedState();
v25 = atoi((const char *)v2->m_searchQuery.m_data.m_data);
SFXObject = (SFXSearchResult *)MusicDownloadManager::getSFXObject(v24, v25);
if ( SFXObject )
{
v27 = (cocos2d::CCObject *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)SFXObject, v26);
p_m_filterObjects = &v2->m_filterObjects;
goto LABEL_43;
}
LABEL_21:
v2->m_sortType = a2;
m_folderObject = v2->m_folderObject;
if ( m_folderObject )
{
if ( !*((_DWORD *)v2->m_searchQuery.m_data.m_data - 3) )
{
m_sfxObjects = m_folderObject->m_sfxObjects;
goto LABEL_36;
}
if ( m_folderObject->m_sfxID != 1 )
{
FilesMatchingSearch = (cocos2d::CCArray *)cocos2d::CCArray::create((cocos2d::CCArray *)SFXObject);
v14 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)v2->m_folderObject, v13);
while ( cocos2d::CCArray::count(v14) )
{
Object = cocos2d::CCArray::lastObject(v14);
cocos2d::CCArray::removeLastObject(v14, 1);
v16 = *(_DWORD *)(Object + 76);
if ( v16 )
{
v17 = *(_DWORD **)(v16 + 52);
if ( *v17 )
{
v18 = *v17 + 0x40000000;
v19 = (int *)v17[3];
v20 = (unsigned int)&v19[v18 - 1];
v21 = v19;
while ( (unsigned int)v21 <= v20 )
{
v23 = *v21++;
v22 = v23;
if ( !v23 )
break;
if ( *(_BYTE *)(v22 + 68) )
v36 = v14;
else
v36 = FilesMatchingSearch;
cocos2d::CCArray::addObject(v36, (cocos2d::CCObject *)v22);
}
}
}
}
if ( !FilesMatchingSearch )
{
v51 = (cocos2d::CCArray *)cocos2d::CCArray::count(nullptr);
FilesMatchingSearch = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v51, v52);
}
goto LABEL_40;
}
}
v10 = MusicDownloadManager::sharedState();
m_sfxObjects = MusicDownloadManager::getAllSFXObjects(v10, 1);
LABEL_36:
v29 = (cocos2d::CCArray *)cocos2d::CCArray::count(m_sfxObjects);
FilesMatchingSearch = (cocos2d::CCArray *)cocos2d::CCArray::createWithCapacity(v29, v30);
if ( m_sfxObjects )
{
data = m_sfxObjects->data;
if ( data->num )
{
v32 = data->num + 0x40000000;
arr = data->arr;
v34 = (unsigned int)&arr[v32 - 1];
v35 = arr;
while ( (unsigned int)v35 <= v34 )
{
v38 = *v35++;
v37 = v38;
if ( !v38 )
break;
cocos2d::CCArray::addObject(FilesMatchingSearch, v37);
}
}
}
LABEL_40:
if ( *((_DWORD *)v2->m_searchQuery.m_data.m_data - 3) )
{
if ( FilesMatchingSearch )
{
v40 = FilesMatchingSearch->data;
num = v40->num;
if ( v40->num )
{
v42 = v40->arr;
v43 = &v42[num] + 0x3FFFFFFF;
while ( v42 <= v43 )
{
v45 = (int)*v42++;
v44 = v45;
if ( !v45 )
break;
*(_BYTE *)(v44 + 69) = 0;
}
}
}
v39 = GameManager::sharedState();
if ( GameManager::getGameVariable(v39, "0147") && v2->m_folderObject )
{
v48 = 0;
sub_775C20(&v64);
v53 = *(_DWORD *)(v64 - 12);
while ( v48 != v53 )
{
sub_775170(&v64);
v46 = v64;
sub_775170(&v64);
*(_BYTE *)(v46 + v48) = tolower(*(unsigned __int8 *)(v64 + v48));
++v48;
}
v49 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject((cocos2d::CCArray *)v2->m_folderObject, v47);
while ( cocos2d::CCArray::count(v49) )
{
v54 = cocos2d::CCArray::lastObject(v49);
cocos2d::CCArray::removeLastObject(v49, 1);
SFXInfoObject::getLowerCaseName((SFXInfoObject *)&v65);
if ( *(_BYTE *)(v54 + 69) )
v55 = 1;
else
v55 = sub_774834(&v65, &v64, *(unsigned __int8 *)(v54 + 69)) != -1;
v61 = v55;
v56 = *(_DWORD *)(v54 + 76);
if ( v56 )
{
v57 = *(_DWORD **)(v56 + 52);
if ( *v57 )
{
v58 = (int *)v57[3];
v63 = &v58[*v57 - 1];
while ( v58 <= v63 )
{
v60 = *v58++;
v59 = v60;
if ( !v60 )
break;
*(_BYTE *)(v59 + 69) = v61;
if ( *(_BYTE *)(v59 + 68) )
cocos2d::CCArray::addObject(v49, (cocos2d::CCObject *)v59);
}
}
}
sub_774008(&v65);
}
sub_774008(&v64);
}
sub_775C20(&v65);
FilesMatchingSearch = MusicSearchResult::getFilesMatchingSearch((cocos2d::CCArray *)v2, (int)FilesMatchingSearch);
sub_774008(&v65);
}
if ( cocos2d::CCArray::count(FilesMatchingSearch) > 1u )
{
switch ( a2 )
{
case NameDescending:
v50 = (int (**)(const void *, const void *))&sfxNameCompareDesc;
break;
case LengthAscending:
v50 = (int (**)(const void *, const void *))&sfxLengthCompare;
break;
case LengthDescending:
v50 = (int (**)(const void *, const void *))&sfxLengthCompareDesc;
break;
case IDAscending:
v50 = (int (**)(const void *, const void *))&sfxIDCompare;
break;
case IDDescending:
v50 = (int (**)(const void *, const void *))&sfxIDCompareDesc;
break;
default:
v50 = (int (**)(const void *, const void *))&sfxNameCompare;
break;
}
qsort(FilesMatchingSearch->data->arr, FilesMatchingSearch->data->num, 4u, *v50);
}
p_m_filterObjects = &v2->m_filterObjects;
v27 = FilesMatchingSearch;
LABEL_43:
sub_457138(p_m_filterObjects, v27);
}