//
// MusicDownloadManager::onDownloadSongCompleted from 0x96d1e0 to 0x96d388 (424 bytes)
//
// 4 xrefs:
// > ??> @ 0x72178
// > MusicDownloadManager::downloadCustomSong @ 0x968400
// > MusicDownloadManager::downloadSong @ 0x9687d0
// > ??> @ 0x1542dd0
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:57:39 +0000
//
__int64 __fastcall MusicDownloadManager::onDownloadSongCompleted(
MusicDownloadManager *this,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
__int64 v5; // x1
const char *v6; // x0
unsigned int v7; // w22
const char *SongDownloadKey; // x0
unsigned int v9; // w2
const char *v11; // x0
FILE *v12; // x23
GameManager *SongInfoObject; // x0
GameManager *v14; // x21
GameManager *v15; // x0
__int64 v16[2]; // [xsp+40h] [xbp+40h] BYREF
void *v17; // [xsp+50h] [xbp+50h]
v5 = *((_QWORD *)a3 + 7);
v6 = (const char *)(v5 + 113);
if ( (*(_BYTE *)(v5 + 112) & 1) != 0 )
v6 = *(const char **)(v5 + 128);
v7 = atoi(v6);
SongDownloadKey = (const char *)MusicDownloadManager::getSongDownloadKey(this, (const char *)v7);
MusicDownloadManager::removeDLFromActive(this, SongDownloadKey);
if ( *((_BYTE *)a3 + 64) )
{
MusicDownloadManager::pathForSong(v16, this, v7);
v11 = (char *)v16 + 1;
if ( (v16[0] & 1) != 0 )
v11 = (const char *)v17;
v12 = fopen(v11, "wb");
if ( v12 )
{
fwrite(*((const void **)a3 + 9), 1u, *((_QWORD *)a3 + 10) - *((_QWORD *)a3 + 9), v12);
fclose(v12);
SongInfoObject = (GameManager *)MusicDownloadManager::getSongInfoObject(this, (const char *)v7);
v14 = SongInfoObject;
if ( SongInfoObject )
{
SongInfoObject = (GameManager *)MusicDownloadManager::getSongPriority(this);
*((_DWORD *)v14 + 109) = (_DWORD)SongInfoObject;
}
v15 = (GameManager *)GameManager::sharedState(SongInfoObject);
if ( !(unsigned __int8)GameManager::getGameVariable(v15, "0018") )
MusicDownloadManager::limitDownloadedSongs(this);
MusicDownloadManager::downloadSongFinished((cocos2d::CCArray **)this, v7);
}
else
{
MusicDownloadManager::downloadSongFailed((__int64)this, v7, 0);
}
if ( (v16[0] & 1) != 0 )
operator delete(v17);
}
else
{
if ( *(_BYTE *)(*((_QWORD *)a3 + 7) + 196LL) )
v9 = 3;
else
v9 = 0;
MusicDownloadManager::downloadSongFailed((__int64)this, v7, v9);
}
return _stack_chk_guard;
}