//
// MusicDownloadManager::parseSFXLibrary from 0x10015a32c to 0x10015a8b0 (1412 bytes)
//
// 3 xrefs:
// > MusicDownloadManager::onDownloadSFXLibraryCompleted @ 0x10015a2ac
// > MusicDownloadManager::tryLoadLibraries @ 0x10015ac4c
// > SFXBrowser::init @ 0x1001695b8
//
// 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 __fastcall MusicDownloadManager::parseSFXLibrary(MusicDownloadManager *a1)
{
cocos2d::CCFileUtils *v2; // x0
std::string *v3; // x1
std::string::value_type *v4; // x0
std::string::size_type size; // x9
char v6; // w8
std::string::size_type v7; // x8
void **p_data; // x8
void **v9; // x9
cocos2d::CCDictionary *m_sfxObjects; // x0
cocos2d::CCArray *m_sfxArtists; // x0
cocos2d::CCDictionary *v12; // x0
__int64 v13; // x0
cocos2d::CCArray *v14; // x0
unsigned __int64 v15; // x27
void **v16; // x22
void **v17; // x23
int v18; // w8
void **v19; // x23
const char *v20; // x0
__int64 v21; // x22
char *v22; // x1
char *v23; // x26
const char *v24; // x0
int v25; // w24
const char *v26; // x0
__int64 v27; // x23
const char *v28; // x0
__int64 v29; // x25
const char *v30; // x0
__int64 v31; // x26
std::string *v32; // x0
SFXInfoObject *v33; // x0
SFXInfoObject *v34; // x0
std::string::size_type v35; // x8
unsigned __int64 v36; // x22
void **v37; // x21
void **v38; // x25
int v39; // w8
void **v40; // x8
cocos2d::CCArray *v41; // x21
__int128 v42; // q0
__int64 v43; // x0
void *v44[2]; // [xsp+0h] [xbp-180h] BYREF
void *v45; // [xsp+10h] [xbp-170h]
void *v46[2]; // [xsp+20h] [xbp-160h] BYREF
void *v47; // [xsp+30h] [xbp-150h]
std::string __p; // [xsp+40h] [xbp-140h] BYREF
std::string __dst; // [xsp+60h] [xbp-120h] BYREF
std::string v50; // [xsp+80h] [xbp-100h] BYREF
void **v51; // [xsp+98h] [xbp-E8h] BYREF
void **v52; // [xsp+A0h] [xbp-E0h]
__int64 v53; // [xsp+A8h] [xbp-D8h]
std::string *v54; // [xsp+B0h] [xbp-D0h] BYREF
void **v55; // [xsp+B8h] [xbp-C8h]
__int64 v56; // [xsp+C0h] [xbp-C0h]
std::string v57; // [xsp+C8h] [xbp-B8h] BYREF
std::string v58; // [xsp+E0h] [xbp-A0h] BYREF
__int64 v59; // [xsp+100h] [xbp-80h] BYREF
std::string v60; // [xsp+108h] [xbp-78h] BYREF
std::string *v61; // [xsp+120h] [xbp-60h] BYREF
MusicDownloadManager::pathForSFXFolder((__int64)a1, 0, (__int64)&v60);
std::string::append(&v60, "sfxlibrary.dat");
v59 = 0;
v2 = cocos2d::CCFileUtils::sharedFileUtils();
if ( (v60.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v3 = &v60;
else
v3 = (std::string *)v60.__r_.__value_.__r.__words[0];
v4 = (std::string::value_type *)((__int64 (__fastcall *)(cocos2d::CCFileUtils *, std::string *, const char *, __int64 *))v2->addSearchResolutionsOrder)(
v2,
v3,
"r",
&v59);
memset(&v58, 0, sizeof(v58));
if ( v4 )
{
cocos2d::ZipUtils::decompressString2((__int64 *)&v57, v4, 0, (unsigned int)v59);
if ( SHIBYTE(v58.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v58.__r_.__value_.__l.__data_);
v58 = v57;
size = HIBYTE(v57.__r_.__value_.__r.__words[2]);
v6 = HIBYTE(v57.__r_.__value_.__r.__words[2]);
if ( (v57.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) != 0LL )
size = v58.__r_.__value_.__l.__size_;
if ( size )
{
memset(&v57, 0, sizeof(v57));
sub_100155A98(&v58, "|", (__int64)&v57);
if ( 0xAAAAAAAAAAAAAAABLL * ((__int64)(v57.__r_.__value_.__l.__size_ - v57.__r_.__value_.__r.__words[0]) >> 3) >= 2 )
{
v54 = nullptr;
v55 = nullptr;
v56 = 0;
sub_100155A98((std::string *)v57.__r_.__value_.__l.__data_, ";", (__int64)&v54);
v7 = v57.__r_.__value_.__r.__words[0];
if ( *(char *)(v57.__r_.__value_.__r.__words[0] + 23) < 0 )
{
**(_BYTE **)v57.__r_.__value_.__l.__data_ = 0;
*(_QWORD *)(v7 + 8) = 0;
}
else
{
*v57.__r_.__value_.__l.__data_ = 0;
*(_BYTE *)(v7 + 23) = 0;
}
v51 = nullptr;
v52 = nullptr;
v53 = 0;
p_data = (void **)&v54->__r_.__value_.__l.__data_;
v9 = v55;
if ( v55 != (void **)v54 )
{
m_sfxObjects = a1->m_sfxObjects;
if ( m_sfxObjects )
{
cocos2d::CCObject::release(m_sfxObjects);
m_sfxArtists = a1->m_sfxArtists;
if ( m_sfxArtists )
cocos2d::CCObject::release(m_sfxArtists);
}
v12 = cocos2d::CCDictionary::create();
a1->m_sfxObjects = v12;
cocos2d::CCObject::retain(v12);
v14 = (cocos2d::CCArray *)sub_10024A15C(v13);
a1->m_sfxArtists = v14;
cocos2d::CCObject::retain(v14);
a1->m_sfxObjectCount = 0;
p_data = (void **)&v54->__r_.__value_.__l.__data_;
v9 = v55;
}
if ( v9 != p_data )
{
v15 = 0;
do
{
v16 = v51;
v17 = v52;
if ( v52 != v51 )
{
do
{
v18 = *((char *)v17 - 1);
v17 -= 3;
if ( v18 < 0 )
operator delete(*v17);
}
while ( v17 != v16 );
p_data = (void **)&v54->__r_.__value_.__l.__data_;
}
v52 = v16;
sub_100155A98((std::string *)&p_data[3 * v15], ",", (__int64)&v51);
v19 = v51;
if ( 0xAAAAAAAAAAAAAAABLL * (v52 - v51) >= 6 )
{
v20 = (const char *)v51;
if ( *((char *)v51 + 23) < 0 )
v20 = (const char *)*v51;
v21 = atoi(v20);
v22 = (char *)(v19 + 3);
if ( *((char *)v19 + 47) < 0 )
v22 = *(char **)v22;
sub_100009900(&v50, v22);
v23 = (char *)v51;
v24 = (const char *)(v51 + 6);
if ( *((char *)v51 + 71) < 0 )
v24 = *(const char **)v24;
v25 = atoi(v24);
v26 = v23 + 72;
if ( v23[95] < 0 )
v26 = *(const char **)v26;
v27 = atoi(v26);
v28 = v23 + 96;
if ( v23[119] < 0 )
v28 = *(const char **)v28;
v29 = atoi(v28);
v30 = v23 + 120;
if ( v23[143] < 0 )
v30 = *(const char **)v30;
v31 = atoi(v30);
if ( (_DWORD)v21 == 1 )
{
if ( (v50.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
v32 = &v50;
else
v32 = (std::string *)v50.__r_.__value_.__r.__words[0];
a1->m_sfxLibraryVersion = atoi((const char *)v32);
std::string::assign(&v50, "Root");
}
if ( v25 )
{
if ( SHIBYTE(v50.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v50.__r_.__value_.__l.__data_, v50.__r_.__value_.__l.__size_);
else
__p = v50;
v33 = (SFXInfoObject *)SFXFolderObject::create(v21, &__p, v27);
MusicDownloadManager::storeSFXInfoObject(a1, v33);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
}
else
{
if ( SHIBYTE(v50.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__dst, v50.__r_.__value_.__l.__data_, v50.__r_.__value_.__l.__size_);
else
__dst = v50;
v34 = (SFXInfoObject *)SFXInfoObject::create(v21, &__dst, v27, v29, v31);
MusicDownloadManager::storeSFXInfoObject(a1, v34);
if ( SHIBYTE(__dst.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__dst.__r_.__value_.__l.__data_);
++a1->m_sfxObjectCount;
}
if ( SHIBYTE(v50.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v50.__r_.__value_.__l.__data_);
}
++v15;
p_data = (void **)&v54->__r_.__value_.__l.__data_;
}
while ( 0xAAAAAAAAAAAAAAABLL * (((char *)v55 - (char *)v54) >> 3) > v15 );
}
memset(&v50, 0, sizeof(v50));
sub_100155A98((std::string *)(v57.__r_.__value_.__r.__words[0] + 24), ";", (__int64)&v50);
v35 = v50.__r_.__value_.__r.__words[0];
if ( v50.__r_.__value_.__l.__size_ != v50.__r_.__value_.__r.__words[0] )
{
v36 = 0;
do
{
v37 = v51;
v38 = v52;
if ( v52 != v51 )
{
do
{
v39 = *((char *)v38 - 1);
v38 -= 3;
if ( v39 < 0 )
operator delete(*v38);
}
while ( v38 != v37 );
v35 = v50.__r_.__value_.__r.__words[0];
}
v52 = v37;
sub_100155A98((std::string *)(v35 + 24 * v36), ",", (__int64)&v51);
v40 = v51;
if ( 0xAAAAAAAAAAAAAAABLL * (v52 - v51) >= 2 )
{
v41 = a1->m_sfxArtists;
if ( *((char *)v51 + 23) < 0 )
{
sub_1000097D0(v46, *v51, (unsigned __int64)v51[1]);
v40 = v51;
}
else
{
v42 = *(_OWORD *)v51;
v47 = v51[2];
*(_OWORD *)v46 = v42;
}
if ( *((char *)v40 + 47) < 0 )
{
sub_1000097D0(v44, v40[3], (unsigned __int64)v40[4]);
}
else
{
*(_OWORD *)v44 = *(_OWORD *)(v40 + 3);
v45 = v40[5];
}
v43 = CCURLObject::create(v46, v44);
sub_10024A2D0(v41, v43);
if ( SHIBYTE(v45) < 0 )
operator delete(v44[0]);
if ( SHIBYTE(v47) < 0 )
operator delete(v46[0]);
}
++v36;
v35 = v50.__r_.__value_.__r.__words[0];
}
while ( 0xAAAAAAAAAAAAAAABLL
* ((__int64)(v50.__r_.__value_.__l.__size_ - v50.__r_.__value_.__r.__words[0]) >> 3) > v36 );
}
v61 = &v50;
sub_1000177FC((void ***)&v61);
v50.__r_.__value_.__r.__words[0] = (std::string::size_type)&v51;
sub_1000177FC((void ***)&v50);
v51 = (void **)&v54;
sub_1000177FC(&v51);
}
v54 = &v57;
sub_1000177FC((void ***)&v54);
v6 = HIBYTE(v58.__r_.__value_.__r.__words[2]);
}
if ( v6 < 0 )
operator delete(v58.__r_.__value_.__l.__data_);
}
if ( SHIBYTE(v60.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v60.__r_.__value_.__l.__data_);
}