//
// MusicDownloadManager::onDownloadSFXCompleted from 0x1403424a0 to 0x1403425f5 (341 bytes)
//
// 3 xrefs:
// > MusicDownloadManager::downloadSFX @ 0x140342401
// > ??> @ 0x1406d57d4
// > ??> @ 0x1406d57e0
//
// 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=1
void MusicDownloadManager::onDownloadSFXCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
const char *Tag; // rax
unsigned int v6; // esi
cocos2d::CCString *v7; // rax
const char *CString; // rax
const char *v9; // rcx
FILE *v10; // rax
FILE *v11; // rbp
unsigned int i; // ebx
struct cocos2d::CCObject *v13; // rax
char *FileName[4]; // [rsp+20h] [rbp-48h] BYREF
Tag = cocos2d::extension::CCHttpRequest::getTag(a3->_pHttpRequest);
v6 = atoi(Tag);
v7 = cocos2d::CCString::createWithFormat("sfx_%i", v6);
CString = cocos2d::CCString::getCString(v7);
MusicDownloadManager::removeDLFromActive(a1, CString);
if ( a3->_succeed )
{
MusicDownloadManager::pathForSFX((__int64)a1, FileName, v6);
v9 = (const char *)FileName;
if ( FileName[3] > (char *)0xF )
v9 = FileName[0];
v10 = fopen(v9, "wb");
v11 = v10;
if ( v10 )
{
fwrite(
a3->_responseData._Mypair._Myval2._Myfirst,
1u,
a3->_responseData._Mypair._Myval2._Mylast - a3->_responseData._Mypair._Myval2._Myfirst,
v10);
fclose(v11);
for ( i = 0; i < cocos2d::CCArray::count(a1->m_musicDownloadDelegates); ++i )
{
v13 = cocos2d::CCArray::objectAtIndex(a1->m_musicDownloadDelegates, i);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)&v13[5].m_unknown2 + 48LL))(
*(_QWORD *)&v13[5].m_unknown2,
v6);
}
}
else
{
MusicDownloadManager::downloadSFXFailed(a1, v6, (GJSongError)0);
}
sub_14003A830((__int64)FileName);
}
else
{
MusicDownloadManager::downloadSFXFailed(
a1,
v6,
BYTE4(a3->_pHttpRequest->_headers._Mypair._Myval2._Myend) != 0 ? DownloadCancelled : (GJSongError)0);
}
}