//
// MusicDownloadManager::onDownloadMusicLibraryCompleted from 0x140340bd0 to 0x140340d76 (422 bytes)
//
// 2 xrefs:
// > MusicDownloadManager::downloadMusicLibrary @ 0x140340af2
// > ??> @ 0x1406d5774
//
// 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
//
// Hidden C++ exception states: #wind=2
void MusicDownloadManager::onDownloadMusicLibraryCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
void *v5; // rcx
const char *v6; // rcx
FILE *v7; // rax
FILE *v8; // rsi
cocos2d::CCDictionary *m_musicObjects; // rcx
void *Block[2]; // [rsp+20h] [rbp-58h] BYREF
__int64 v11; // [rsp+30h] [rbp-48h]
unsigned __int64 v12; // [rsp+38h] [rbp-40h]
char *FileName[4]; // [rsp+40h] [rbp-38h] BYREF
Block[1] = (void *)27743;
v11 = 10;
v12 = 15;
Block[0] = (void *)0x636973756D5F6C64LL;
cocos2d::CCDictionary::removeObjectForKey(a1->m_activeDownloads, Block);
if ( v12 > 0xF )
{
v5 = Block[0];
if ( v12 + 1 >= 0x1000 )
{
v5 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v5 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v5);
}
if ( a3 && a3->_succeed )
{
MusicDownloadManager::pathForSongFolder((__int64)a1, FileName, 0);
sub_140041270(FileName, "musiclibrary.dat", 0x10u);
v6 = (const char *)FileName;
if ( FileName[3] > (char *)0xF )
v6 = FileName[0];
v7 = fopen(v6, "wb");
v8 = v7;
if ( v7
&& (fwrite(
a3->_responseData._Mypair._Myval2._Myfirst,
1u,
a3->_responseData._Mypair._Myval2._Mylast - a3->_responseData._Mypair._Myval2._Myfirst,
v7),
fclose(v8),
MusicDownloadManager::parseMusicLibrary(a1),
(m_musicObjects = a1->m_musicObjects) != nullptr)
&& cocos2d::CCDictionary::count(m_musicObjects) )
{
MusicDownloadManager::musicActionFinished(a1, UpdateMusicLibrary|0x1);
}
else
{
MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);
}
sub_14003A830((__int64)FileName);
}
else
{
MusicDownloadManager::musicActionFailed(a1, UpdateMusicLibrary|0x1);
}
}