//
// CustomSongWidget::downloadAssetFinished from 0x100620a50 to 0x100620c5c (524 bytes)
//
// 3 xrefs:
// > CustomSongWidget::downloadSongFinished @ 0x10062099e
// > CustomSongWidget::downloadSFXFinished @ 0x100620eba
// > sub_100620EC0 @ 0x100620ed1
//
// 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::downloadAssetFinished(CustomSongWidget *a1, int a2, GJAssetType a3)
{
std::__vector_base::pointer begin; // r15
std::__vector_base::pointer end; // rax
__int64 i; // r12
__int64 v6; // rcx
std::__tree_end_node *>::pointer v7; // rax
std::__compressed_pair *>> *v8; // r14
std::__compressed_pair *>> *v9; // r13
_DWORD *v10; // rax
std::__tree_end_node *> *v11; // rcx
__int64 v12; // r13
std::__tree_end_node *>::pointer left; // rax
std::__compressed_pair *>> *p_pair1; // r14
std::__tree_end_node *> *v15; // rcx
std::__compressed_pair *>> *v16; // r14
char *v17; // r14
GJAssetDownloadAction *v18; // rsi
char *v19; // rdx
char *v20; // r15
std::__vector_base::pointer v21; // rax
GJAssetDownloadAction *v22; // r14
__int64 **v23; // [rsp+8h] [rbp-38h]
begin = a1->m_undownloadedAssets.__begin_;
end = a1->m_undownloadedAssets.__end_;
if ( begin == end )
return;
for ( i = 0; *(int *)((char *)&begin->m_id + i) != a2 || *(GJAssetType *)((char *)&begin->m_assetType + i) != a3; i += 16 )
{
v6 = (__int64)&begin[1].m_assetType + i;
if ( (std::__vector_base::pointer)v6 == end )
return;
}
if ( a3 == User )
{
left = a1->m_sfx.__tree_.__pair1_.__value_.__left_;
p_pair1 = &a1->m_sfx.__tree_.__pair1_;
v9 = &a1->m_sfx.__tree_.__pair1_;
LABEL_20:
if ( left )
{
do
{
v9 = (std::__compressed_pair *>> *)left;
if ( *((_DWORD *)left + 7) > a2 )
{
left = *(std::__tree_end_node *>::pointer *)left;
p_pair1 = v9;
goto LABEL_20;
}
if ( *((_DWORD *)left + 7) >= a2 )
goto LABEL_28;
left = *((std::__tree_end_node *>::pointer *)left + 1);
}
while ( left );
p_pair1 = v9 + 1;
}
v23 = (__int64 **)&a1->m_sfx.__tree_.__pair1_;
v10 = operator new(0x28u);
v10[7] = a2;
*((_BYTE *)v10 + 32) = 0;
*(_OWORD *)v10 = 0;
*((_QWORD *)v10 + 2) = v9;
p_pair1->__value_.__left_ = (std::__tree_end_node *>::pointer)v10;
v15 = (std::__tree_end_node *> *)a1->m_sfx.__tree_.__begin_node_->__left_;
v12 = 568;
if ( v15 )
a1->m_sfx.__tree_.__begin_node_ = v15;
goto LABEL_27;
}
if ( a3 == 1 )
{
v7 = a1->m_songs.__tree_.__pair1_.__value_.__left_;
v8 = &a1->m_songs.__tree_.__pair1_;
v9 = &a1->m_songs.__tree_.__pair1_;
LABEL_11:
if ( v7 )
{
do
{
v9 = (std::__compressed_pair *>> *)v7;
if ( *((_DWORD *)v7 + 7) > a2 )
{
v7 = *(std::__tree_end_node *>::pointer *)v7;
v8 = v9;
goto LABEL_11;
}
if ( *((_DWORD *)v7 + 7) >= a2 )
goto LABEL_28;
v7 = *((std::__tree_end_node *>::pointer *)v7 + 1);
}
while ( v7 );
v8 = v9 + 1;
}
v23 = (__int64 **)&a1->m_songs.__tree_.__pair1_;
v10 = operator new(0x28u);
v10[7] = a2;
*((_BYTE *)v10 + 32) = 0;
*(_OWORD *)v10 = 0;
*((_QWORD *)v10 + 2) = v9;
v8->__value_.__left_ = (std::__tree_end_node *>::pointer)v10;
v11 = (std::__tree_end_node *> *)a1->m_songs.__tree_.__begin_node_->__left_;
v12 = 544;
if ( v11 )
a1->m_songs.__tree_.__begin_node_ = v11;
LABEL_27:
v16 = (std::__compressed_pair *>> *)v10;
sub_100054DD0(*v23, (__int64 *)v10);
++*(CustomSongWidget_vtbl **)((char *)&a1->cocos2d::CCNode::cocos2d::CCObject::cocos2d::CCCopying::__vftable + v12);
v9 = v16;
LABEL_28:
LOBYTE(v9[4].__value_.__left_) = 1;
}
v17 = (char *)begin + i;
v18 = (std::__vector_base::pointer)((char *)begin + i + 16);
v19 = (char *)((char *)a1->m_undownloadedAssets.__end_ - (char *)begin - i);
v20 = v19 - 16;
if ( v18 != a1->m_undownloadedAssets.__end_ )
memmove(v17, v18, (size_t)(v19 - 19));
v21 = a1->m_undownloadedAssets.__begin_;
v22 = (GJAssetDownloadAction *)&v17[(_QWORD)v20];
a1->m_undownloadedAssets.__end_ = v22;
if ( v21 != v22 )
CustomSongWidget::updateMultiAssetInfo(a1, 0);
CustomSongWidget::processNextMultiAsset(a1);
}