//
// MusicDownloadManager::onDownloadSFXCompleted from 0x100594f00 to 0x100595131 (561 bytes)
//
// 1 xrefs:
// > MusicDownloadManager::downloadSFX @ 0x100594da2
//
// 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::onDownloadSFXCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
double v3; // xmm0_8
cocos2d::extension::CCHttpRequest *pHttpRequest; // rdi
const char *longStorage; // rdi
unsigned int v8; // r14d
cocos2d::CCString *v9; // rax
const char *CString; // rax
const char *data; // rdi
bool shouldCancel; // r15
int v13; // eax
unsigned int v14; // r15d
__int64 v15; // rax
FILE *v16; // rax
FILE *v17; // r12
unsigned int v18; // r15d
__int64 v19; // rax
unsigned int v20; // r15d
__int64 v21; // rax
unsigned int v22; // r15d
__int64 v23; // rax
char v24; // [rsp+0h] [rbp-40h]
std::string v25; // [rsp+8h] [rbp-38h] BYREF
pHttpRequest = a3->_pHttpRequest;
if ( (pHttpRequest->_tag.m_data.m_short.sizex2 & 1) != 0 )
longStorage = pHttpRequest->_tag.m_data.m_long.longStorage;
else
longStorage = pHttpRequest->_tag.m_data.m_short.shortStorage.__elems_;
v8 = atoi(longStorage);
v9 = (cocos2d::CCString *)sub_1007AB580("sfx_%i", v24);
CString = cocos2d::CCString::getCString(v9);
MusicDownloadManager::removeDLFromActive(a1, CString);
if ( a3->_succeed )
{
MusicDownloadManager::pathForSFX(&v25, v3, (__int64)a1, v8);
if ( (*(_BYTE *)&v25.__r_.__value_.__s.0 & 1) != 0 )
data = v25.__r_.__value_.__l.__data_;
else
data = v25.__r_.__value_.__s.__data_;
v16 = fopen(data, "wb");
v17 = v16;
if ( v16 )
{
fwrite(a3->_responseData.__begin_, 1u, a3->_responseData.__end_ - a3->_responseData.__begin_, v16);
fclose(v17);
if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v18 = 0;
do
{
v19 = sub_1007200C0(a1->m_musicDownloadDelegates, v18);
(*(void (__fastcall **)(_QWORD, _QWORD))(**(_QWORD **)(v19 + 320) + 48LL))(*(_QWORD *)(v19 + 320), v8);
++v18;
}
while ( v18 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
}
else if ( (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) )
{
v22 = 0;
do
{
v23 = sub_1007200C0(a1->m_musicDownloadDelegates, v22);
(*(void (__fastcall **)(_QWORD, _QWORD, _QWORD))(**(_QWORD **)(v23 + 320) + 56LL))(
*(_QWORD *)(v23 + 320),
v8,
0);
++v22;
}
while ( v22 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
if ( (*(_BYTE *)&v25.__r_.__value_.__s.0 & 1) != 0 )
operator delete(v25.__r_.__value_.__l.__data_);
}
else
{
shouldCancel = a3->_pHttpRequest->_shouldCancel;
v13 = sub_100720070(a1->m_musicDownloadDelegates);
if ( shouldCancel )
{
if ( v13 )
{
v14 = 0;
do
{
v15 = sub_1007200C0(a1->m_musicDownloadDelegates, v14);
(*(void (__fastcall **)(_QWORD, _QWORD, __int64))(**(_QWORD **)(v15 + 320) + 56LL))(
*(_QWORD *)(v15 + 320),
v8,
3);
++v14;
}
while ( v14 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
}
else if ( v13 )
{
v20 = 0;
do
{
v21 = sub_1007200C0(a1->m_musicDownloadDelegates, v20);
(*(void (__fastcall **)(_QWORD, _QWORD, _QWORD))(**(_QWORD **)(v21 + 320) + 56LL))(
*(_QWORD *)(v21 + 320),
v8,
0);
++v20;
}
while ( v20 < (unsigned int)sub_100720070(a1->m_musicDownloadDelegates) );
}
}
}