//
// MusicDownloadManager::downloadSFX from 0x1001598ec to 0x100159ac8 (476 bytes)
//
// 2 xrefs:
// > CustomSongWidget::processNextMultiAsset @ 0x1000fe610
// > CustomSFXWidget::startDownload @ 0x1002f15d8
//
// 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 MusicDownloadManager::downloadSFX(MusicDownloadManager *a1, int a2)
{
__int64 v2; // x21
cocos2d::CCString *v4; // x0
const char *CString; // x20
std::string *v6; // x0
const std::string::value_type *v7; // x1
std::string::size_type v8; // x2
char *Request; // x21
void *v10[2]; // [xsp+10h] [xbp-C0h] BYREF
__int64 v11; // [xsp+20h] [xbp-B0h]
void *__dst[2]; // [xsp+30h] [xbp-A0h] BYREF
__int64 v13; // [xsp+40h] [xbp-90h]
std::string __p; // [xsp+50h] [xbp-80h] BYREF
void *v15[2]; // [xsp+68h] [xbp-68h] BYREF
__int64 v16; // [xsp+78h] [xbp-58h]
std::string v17; // [xsp+80h] [xbp-50h] BYREF
__int128 v18; // [xsp+98h] [xbp-38h] BYREF
__int64 v19; // [xsp+A8h] [xbp-28h]
v2 = *(_QWORD *)&a2;
if ( (a1->m_customContentURL.m_data.m_short.shortStorage.__elems_[22] & 0x8000000000000000LL) != 0 )
{
if ( !a1->m_customContentURL.m_data.m_long.size )
return;
}
else if ( !a1->m_customContentURL.m_data.m_short.shortStorage.__elems_[22] )
{
return;
}
v4 = (cocos2d::CCString *)sub_100268F4C("sfx_%i", a2);
CString = cocos2d::CCString::getCString(v4);
if ( !MusicDownloadManager::getDLObject(a1, CString) )
{
GameToolbox::intToString(v2, &v18);
v6 = (std::string *)sub_100009900(&v17, "/sfx/s");
if ( v19 >= 0 )
v7 = (const std::string::value_type *)&v18;
else
v7 = (const std::string::value_type *)v18;
if ( v19 >= 0 )
v8 = HIBYTE(v19);
else
v8 = *((_QWORD *)&v18 + 1);
std::string::append(v6, v7, v8);
std::string::append(&v17, ".ogg");
if ( SHIBYTE(v17.__r_.__value_.__r.__words[2]) < 0 )
sub_1000097D0(&__p, v17.__r_.__value_.__l.__data_, v17.__r_.__value_.__l.__size_);
else
__p = v17;
MusicDownloadManager::generateCustomContentURL((__int64)a1, (const char *)&__p, v15);
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
if ( SHIBYTE(v16) < 0 )
{
sub_1000097D0(__dst, v15[0], (unsigned __int64)v15[1]);
}
else
{
*(_OWORD *)__dst = *(_OWORD *)v15;
v13 = v16;
}
if ( SHIBYTE(v19) < 0 )
{
sub_1000097D0(v10, (void *)v18, *((unsigned __int64 *)&v18 + 1));
}
else
{
*(_OWORD *)v10 = v18;
v11 = v19;
}
Request = MusicDownloadManager::ProcessHttpGetRequest(
a1,
(const std::string::value_type *)__dst,
(const std::string::value_type *)v10,
(__int64)MusicDownloadManager::onDownloadSFXCompleted,
0,
5,
10);
if ( SHIBYTE(v11) < 0 )
operator delete(v10[0]);
if ( SHIBYTE(v13) < 0 )
operator delete(__dst[0]);
MusicDownloadManager::addDLToActive(a1, CString, (cocos2d::CCObject *)Request);
if ( SHIBYTE(v16) < 0 )
operator delete(v15[0]);
if ( SHIBYTE(v17.__r_.__value_.__r.__words[2]) < 0 )
operator delete(v17.__r_.__value_.__l.__data_);
if ( SHIBYTE(v19) < 0 )
operator delete((void *)v18);
}
}