//
// SFXSearchResult::updateObjects from 0x10015d0e4 to 0x10015d604 (1312 bytes)
//
// 1 xrefs:
// > ??> @ 0x10079b1b0
//
// 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
//
// local variable allocation has failed, the output may be wrong!
void __fastcall SFXSearchResult::updateObjects(SFXSearchResult *a1, AudioSortType a2)
{
__int64 v2; // x26
SFXSearchResult *v3; // x19
std::size_t size; // x8
std::string *capacitym1; // x9
__int64 sizex2; // x10
MusicDownloadManager *v7; // x8
cocos2d::CCDictionary *m_sfxObjects; // x21
int v9; // w0
__int64 v10; // x1
cocos2d::CCObject *v11; // x0
SFXFolderObject *m_folderObject; // x8
MusicDownloadManager *v13; // x0
cocos2d::CCArray *AllSFXObjects; // x22
cocos2d::CCObject *FilesMatchingSearch; // x21
__int64 v16; // x1
__int64 v17; // x0
cocos2d::CCObject *v18; // x22
__int64 v19; // x23
__int64 v20; // x8
unsigned int *v21; // x9
__int64 v22; // x8
__int64 *v23; // x20
unsigned __int64 v24; // x23
__int64 v25; // x1
cocos2d::CCObject *v26; // x0
__int64 v27; // x0
cocos2d::ccArray *data; // x9
__int64 num; // x8
cocos2d::CCObject **arr; // x20
unsigned __int64 v31; // x22
cocos2d::CCObject_vtbl *v32; // x8
__int64 copyWithZone_low; // x9
unsigned __int64 v34; // x8
unsigned __int64 v35; // x9
GameManager *v36; // x0
__int64 v37; // x1
unsigned int v38; // w8
__int64 v39; // x20
__int64 v40; // x22
void **v41; // x8
char v42; // w0
void **v43; // x8
__int64 v44; // x22
__int64 v45; // x23
__int64 v46; // x8
void **v47; // x20
void **v48; // x24
void *v49; // x25
char *v50; // x28
char *v51; // x27
bool v52; // w20
__int64 v53; // x19
int v54; // w26
void **v55; // x0
__int64 v56; // x8
char *v57; // x0
__int64 v59; // x8
unsigned int *v60; // x9
__int64 v61; // x8
__int64 *v62; // x23
unsigned __int64 v63; // x24
__int64 v64; // x1
int (__cdecl *v65)(const void *, const void *); // x3
SFXSearchResult *v66; // [xsp+0h] [xbp-B0h]
std::string *p_m_searchQuery; // [xsp+8h] [xbp-A8h]
void *v68[2]; // [xsp+10h] [xbp-A0h] BYREF
char *v69; // [xsp+20h] [xbp-90h]
void *__p[2]; // [xsp+28h] [xbp-88h] BYREF
unsigned __int8 v71; // [xsp+3Fh] [xbp-71h]
void *__dst[2]; // [xsp+40h] [xbp-70h] BYREF
char *longStorage; // [xsp+50h] [xbp-60h]
v2 = *(_QWORD *)&a2;
v3 = a1;
p_m_searchQuery = &a1->m_searchQuery;
size = a1->m_searchQuery.m_data.m_short.shortStorage.__elems_[22];
if ( (size & 0x8000000000000000LL) != 0 )
{
size = a1->m_searchQuery.m_data.m_long.size;
if ( size )
{
capacitym1 = (std::string *)p_m_searchQuery->m_data.m_long.capacitym1;
goto LABEL_6;
}
}
else if ( a1->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] )
{
capacitym1 = &a1->m_searchQuery;
LABEL_6:
while ( 1 )
{
sizex2 = (char)capacitym1->m_data.m_short.sizex2;
if ( sizex2 < 0 || (_DefaultRuneLocale.__runetype[sizex2] & 0x400) == 0 )
break;
capacitym1 = (std::string *)((char *)capacitym1 + 1);
if ( !--size )
{
v7 = MusicDownloadManager::sharedState();
a1 = (SFXSearchResult *)p_m_searchQuery;
if ( v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] < 0 )
a1 = (SFXSearchResult *)p_m_searchQuery->m_data.m_long.capacitym1;
m_sfxObjects = v7->m_sfxObjects;
if ( m_sfxObjects )
{
v9 = atoi((const char *)a1);
a1 = (SFXSearchResult *)cocos2d::CCDictionary::objectForKey(m_sfxObjects, v9);
if ( a1 )
{
v11 = (cocos2d::CCObject *)sub_10024A1B8(a1, v10);
sub_10015CEE8((__int64)v3, v11);
return;
}
}
break;
}
}
}
v3->m_sortType = v2;
m_folderObject = v3->m_folderObject;
if ( !m_folderObject )
goto LABEL_18;
if ( (v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] & 0x8000000000000000LL) == 0 )
{
if ( v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] )
goto LABEL_17;
LABEL_20:
AllSFXObjects = m_folderObject->m_sfxObjects;
goto LABEL_34;
}
if ( !v3->m_searchQuery.m_data.m_long.size )
goto LABEL_20;
LABEL_17:
if ( m_folderObject->m_sfxID == 1 )
{
LABEL_18:
v13 = MusicDownloadManager::sharedState();
AllSFXObjects = MusicDownloadManager::getAllSFXObjects(v13, 1);
LABEL_34:
v27 = sub_10024A36C(AllSFXObjects);
FilesMatchingSearch = (cocos2d::CCObject *)sub_10024A300(v27);
if ( AllSFXObjects )
{
data = AllSFXObjects->data;
num = data->num;
if ( (_DWORD)num )
{
arr = data->arr;
v31 = (unsigned __int64)&arr[num - 1];
do
{
if ( !*arr )
break;
sub_10024A2D0(FilesMatchingSearch, *arr++);
}
while ( (unsigned __int64)arr <= v31 );
}
}
goto LABEL_39;
}
FilesMatchingSearch = (cocos2d::CCObject *)sub_10024A15C(a1);
v17 = sub_10024A1B8(v3->m_folderObject, v16);
v18 = (cocos2d::CCObject *)v17;
while ( (unsigned int)sub_10024A36C(v17) )
{
v19 = sub_10024A398(v18);
sub_10024A430(v18, 1);
v20 = *(_QWORD *)(v19 + 104);
if ( v20 )
{
v21 = *(unsigned int **)(v20 + 56);
v22 = *v21;
if ( (_DWORD)v22 )
{
v23 = *((__int64 **)v21 + 2);
v24 = (unsigned __int64)&v23[v22 - 1];
do
{
v25 = *v23;
if ( !*v23 )
break;
v26 = *(_BYTE *)(v25 + 72) ? v18 : FilesMatchingSearch;
sub_10024A2D0(v26, v25);
++v23;
}
while ( (unsigned __int64)v23 <= v24 );
}
}
v17 = (__int64)v18;
}
if ( !FilesMatchingSearch )
{
AllSFXObjects = nullptr;
goto LABEL_34;
}
LABEL_39:
if ( (v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] & 0x8000000000000000LL) == 0 )
{
if ( !v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] )
goto LABEL_111;
LABEL_43:
if ( FilesMatchingSearch )
{
v32 = FilesMatchingSearch[1].__vftable;
copyWithZone_low = LODWORD(v32->copyWithZone);
if ( (_DWORD)copyWithZone_low )
{
v34 = (unsigned __int64)v32->~CCObject_0;
v35 = v34 + 8 * copyWithZone_low - 8;
do
{
if ( !*(_QWORD *)v34 )
break;
*(_BYTE *)(*(_QWORD *)v34 + 73LL) = 0;
v34 += 8LL;
}
while ( v34 <= v35 );
}
}
v36 = GameManager::sharedState();
if ( GameManager::getGameVariable(v36, "0147") && v3->m_folderObject )
{
if ( v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(__dst, (void *)v3->m_searchQuery.m_data.m_long.capacitym1, v3->m_searchQuery.m_data.m_long.size);
}
else
{
*(_OWORD *)__dst = *(_OWORD *)&p_m_searchQuery->m_data.m_short.sizex2;
longStorage = p_m_searchQuery->m_data.m_long.longStorage;
}
v38 = HIBYTE(longStorage);
if ( SHIBYTE(longStorage) < 0 )
v38 = (unsigned int)__dst[1];
v39 = v38;
if ( v38 )
{
v40 = 0;
do
{
if ( SHIBYTE(longStorage) >= 0 )
v41 = __dst;
else
v41 = (void **)__dst[0];
v42 = __tolower(*((char *)v41 + v40));
if ( SHIBYTE(longStorage) >= 0 )
v43 = __dst;
else
v43 = (void **)__dst[0];
*((_BYTE *)v43 + v40++) = v42;
}
while ( v39 != v40 );
}
v44 = sub_10024A1B8(v3->m_folderObject, v37);
v66 = v3;
while ( (unsigned int)sub_10024A36C(v44) )
{
v45 = sub_10024A398(v44);
sub_10024A430(v44, 1);
SFXInfoObject::getLowerCaseName((void *)v45, (__int64 *)__p);
if ( (*(_BYTE *)(v45 + 73) & 1) != 0 )
goto LABEL_81;
v46 = v71;
if ( (v71 & 0x80u) == 0 )
v47 = __p;
else
v47 = (void **)__p[0];
if ( (v71 & 0x80u) != 0 )
v46 = (__int64)__p[1];
v48 = SHIBYTE(longStorage) >= 0 ? __dst : (void **)__dst[0];
v49 = SHIBYTE(longStorage) >= 0 ? (void *)HIBYTE(longStorage) : __dst[1];
if ( !v49 )
{
LABEL_81:
v52 = 1;
}
else
{
v50 = (char *)v47 + v46;
if ( v46 >= (__int64)v49 )
{
v53 = v2;
v54 = *(char *)v48;
v55 = v47;
do
{
v56 = v46 - (_QWORD)v49;
if ( v56 == -1 )
break;
v57 = (char *)memchr(v55, v54, v56 + 1);
if ( !v57 )
break;
v51 = v57;
if ( !memcmp(v57, v48, (size_t)v49) )
goto LABEL_88;
v55 = (void **)(v51 + 1);
v46 = v50 - (v51 + 1);
}
while ( v46 >= (__int64)v49 );
v51 = v50;
LABEL_88:
v2 = v53;
v3 = v66;
}
else
{
v51 = (char *)v47 + v46;
}
v52 = v51 != v50 && v51 - (char *)v47 != -1;
}
v59 = *(_QWORD *)(v45 + 104);
if ( v59 )
{
v60 = *(unsigned int **)(v59 + 56);
v61 = *v60;
if ( (_DWORD)v61 )
{
v62 = *((__int64 **)v60 + 2);
v63 = (unsigned __int64)&v62[v61 - 1];
do
{
v64 = *v62;
if ( !*v62 )
break;
*(_BYTE *)(v64 + 73) = v52;
if ( *(_BYTE *)(v64 + 72) == 1 )
sub_10024A2D0(v44, v64);
++v62;
}
while ( (unsigned __int64)v62 <= v63 );
}
}
if ( (char)v71 < 0 )
operator delete(__p[0]);
}
if ( SHIBYTE(longStorage) < 0 )
operator delete(__dst[0]);
}
if ( v3->m_searchQuery.m_data.m_short.shortStorage.__elems_[22] < 0 )
{
sub_1000097D0(v68, (void *)v3->m_searchQuery.m_data.m_long.capacitym1, v3->m_searchQuery.m_data.m_long.size);
}
else
{
*(_OWORD *)v68 = *(_OWORD *)&p_m_searchQuery->m_data.m_short.sizex2;
v69 = p_m_searchQuery->m_data.m_long.longStorage;
}
FilesMatchingSearch = (cocos2d::CCObject *)MusicSearchResult::getFilesMatchingSearch(
(__int64)v3,
(__int64)FilesMatchingSearch,
(__int64)v68);
if ( SHIBYTE(v69) < 0 )
operator delete(v68[0]);
goto LABEL_111;
}
if ( v3->m_searchQuery.m_data.m_long.size )
goto LABEL_43;
LABEL_111:
if ( (unsigned int)sub_10024A36C(FilesMatchingSearch) >= 2 )
{
if ( (unsigned int)(v2 - 1) > 4 )
v65 = (int (__cdecl *)(const void *, const void *))sub_100153114;
else
v65 = (int (__cdecl *)(const void *, const void *))off_10079B2F8[(unsigned int)(v2 - 1)];
qsort(FilesMatchingSearch[1].~CCObject_0, (size_t)FilesMatchingSearch[1].copyWithZone, 8u, v65);
}
sub_10015CEE8((__int64)v3, FilesMatchingSearch);
}