//
// MusicDownloadManager::onDownloadSFXCompleted from 0x82f2a0 to 0x82f470 (464 bytes)
//
// 3 xrefs:
// > ??> @ 0x54318
// > MusicDownloadManager::downloadSFX @ 0x82c7a8
// > ??> @ 0x122ab50
//
// 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 MusicDownloadManager::onDownloadSFXCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
int v5; // w22
const char *SFXDownloadKey; // x0
GJSongError v7; // w2
FILE *v8; // x23
char *v9; // x2
char *v10; // x0
unsigned int *v11; // x2
int v12; // w1
unsigned int *v13; // x2
char *filename; // [xsp+50h] [xbp+50h] BYREF
v5 = atoi((const char *)a3->_pHttpRequest->_tag.m_data.m_data);
SFXDownloadKey = MusicDownloadManager::getSFXDownloadKey(a1, v5);
MusicDownloadManager::removeDLFromActive(a1, SFXDownloadKey);
if ( !a3->_succeed )
{
if ( a3->_pHttpRequest->_shouldCancel )
v7 = DownloadCancelled;
else
v7 = 0;
MusicDownloadManager::downloadSFXFailed(a1, v5, v7);
return;
}
MusicDownloadManager::pathForSFX((__int64 *)&filename, a1, v5);
v8 = fopen(filename, "wb");
if ( v8 )
{
fwrite(a3->_responseData.m_start, 1u, a3->_responseData.m_finish - a3->_responseData.m_start, v8);
fclose(v8);
MusicDownloadManager::downloadSFXFinished(a1, v5);
v9 = filename;
v10 = filename - 24;
if ( filename - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v11 = (unsigned int *)(filename - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
goto LABEL_12;
}
LABEL_19:
v12 = *((_DWORD *)v9 - 2);
*((_DWORD *)v9 - 2) = v12 - 1;
goto LABEL_12;
}
MusicDownloadManager::downloadSFXFailed(a1, v5, (GJSongError)0);
v9 = filename;
v10 = filename - 24;
if ( filename - 24 == (char *)&qword_124B6B0 )
return;
if ( !&pthread_create )
goto LABEL_19;
v13 = (unsigned int *)(filename - 8);
do
v12 = __ldaxr(v13);
while ( __stlxr(v12 - 1, v13) );
LABEL_12:
if ( v12 <= 0 )
operator delete(v10);
}