//
// MusicDownloadManager::onDownloadMusicLibraryCompleted from 0x100591cb0 to 0x100591ecf (543 bytes)
//
// 1 xrefs:
// > MusicDownloadManager::downloadMusicLibrary @ 0x100591bb3
//
// 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::onDownloadMusicLibraryCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
const char *data; // rdi
unsigned int v6; // r14d
__int64 v7; // rax
FILE *v8; // rax
FILE *v9; // r15
cocos2d::CCDictionary *m_musicObjects; // rdi
unsigned int v11; // r14d
__int64 v12; // rax
unsigned int v13; // r14d
__int64 v14; // rax
unsigned int v15; // r14d
__int64 v16; // rax
std::string v17; // [rsp+0h] [rbp-30h] BYREF
MusicDownloadManager::removeDLFromActive(a1, "dl_music_l");
if ( a3 && a3->_succeed )
{
MusicDownloadManager::pathForSongFolder(&v17, (__int64)a1, 0);
std::string::append(&v17, "musiclibrary.dat");
if ( (*(_BYTE *)&v17.__r_.__value_.__s.0 & 1) != 0 )
data = v17.__r_.__value_.__l.__data_;
else
data = v17.__r_.__value_.__s.__data_;
v8 = fopen(data, "wb");
v9 = v8;
if ( v8 )
{
fwrite(a3->_responseData.__begin_, 1u, a3->_responseData.__end_ - a3->_responseData.__begin_, v8);
fclose(v9);
MusicDownloadManager::parseMusicLibrary(a1);
m_musicObjects = a1->m_musicObjects;
if ( m_musicObjects && cocos2d::CCDictionary::count(m_musicObjects) )
{
if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v11 = 0;
do
{
v12 = sub_1007200C0(a1->m_musicDownloadDelegates, v11);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(v12 + 320) + 64LL))(*(_QWORD *)(v12 + 320), 7);
++v11;
}
while ( v11 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
}
else if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v13 = 0;
do
{
v14 = sub_1007200C0(a1->m_musicDownloadDelegates, v13);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(v14 + 320) + 72LL))(*(_QWORD *)(v14 + 320), 7);
++v13;
}
while ( v13 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
}
else if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v15 = 0;
do
{
v16 = sub_1007200C0(a1->m_musicDownloadDelegates, v15);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(v16 + 320) + 72LL))(*(_QWORD *)(v16 + 320), 7);
++v15;
}
while ( v15 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
if ( (*(_BYTE *)&v17.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v17.__r_.__value_.__l.__data_);
}
else if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v6 = 0;
do
{
v7 = sub_1007200C0(a1->m_musicDownloadDelegates, v6);
(*(void (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(v7 + 320) + 72LL))(*(_QWORD *)(v7 + 320), 7);
++v6;
}
while ( v6 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
}