//
// CustomSongWidget::processNextMultiAsset from 0x86cd28 to 0x86d00c (740 bytes)
//
// 5 xrefs:
// > CustomSongWidget::processNextMultiAsset @ 0x86ce40
// > CustomSongWidget::downloadAssetFailed @ 0x86d14c
// > CustomSongWidget::startMultiAssetDownload @ 0x86d328
// > CustomSongWidget::downloadAssetFinished @ 0x86db1c
// > ??> @ 0xeb000
//
// 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:55:44 +0000
//
__int64 __fastcall CustomSongWidget::processNextMultiAsset(CustomSongWidget *this)
{
cocos2d::extension::CCHttpClient *v2; // x1
cocos2d::extension::CCHttpClient *v3; // x0
cocos2d::extension::CCHttpClient *Instance; // x0
__int64 v5; // x0
__int64 v6; // x19
__int64 v7; // x1
unsigned __int64 v8; // x22
__int64 v9; // x0
void (__fastcall *v10)(__int64, char **); // x2
__int64 SongInfo; // x0
cocos2d::extension::CCHttpClient *v12; // x0
unsigned __int64 v13; // x0
MusicDownloadManager *v15; // x0
int v16; // w19
__int64 v17; // x0
__int64 **v18; // x23
int v19; // w1
bool v20; // cc
__int64 v21; // x1
int v22; // w1
__int64 v23; // x0
__int64 v24; // x1
__int64 *v25; // x1
MusicDownloadManager *v26; // x0
MusicDownloadManager *v27; // x0
char *v28; // [xsp+40h] [xbp+40h] BYREF
v2 = *((cocos2d::extension::CCHttpClient **)this + 75);
v3 = *((cocos2d::extension::CCHttpClient **)this + 76);
if ( v2 == v3 )
{
(*(void (__fastcall **)(_QWORD, void *))(**((_QWORD **)this + 47) + 1072LL))(*((_QWORD *)this + 47), &unk_114B370);
(*(void (__fastcall **)(_QWORD, const char *))(**((_QWORD **)this + 47) + 928LL))(
*((_QWORD *)this + 47),
"Download complete.");
if ( *((_BYTE *)this + 501) )
cocos2d::CCLabelBMFont::limitLabelWidth(*((cocos2d::CCLabelBMFont **)this + 47), 140.0, 0.35, 0.0);
else
cocos2d::CCLabelBMFont::limitLabelWidth(*((cocos2d::CCLabelBMFont **)this + 47), 230.0, 0.4, 0.0);
CustomSongWidget::showError((cocos2d::CCNode **)this, 1u);
*((_BYTE *)this + 545) = 0;
CustomSongWidget::updateMultiAssetInfo(this, 1u);
}
else
{
Instance = (cocos2d::extension::CCHttpClient *)cocos2d::extension::CCHttpClient::getInstance(v3);
v5 = cocos2d::extension::CCHttpClient::availableThreadCount(Instance);
v6 = *((_QWORD *)this + 75);
v7 = *((_QWORD *)this + 76);
v8 = v5;
if ( v6 != v7 )
{
while ( *(_BYTE *)(v6 + 12) )
{
v6 += 16;
if ( v7 == v6 )
return _stack_chk_guard;
}
if ( *(int *)(v6 + 8) <= 1 )
{
SongInfo = *(unsigned int *)(v6 + 4);
*(_BYTE *)(v6 + 12) = 1;
if ( (_DWORD)SongInfo == 1 )
{
v16 = *(_DWORD *)v6;
if ( v16 > (int)&loc_98967C + 3 )
{
v27 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)((char *)&loc_98967C + 3));
SongInfo = MusicDownloadManager::downloadSong(v27, v16);
}
else
{
v17 = *((_QWORD *)this + 80);
v18 = (__int64 **)((char *)this + 640);
if ( v17 )
{
v19 = *(_DWORD *)(v17 + 28);
v20 = v16 <= v19;
if ( v16 >= v19 )
goto LABEL_24;
while ( 1 )
{
v21 = *(_QWORD *)v17;
if ( !*(_QWORD *)v17 )
break;
while ( 1 )
{
v17 = v21;
v22 = *(_DWORD *)(v21 + 28);
v20 = v16 <= v22;
if ( v16 < v22 )
break;
LABEL_24:
if ( v20 )
goto LABEL_30;
v21 = *(_QWORD *)(v17 + 8);
if ( !v21 )
{
v28 = (char *)v17;
v18 = (__int64 **)(v17 + 8);
goto LABEL_27;
}
}
}
v28 = (char *)v17;
v18 = (__int64 **)v17;
}
else
{
v28 = (char *)this + 640;
}
LABEL_27:
v23 = operator new(0x20u);
*(_DWORD *)(v23 + 28) = v16;
*(_QWORD *)(v23 + 16) = v28;
*(_QWORD *)v23 = 0;
*(_QWORD *)(v23 + 8) = 0;
*v18 = (__int64 *)v23;
v24 = **((_QWORD **)this + 79);
if ( v24 )
{
*((_QWORD *)this + 79) = v24;
v25 = *v18;
}
else
{
v25 = (__int64 *)v23;
}
std::__tree_balance_after_insert *>(*((__int64 **)this + 80), v25);
v17 = *((_QWORD *)this + 81) + 1LL;
*((_QWORD *)this + 81) = v17;
LABEL_30:
v26 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)v17);
SongInfo = MusicDownloadManager::getSongInfo(v26, v16, 0);
}
}
else if ( (_DWORD)SongInfo == 2 )
{
v15 = (MusicDownloadManager *)MusicDownloadManager::sharedState((MusicDownloadManager *)SongInfo);
SongInfo = MusicDownloadManager::downloadSFX(v15, *(_DWORD *)v6);
}
}
else
{
CustomSongWidget::updateMultiAssetInfo(this, 1u);
v9 = *((_QWORD *)this + 47);
v10 = *(void (__fastcall **)(__int64, char **))(*(_QWORD *)v9 + 1072LL);
LOWORD(v28) = 13055;
BYTE2(v28) = 25;
v10(v9, &v28);
(*(void (__fastcall **)(_QWORD, const char *))(**((_QWORD **)this + 47) + 928LL))(
*((_QWORD *)this + 47),
"Some assets failed to download.");
cocos2d::CCLabelBMFont::limitLabelWidth(*((cocos2d::CCLabelBMFont **)this + 47), 230.0, 0.4, 0.0);
SongInfo = CustomSongWidget::showError((cocos2d::CCNode **)this, 0);
}
v12 = (cocos2d::extension::CCHttpClient *)cocos2d::extension::CCHttpClient::getInstance((cocos2d::extension::CCHttpClient *)SongInfo);
v13 = cocos2d::extension::CCHttpClient::availableThreadCount(v12);
if ( *((_QWORD *)this + 75) != *((_QWORD *)this + 76) && v13 && v8 > v13 )
CustomSongWidget::processNextMultiAsset(this);
}
}
return _stack_chk_guard;
}