//
// MusicDownloadManager::downloadSFX from 0x10065ec30 to 0x10065ee65 (565 bytes)
//
// 5 xrefs:
// > CustomSFXWidget::onDownload @ 0x1006b69c2
// > CustomSFXWidget::startDownload @ 0x1006b84b5
// > CustomSongWidget::processNextMultiAsset @ 0x1006fda36
// > sub_1008EE290 @ 0x1008ee33a
// > sub_1008F8520 @ 0x1008f857c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:34:55 +0000
//
void __fastcall MusicDownloadManager::downloadSFX(__int64 a1, int a2)
{
unsigned int v2; // eax
__int64 v3; // rax
const char *CString; // r14
const std::string::value_type *v5; // rsi
std::string::size_type v6; // rdx
char v7; // r12
char *Request; // r15
char v9; // [rsp+0h] [rbp-D0h]
__int128 v10; // [rsp+8h] [rbp-C8h] BYREF
void *v11; // [rsp+18h] [rbp-B8h]
__int128 v12; // [rsp+20h] [rbp-B0h] BYREF
void *__p; // [rsp+30h] [rbp-A0h]
__int128 v14; // [rsp+40h] [rbp-90h] BYREF
void *v15; // [rsp+50h] [rbp-80h]
__int128 v16; // [rsp+60h] [rbp-70h] BYREF
void *v17; // [rsp+70h] [rbp-60h]
std::string::value_type __s[16]; // [rsp+80h] [rbp-50h] BYREF
void *v19; // [rsp+90h] [rbp-40h]
std::string v20; // [rsp+98h] [rbp-38h] BYREF
v2 = *(unsigned __int8 *)(a1 + 368);
if ( (v2 & 1) != 0 )
{
if ( !*(_QWORD *)(a1 + 376) )
return;
}
else if ( !(v2 >> 1) )
{
return;
}
v3 = sub_10088E820("sfx_%i", v9);
CString = (const char *)cocos2d::CCString::getCString(v3);
if ( !MusicDownloadManager::getDLObject(a1, CString) )
{
GameToolbox::intToString((size_t *)__s, a2);
v20.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)12;
strcpy(v20.__r_.__value_.__s.__data_, "/sfx/s");
if ( (__s[0] & 1) != 0 )
{
v5 = (const std::string::value_type *)v19;
v6 = *(_QWORD *)&__s[8];
}
else
{
v6 = (unsigned __int8)__s[0] >> 1;
v5 = &__s[1];
}
std::string::append(&v20, v5, v6);
std::string::append(&v20, ".ogg");
if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) != 0 )
{
sub_10001AD30(&v12, v20.__r_.__value_.__l.__data_, v20.__r_.__value_.__l.__size_);
}
else
{
__p = v20.__r_.__value_.__l.__data_;
v12 = *(_OWORD *)&v20.__r_.__value_.__l.0;
}
MusicDownloadManager::generateCustomContentURL((size_t *)&v10, a1);
if ( (v12 & 1) != 0 )
operator delete(__p);
v7 = v10;
if ( (v10 & 1) != 0 )
{
sub_10001AD30(&v14, v11, *((unsigned __int64 *)&v10 + 1));
}
else
{
v15 = v11;
v14 = v10;
}
if ( (__s[0] & 1) != 0 )
{
sub_10001AD30(&v16, v19, *(unsigned __int64 *)&__s[8]);
}
else
{
v17 = v19;
v16 = *(_OWORD *)__s;
}
Request = MusicDownloadManager::ProcessHttpGetRequest(
a1,
(__int64)&v14,
(__int64)&v16,
(__int64)MusicDownloadManager::onDownloadSFXCompleted,
0,
5,
10);
if ( (v16 & 1) != 0 )
operator delete(v17);
if ( (v14 & 1) != 0 )
operator delete(v15);
MusicDownloadManager::addDLToActive(a1, CString, (__int64)Request);
if ( (v7 & 1) != 0 )
{
operator delete(v11);
if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_26:
if ( (__s[0] & 1) == 0 )
return;
goto LABEL_27;
}
}
else if ( (*(_BYTE *)&v20.__r_.__value_.__s.0 & 1) == 0 )
{
goto LABEL_26;
}
operator delete(v20.__r_.__value_.__l.__data_);
if ( (__s[0] & 1) == 0 )
return;
LABEL_27:
operator delete(v19);
}
}