//
// MusicDownloadManager::onDownloadSFXLibraryCompleted from 0x831508 to 0x8316c0 (440 bytes)
//
// 3 xrefs:
// > ??> @ 0xb0250
// > MusicDownloadManager::downloadSFXLibrary @ 0x82cf78
// > ??> @ 0x122e168
//
// 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::onDownloadSFXLibraryCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
FILE *v5; // x22
char *v6; // x2
char *v7; // x0
unsigned int *v8; // x2
int v9; // w1
unsigned int *v10; // x2
char *filename; // [xsp+40h] [xbp+40h] BYREF
MusicDownloadManager::removeDLFromActive(a1, "dl_sfx_l");
if ( !a3 || !a3->_succeed )
{
MusicDownloadManager::musicActionFailed(a1, (GJMusicAction)1);
return;
}
MusicDownloadManager::pathForSFXFolder(a1, 0, (__int64)&filename);
sub_D15FD4(&filename, "sfxlibrary.dat", 14);
v5 = fopen(filename, "wb");
if ( v5 )
{
fwrite(a3->_responseData.m_start, 1u, a3->_responseData.m_finish - a3->_responseData.m_start, v5);
fclose(v5);
MusicDownloadManager::parseSFXLibrary(a1);
MusicDownloadManager::musicActionFinished(a1, (GJMusicAction)1);
v6 = filename;
v7 = filename - 24;
if ( filename - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v8 = (unsigned int *)(filename - 8);
do
v9 = __ldaxr(v8);
while ( __stlxr(v9 - 1, v8) );
goto LABEL_10;
}
}
else
{
MusicDownloadManager::musicActionFailed(a1, (GJMusicAction)1);
v6 = filename;
v7 = filename - 24;
if ( filename - 24 == (char *)&qword_124B6B0 )
return;
if ( &pthread_create )
{
v10 = (unsigned int *)(filename - 8);
do
v9 = __ldaxr(v10);
while ( __stlxr(v9 - 1, v10) );
goto LABEL_10;
}
}
v9 = *((_DWORD *)v6 - 2);
*((_DWORD *)v6 - 2) = v9 - 1;
LABEL_10:
if ( v9 <= 0 )
operator delete(v7);
}