//
// MusicDownloadManager::downloadCustomSong from 0x10058f200 to 0x10058f48e (654 bytes)
//
// 1 xrefs:
// > MusicDownloadManager::downloadSong @ 0x10058ed33
//
// 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::downloadCustomSong(MusicDownloadManager *a1, int a2)
{
double v2; // xmm0_8
unsigned int sizex2; // eax
cocos2d::CCString *v5; // rax
const char *CString; // r14
unsigned int v7; // r12d
__int64 v8; // rdi
const std::string::value_type *v9; // rsi
std::string::size_type v10; // rdx
char v11; // r12
char *Request; // r15
char v13; // [rsp+0h] [rbp-D0h]
__int128 v14; // [rsp+8h] [rbp-C8h] BYREF
void *v15; // [rsp+18h] [rbp-B8h]
__int128 v16; // [rsp+20h] [rbp-B0h] BYREF
void *__p; // [rsp+30h] [rbp-A0h]
__int128 v18; // [rsp+40h] [rbp-90h] BYREF
void *v19; // [rsp+50h] [rbp-80h]
__int128 v20; // [rsp+60h] [rbp-70h] BYREF
void *v21; // [rsp+70h] [rbp-60h]
std::string::value_type __s[16]; // [rsp+80h] [rbp-50h] BYREF
void *v23; // [rsp+90h] [rbp-40h]
std::string v24; // [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;
}
v5 = (cocos2d::CCString *)sub_1007AB580("d_%i", v13);
CString = cocos2d::CCString::getCString(v5);
if ( !MusicDownloadManager::getDLObject(a1, CString) )
{
if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v7 = 0;
do
{
v8 = *(_QWORD *)(sub_1007200C0(a1->m_musicDownloadDelegates, v7) + 320);
if ( v8 )
(*(void (__fastcall **)(__int64, _QWORD))(*(_QWORD *)v8 + 16LL))(v8, (unsigned int)a2);
++v7;
}
while ( v7 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
GameToolbox::intToString((size_t *)__s, a2, v2);
v24.__r_.__value_.__s.0 = (std::string::__short::$7162EEB0FEF29CC674EFA33D0008C7E0)14;
strcpy(v24.__r_.__value_.__s.__data_, "/music/");
if ( (__s[0] & 1) != 0 )
{
v9 = (const std::string::value_type *)v23;
v10 = *(_QWORD *)&__s[8];
}
else
{
v10 = (unsigned __int8)__s[0] >> 1;
v9 = &__s[1];
}
std::string::append(&v24, v9, v10);
std::string::append(&v24, ".ogg");
if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) != 0 )
{
sub_100006B70(&v16, v24.__r_.__value_.__l.__data_, v24.__r_.__value_.__l.__size_, v2);
}
else
{
__p = v24.__r_.__value_.__l.__data_;
v2 = *(double *)v24.__r_.__value_.__r.__words;
v16 = *(_OWORD *)&v24.__r_.__value_.__l.0;
}
MusicDownloadManager::generateCustomContentURL(&v14, a1, &v16);
if ( (v16 & 1) != 0 )
operator delete(__p);
v11 = v14;
if ( (v14 & 1) != 0 )
{
sub_100006B70(&v18, v15, *((unsigned __int64 *)&v14 + 1), v2);
}
else
{
v19 = v15;
v2 = *(double *)&v14;
v18 = v14;
}
if ( (__s[0] & 1) != 0 )
{
sub_100006B70(&v20, v23, *(unsigned __int64 *)&__s[8], v2);
}
else
{
v21 = v23;
v20 = *(_OWORD *)__s;
}
Request = MusicDownloadManager::ProcessHttpGetRequest(
a1,
(__int64)&v18,
(__int64)&v20,
(__int64)MusicDownloadManager::onDownloadSongCompleted,
0,
0,
0);
if ( (v20 & 1) != 0 )
operator delete(v21);
if ( (v18 & 1) != 0 )
operator delete(v19);
MusicDownloadManager::addDLToActive(a1, CString, (cocos2d::CCObject *)Request);
if ( (v11 & 1) != 0 )
{
operator delete(v15);
if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_31:
if ( (__s[0] & 1) == 0 )
return;
goto LABEL_32;
}
}
else if ( (*(_BYTE *)&v24.__r_.__value_.__s.0 & 1) == 0 )
{
goto LABEL_31;
}
operator delete(v24.__r_.__value_.__l.__data_);
if ( (__s[0] & 1) == 0 )
return;
LABEL_32:
operator delete(v23);
}
}