| 722 | } |
| 723 | |
| 724 | void PackInstallTask::downloadMods() |
| 725 | { |
| 726 | qDebug() << "PackInstallTask::installMods: " << QThread::currentThreadId(); |
| 727 | |
| 728 | QVector<ATLauncher::VersionMod> optionalMods; |
| 729 | for (const auto& mod : m_version.mods) { |
| 730 | if (mod.optional) { |
| 731 | optionalMods.push_back(mod); |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | // Select optional mods, if pack contains any |
| 736 | QVector<QString> selectedMods; |
| 737 | if (!optionalMods.isEmpty()) { |
| 738 | setStatus(tr("Selecting optional mods...")); |
| 739 | selectedMods = m_support->chooseOptionalMods(m_version, optionalMods); |
| 740 | } |
| 741 | |
| 742 | setStatus(tr("Downloading mods...")); |
| 743 | |
| 744 | jarmods.clear(); |
| 745 | jobPtr = new NetJob(tr("Mod download"), APPLICATION->network()); |
| 746 | for(const auto& mod : m_version.mods) { |
| 747 | // skip non-client mods |
| 748 | if(!mod.client) continue; |
| 749 | |
| 750 | // skip optional mods that were not selected |
| 751 | if(mod.optional && !selectedMods.contains(mod.name)) continue; |
| 752 | |
| 753 | QString url; |
| 754 | switch(mod.download) { |
| 755 | case DownloadType::Server: |
| 756 | url = BuildConfig.ATL_DOWNLOAD_SERVER_URL + mod.url; |
| 757 | break; |
| 758 | case DownloadType::Browser: |
| 759 | emitFailed(tr("Unsupported download type: %1").arg(mod.download_raw)); |
| 760 | return; |
| 761 | case DownloadType::Direct: |
| 762 | url = mod.url; |
| 763 | break; |
| 764 | case DownloadType::Unknown: |
| 765 | emitFailed(tr("Unknown download type: %1").arg(mod.download_raw)); |
| 766 | return; |
| 767 | } |
| 768 | |
| 769 | QFileInfo fileName(mod.file); |
| 770 | auto cacheName = fileName.completeBaseName() + "-" + mod.md5 + "." + fileName.suffix(); |
| 771 | |
| 772 | if (mod.type == ModType::Extract || mod.type == ModType::TexturePackExtract || mod.type == ModType::ResourcePackExtract) { |
| 773 | auto entry = APPLICATION->metacache()->resolveEntry("ATLauncherPacks", cacheName); |
| 774 | entry->setStale(true); |
| 775 | modsToExtract.insert(entry->getFullPath(), mod); |
| 776 | |
| 777 | auto dl = Net::Download::makeCached(url, entry); |
| 778 | if (!mod.md5.isEmpty()) { |
| 779 | auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1()); |
| 780 | dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5)); |
| 781 | } |
nothing calls this directly
no test coverage detected