//
// MusicDownloadManager::onDownloadSongCompleted from 0x572810 to 0x572918 (264 bytes)
//
// 0 xrefs:
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 11:52:39 +0000
//
unsigned int __fastcall MusicDownloadManager::onDownloadSongCompleted(
MusicDownloadManager *this,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
int v5; // r5
const char *v6; // r0
const char *v7; // r5
const char *SongDownloadKey; // r0
int v9; // r2
char *v11; // r0
FILE *v12; // r7
GameManager *SongInfoObject; // r0
GameManager *v14; // r7
GameManager *v15; // r0
char v16; // [sp+0h] [bp-14h] BYREF
char v17; // [sp+1h] [bp-13h] BYREF
char *filename; // [sp+8h] [bp-Ch]
v5 = *((_DWORD *)a3 + 13);
if ( (*(_BYTE *)(v5 + 80) & 1) != 0 )
v6 = *(const char **)(v5 + 88);
else
v6 = (const char *)(v5 + 81);
v7 = (const char *)atoi(v6);
SongDownloadKey = (const char *)MusicDownloadManager::getSongDownloadKey(this, v7);
MusicDownloadManager::removeDLFromActive(this, SongDownloadKey);
if ( *((_BYTE *)a3 + 56) )
{
MusicDownloadManager::pathForSong((MusicDownloadManager *)&v16, this, (int)v7);
if ( (v16 & 1) != 0 )
v11 = filename;
else
v11 = &v17;
v12 = fopen(v11, "wb");
if ( v12 )
{
fwrite(*((const void **)a3 + 15), 1u, *((_DWORD *)a3 + 16) - *((_DWORD *)a3 + 15), v12);
fclose(v12);
SongInfoObject = MusicDownloadManager::getSongInfoObject(this, v7);
v14 = SongInfoObject;
if ( SongInfoObject )
{
SongInfoObject = (GameManager *)MusicDownloadManager::getSongPriority(this);
*((_DWORD *)v14 + 83) = SongInfoObject;
}
v15 = (GameManager *)GameManager::sharedState(SongInfoObject);
if ( !GameManager::getGameVariable(v15, "0018") )
MusicDownloadManager::limitDownloadedSongs(this);
MusicDownloadManager::downloadSongFinished((cocos2d::CCArray **)this, (int)v7);
}
else
{
MusicDownloadManager::downloadSongFailed((int)this, (int)v7, 0);
}
return std::string::~string((int)&v16);
}
else
{
if ( *(_BYTE *)(*((_DWORD *)a3 + 13) + 124) )
v9 = 3;
else
v9 = 0;
return MusicDownloadManager::downloadSongFailed((int)this, (int)v7, v9);
}
}