//
// CustomSongWidget::processNextMultiAsset from 0x100621070 to 0x10062131b (683 bytes)
//
// 7 xrefs:
// > CustomSongWidget::startMultiAssetDownload @ 0x10061f122
// > CustomSongWidget::downloadAssetFinished @ 0x100620c57
// > CustomSongWidget::downloadSongFailed @ 0x100620d21
// > CustomSongWidget::downloadAssetFailed @ 0x100620e81
// > CustomSongWidget::downloadSFXFailed @ 0x100620f87
// > sub_100620FA0 @ 0x100621057
// > CustomSongWidget::processNextMultiAsset @ 0x100621307
//
// 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 __fastcall CustomSongWidget::processNextMultiAsset(CustomSongWidget *a1)
{
__int64 v1; // rax
cocos2d::extension::CCHttpClient *Instance; // rax
size_t v4; // rax
std::__vector_base::pointer begin; // r14
std::__vector_base::pointer end; // rcx
cocos2d::CCLabelBMFont *m_errorLabel; // rdi
float v8; // xmm0_4
float v9; // xmm1_4
size_t v10; // r15
cocos2d::CCLabelBMFont *v11; // rdi
GJAssetType m_assetType; // eax
int m_id; // r14d
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *p_pair1; // r13
std::__compressed_pair *>> *v16; // r12
int v17; // eax
_DWORD *v18; // rax
std::__tree_end_node *> *v19; // rcx
MusicDownloadManager *v20; // rax
MusicDownloadManager *v21; // rax
MusicDownloadManager *v22; // rax
cocos2d::extension::CCHttpClient *v23; // rax
size_t v24; // rax
int v25; // [rsp+0h] [rbp-2Ch] BYREF
v25 = HIDWORD(v1);
if ( a1->m_undownloadedAssets.__begin_ == a1->m_undownloadedAssets.__end_ )
{
((void (__fastcall *)(cocos2d::CCLabelBMFont *, void *))a1->m_errorLabel->setColor)(
a1->m_errorLabel,
&unk_100822625);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))a1->m_errorLabel->setString)(
a1->m_errorLabel,
"Download complete.");
m_errorLabel = a1->m_errorLabel;
if ( a1->m_isMusicLibrary )
{
v8 = 140.0;
v9 = 0.34999999;
}
else
{
v8 = 230.0;
v9 = 0.40000001;
}
cocos2d::CCLabelBMFont::limitLabelWidth(m_errorLabel, v8, v9, 0.0);
CustomSongWidget::showError(a1, 1);
a1->m_unkBool2 = 0;
CustomSongWidget::updateMultiAssetInfo(a1, 1);
}
else
{
Instance = cocos2d::extension::CCHttpClient::getInstance();
v4 = cocos2d::extension::CCHttpClient::availableThreadCount(Instance);
begin = a1->m_undownloadedAssets.__begin_;
end = a1->m_undownloadedAssets.__end_;
if ( begin != end )
{
while ( LOBYTE(begin[1].m_id) == 1 )
{
begin = (std::__vector_base::pointer)((char *)begin + 16);
if ( begin == end )
return;
}
if ( begin->m_status < 2 )
{
v10 = v4;
LOBYTE(begin[1].m_id) = 1;
m_assetType = begin->m_assetType;
if ( m_assetType == User )
{
v21 = MusicDownloadManager::sharedState();
MusicDownloadManager::downloadSFX(v21, begin->m_id);
}
else if ( m_assetType == 1 )
{
m_id = begin->m_id;
if ( m_id > 9999999 )
{
v22 = MusicDownloadManager::sharedState();
MusicDownloadManager::downloadSong(v22, m_id);
}
else
{
left = a1->m_nextSongIDs.__tree_.__pair1_.__value_.__left_;
if ( left )
{
while ( 1 )
{
while ( 1 )
{
v16 = (std::__compressed_pair *>> *)left;
v17 = *((_DWORD *)left + 7);
if ( m_id >= v17 )
break;
left = v16->__value_.__left_;
p_pair1 = v16;
if ( !v16->__value_.__left_ )
goto LABEL_22;
}
if ( m_id <= v17 )
break;
left = v16[1].__value_.__left_;
if ( !left )
{
p_pair1 = v16 + 1;
goto LABEL_22;
}
}
}
else
{
p_pair1 = &a1->m_nextSongIDs.__tree_.__pair1_;
v16 = &a1->m_nextSongIDs.__tree_.__pair1_;
LABEL_22:
v18 = operator new(0x20u);
v18[7] = m_id;
*(_OWORD *)v18 = 0;
*((_QWORD *)v18 + 2) = v16;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v18;
v19 = (std::__tree_end_node *> *)a1->m_nextSongIDs.__tree_.__begin_node_->__left_;
if ( v19 )
a1->m_nextSongIDs.__tree_.__begin_node_ = v19;
sub_100054DD0((__int64 *)a1->m_nextSongIDs.__tree_.__pair1_.__value_.__left_, (__int64 *)v18);
++a1->m_nextSongIDs.__tree_.__pair3_.__value_;
}
v20 = MusicDownloadManager::sharedState();
MusicDownloadManager::getSongInfo(v20, m_id, 0);
}
}
}
else
{
v10 = v4;
CustomSongWidget::updateMultiAssetInfo(a1, 1);
v11 = a1->m_errorLabel;
BYTE2(v25) = 25;
LOWORD(v25) = 13055;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, int *))v11->setColor)(v11, &v25);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))a1->m_errorLabel->setString)(
a1->m_errorLabel,
"Some assets failed to download.");
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_errorLabel, 230.0, 0.40000001, 0.0);
CustomSongWidget::showError(a1, 0);
}
v23 = cocos2d::extension::CCHttpClient::getInstance();
v24 = cocos2d::extension::CCHttpClient::availableThreadCount(v23);
if ( a1->m_undownloadedAssets.__begin_ != a1->m_undownloadedAssets.__end_ && v24 && v24 < v10 )
CustomSongWidget::processNextMultiAsset(a1);
}
}
}