//
// MusicDownloadManager::downloadSFX from 0x100594c10 to 0x100594e45 (565 bytes)
//
// 3 xrefs:
// > CustomSFXWidget::onDownload @ 0x1005e3a12
// > CustomSFXWidget::startDownload @ 0x1005e4905
// > CustomSongWidget::processNextMultiAsset @ 0x1006212c6
//
// 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::downloadSFX(MusicDownloadManager *a1, int a2)
{
double v2; // xmm0_8
unsigned int sizex2; // eax
cocos2d::CCString *v4; // rax
const char *CString; // r14
const std::string::value_type *v6; // rsi
std::string::size_type v7; // rdx
char v8; // r12
char *Request; // r15
char v10; // [rsp+0h] [rbp-D0h]
__int128 v11; // [rsp+8h] [rbp-C8h] BYREF
void *v12; // [rsp+18h] [rbp-B8h]
__int128 v13; // [rsp+20h] [rbp-B0h] BYREF
void *__p; // [rsp+30h] [rbp-A0h]
__int128 v15; // [rsp+40h] [rbp-90h] BYREF
void *v16; // [rsp+50h] [rbp-80h]
__int128 v17; // [rsp+60h] [rbp-70h] BYREF
void *v18; // [rsp+70h] [rbp-60h]
std::string::value_type __s[16]; // [rsp+80h] [rbp-50h] BYREF
void *v20; // [rsp+90h] [rbp-40h]
std::string v21; // [rsp+98h] [rbp-38h] BYREF
sizex2 = a1->m_customContentURL.m_data.m_short.sizex2;
if ( (sizex2 & 1) != 0 )
{
if ( !a1->m_customContentURL.m_data.m_long.size )
return;
}
else if ( !(sizex2 >> 1) )
{
return;
}
v4 = (cocos2d::CCString *)sub_1007AB580("sfx_%i", v10);
CString = cocos2d::CCString::getCString(v4);
if ( !MusicDownloadManager::getDLObject(a1, CString) )
{
GameToolbox::intToString((size_t *)__s, a2, v2);
v21.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)12;
strcpy(v21.__r_.__value_.__s.__data_, "/sfx/s");
if ( (__s[0] & 1) != 0 )
{
v6 = (const std::string::value_type *)v20;
v7 = *(_QWORD *)&__s[8];
}
else
{
v7 = (unsigned __int8)__s[0] >> 1;
v6 = &__s[1];
}
std::string::append(&v21, v6, v7);
std::string::append(&v21, ".ogg");
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v13, v21.__r_.__value_.__l.__data_, v21.__r_.__value_.__l.__size_, v2);
}
else
{
__p = v21.__r_.__value_.__l.__data_;
v2 = *(double *)v21.__r_.__value_.__r.__words;
v13 = *(_OWORD *)&v21.__r_.__value_.__l.0;
}
MusicDownloadManager::generateCustomContentURL((size_t *)&v11, (__int64)a1, v2);
if ( (v13 & 1) != 0 )
operator delete(__p);
v8 = v11;
if ( (v11 & 1) != 0 )
{
sub_100006B70(&v15, v12, *((unsigned __int64 *)&v11 + 1), v2);
}
else
{
v16 = v12;
v2 = *(double *)&v11;
v15 = v11;
}
if ( (__s[0] & 1) != 0 )
{
sub_100006B70(&v17, v20, *(unsigned __int64 *)&__s[8], v2);
}
else
{
v18 = v20;
v17 = *(_OWORD *)__s;
}
Request = MusicDownloadManager::ProcessHttpGetRequest(
a1,
(__int64)&v15,
(__int64)&v17,
(__int64)MusicDownloadManager::onDownloadSFXCompleted,
0,
5,
10);
if ( (v17 & 1) != 0 )
operator delete(v18);
if ( (v15 & 1) != 0 )
operator delete(v16);
MusicDownloadManager::addDLToActive(a1, CString, (cocos2d::CCObject *)Request);
if ( (v8 & 1) != 0 )
{
operator delete(v12);
if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_26:
if ( (__s[0] & 1) == 0 )
return;
goto LABEL_27;
}
}
else if ( (*(_BYTE *)&v21.__r_.__value_.__s.0 & 1) == 0 )
{
goto LABEL_26;
}
operator delete(v21.__r_.__value_.__l.__data_);
if ( (__s[0] & 1) == 0 )
return;
LABEL_27:
operator delete(v20);
}
}