//
// CustomSongWidget::processNextMultiAsset from 0x4e56f8 to 0x4e58c2 (458 bytes)
//
// 4 xrefs:
// > CustomSongWidget::processNextMultiAsset @ 0x4e58ac
// > CustomSongWidget::downloadAssetFailed @ 0x4e5a08
// > CustomSongWidget::startMultiAssetDownload @ 0x4e5b30
// > CustomSongWidget::downloadAssetFinished @ 0x4e5d88
//
// 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:51:05 +0000
//
MusicDownloadManager *__fastcall CustomSongWidget::processNextMultiAsset(CustomSongWidget *this, int a2, int a3)
{
float v4; // r1
float v5; // r2
MusicDownloadManager *result; // r0
cocos2d::extension::CCHttpClient *Instance; // r0
int v8; // r5
MusicDownloadManager *v9; // r8
int v10; // r7
int v11; // r0
void (__fastcall *v12)(int, _DWORD *); // r3
int v13; // r3
int v14; // r7
_DWORD *v15; // r3
int v16; // r2
_DWORD *v17; // r2
_DWORD *v18; // r5
_DWORD *v19; // r0
int v20; // r3
int v21; // r3
MusicDownloadManager *v22; // r0
MusicDownloadManager *v23; // r0
MusicDownloadManager *v24; // r0
cocos2d::extension::CCHttpClient *v25; // r0
_DWORD v26[3]; // [sp+0h] [bp-Ch] BYREF
v26[0] = this;
v26[1] = a2;
v26[2] = a3;
if ( *((_DWORD *)this + 103) == *((_DWORD *)this + 104) )
{
(*(void (__fastcall **)(_DWORD, void *))(**((_DWORD **)this + 73) + 536))(*((_DWORD *)this + 73), &unk_BEC5F6);
(*(void (__fastcall **)(_DWORD, const char *))(**((_DWORD **)this + 73) + 464))(
*((_DWORD *)this + 73),
"Download complete.");
if ( *((_BYTE *)this + 357) )
{
v4 = 140.0;
v5 = 0.35;
}
else
{
v4 = 230.0;
v5 = 0.4;
}
cocos2d::CCLabelBMFont::limitLabelWidth(*((cocos2d::CCLabelBMFont **)this + 73), v4, v5, 0.0);
CustomSongWidget::showError((cocos2d::CCNode **)this, 1);
*((_BYTE *)this + 385) = 0;
return (MusicDownloadManager *)CustomSongWidget::updateMultiAssetInfo(this, 1);
}
else
{
Instance = (cocos2d::extension::CCHttpClient *)cocos2d::extension::CCHttpClient::getInstance(this);
result = (MusicDownloadManager *)cocos2d::extension::CCHttpClient::availableThreadCount(Instance);
v8 = *((_DWORD *)this + 103);
v9 = result;
while ( v8 != *((_DWORD *)this + 104) )
{
v10 = *(unsigned __int8 *)(v8 + 12);
if ( !*(_BYTE *)(v8 + 12) )
{
if ( *(int *)(v8 + 8) <= 1 )
{
*(_BYTE *)(v8 + 12) = 1;
v13 = *(_DWORD *)(v8 + 4);
if ( v13 == 1 )
{
v14 = *(_DWORD *)v8;
if ( *(int *)v8 > 9999999 )
{
v23 = (MusicDownloadManager *)MusicDownloadManager::sharedState(result);
result = (MusicDownloadManager *)MusicDownloadManager::downloadSong(v23, v14);
}
else
{
v15 = *((_DWORD **)this + 109);
if ( v15 )
{
while ( 1 )
{
v16 = v15[4];
if ( v14 >= v16 )
{
if ( v16 >= v14 )
{
v26[0] = v15;
v18 = v26;
goto LABEL_24;
}
v17 = (_DWORD *)v15[1];
if ( !v17 )
{
v26[0] = v15;
v18 = v15 + 1;
goto LABEL_24;
}
}
else
{
v17 = (_DWORD *)*v15;
if ( !*v15 )
{
v26[0] = v15;
v18 = v15;
goto LABEL_24;
}
}
v15 = v17;
}
}
v18 = (_DWORD *)((char *)this + 436);
v26[0] = (char *)this + 436;
LABEL_24:
if ( !*v18 )
{
v19 = (_DWORD *)operator new(0x14u);
v19[4] = v14;
v20 = v26[0];
*v19 = 0;
v19[1] = 0;
v19[2] = v20;
*v18 = v19;
v21 = **((_DWORD **)this + 108);
if ( v21 )
*((_DWORD *)this + 108) = v21;
result = (MusicDownloadManager *)std::__tree_balance_after_insert *>(
*((_DWORD **)this + 109),
(_DWORD *)*v18);
++*((_DWORD *)this + 110);
}
v22 = (MusicDownloadManager *)MusicDownloadManager::sharedState(result);
result = (MusicDownloadManager *)MusicDownloadManager::getSongInfo(v22, v14, 0);
}
}
else if ( v13 == 2 )
{
v24 = (MusicDownloadManager *)MusicDownloadManager::sharedState(result);
result = (MusicDownloadManager *)MusicDownloadManager::downloadSFX(v24, *(_DWORD *)v8);
}
}
else
{
CustomSongWidget::updateMultiAssetInfo(this, 1);
v11 = *((_DWORD *)this + 73);
v12 = *(void (__fastcall **)(int, _DWORD *))(*(_DWORD *)v11 + 536);
LOWORD(v26[0]) = 13055;
BYTE2(v26[0]) = 25;
v12(v11, v26);
(*(void (__fastcall **)(_DWORD, const char *))(**((_DWORD **)this + 73) + 464))(
*((_DWORD *)this + 73),
"Some assets failed to download.");
cocos2d::CCLabelBMFont::limitLabelWidth(*((cocos2d::CCLabelBMFont **)this + 73), 230.0, 0.4, 0.0);
result = (MusicDownloadManager *)CustomSongWidget::showError((cocos2d::CCNode **)this, v10);
}
v25 = (cocos2d::extension::CCHttpClient *)cocos2d::extension::CCHttpClient::getInstance(result);
result = (MusicDownloadManager *)cocos2d::extension::CCHttpClient::availableThreadCount(v25);
if ( *((_DWORD *)this + 103) != *((_DWORD *)this + 104) && result && result < v9 )
return (MusicDownloadManager *)CustomSongWidget::processNextMultiAsset(this);
return result;
}
v8 += 16;
}
}
return result;
}