//
// MusicDownloadManager::onDownloadSFXCompleted from 0x100159b5c to 0x100159c84 (296 bytes)
//
// 1 xrefs:
// > MusicDownloadManager::downloadSFX @ 0x100159a2c
//
// 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 MusicDownloadManager::onDownloadSFXCompleted(
MusicDownloadManager *a1,
cocos2d::extension::CCHttpClient *a2,
cocos2d::extension::CCHttpResponse *a3)
{
cocos2d::extension::CCHttpRequest *pHttpRequest; // x8
const char *p_tag; // x0
__int64 v7; // x20
cocos2d::CCString *v8; // x0
const char *CString; // x0
std::string *p_p; // x0
FILE *v11; // x22
GJSongError v12; // w2
std::string __p; // [xsp+8h] [xbp-38h] BYREF
pHttpRequest = a3->_pHttpRequest;
p_tag = (const char *)&pHttpRequest->_tag;
if ( pHttpRequest->_tag.m_data.m_short.shortStorage.__elems_[22] < 0 )
p_tag = *(const char **)p_tag;
v7 = atoi(p_tag);
v8 = (cocos2d::CCString *)sub_100268F4C("sfx_%i", v7);
CString = cocos2d::CCString::getCString(v8);
MusicDownloadManager::removeDLFromActive(a1, CString);
if ( a3->_succeed )
{
MusicDownloadManager::pathForSFX(v7, &__p);
if ( (__p.__r_.__value_.__r.__words[2] & 0x8000000000000000LL) == 0LL )
p_p = &__p;
else
p_p = (std::string *)__p.__r_.__value_.__r.__words[0];
v11 = fopen((const char *)p_p, "wb");
if ( v11 )
{
fwrite(a3->_responseData.__begin_, 1u, a3->_responseData.__end_ - a3->_responseData.__begin_, v11);
fclose(v11);
MusicDownloadManager::downloadSFXFinished(a1, v7);
}
else
{
MusicDownloadManager::downloadSFXFailed(a1, v7, (GJSongError)0);
}
if ( SHIBYTE(__p.__r_.__value_.__r.__words[2]) < 0 )
operator delete(__p.__r_.__value_.__l.__data_);
}
else
{
if ( a3->_pHttpRequest->_shouldCancel )
v12 = DownloadCancelled;
else
v12 = 0;
MusicDownloadManager::downloadSFXFailed(a1, v7, v12);
}
}