aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform
diff options
context:
space:
mode:
authortimoreo <contact@timoreo.fr>2022-11-01 09:55:43 +0100
committerGitHub <noreply@github.com>2022-11-01 09:55:43 +0100
commit3a446c410cc6200b3ca05a03867daabdb7b32b30 (patch)
treeba14878d8b0f565865e3d2ce6547b3ff433f20cd /launcher/modplatform
parent35edea2141dd4045352879349c3cae4edc6ae26b (diff)
parente6e92f2b0e9ef16bdbae371ccb284339a70cff02 (diff)
downloadPrismLauncher-3a446c410cc6200b3ca05a03867daabdb7b32b30.tar.gz
PrismLauncher-3a446c410cc6200b3ca05a03867daabdb7b32b30.tar.bz2
PrismLauncher-3a446c410cc6200b3ca05a03867daabdb7b32b30.zip
Merge pull request #329 from flowln/only_safe_workarounds
Diffstat (limited to 'launcher/modplatform')
-rw-r--r--launcher/modplatform/flame/FileResolvingTask.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp
index c50abb8f..25b56fbd 100644
--- a/launcher/modplatform/flame/FileResolvingTask.cpp
+++ b/launcher/modplatform/flame/FileResolvingTask.cpp
@@ -3,6 +3,8 @@
#include "Json.h"
#include "net/Upload.h"
+#include "modplatform/modrinth/ModrinthPackIndex.h"
+
Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptr<QNetworkAccessManager>& network, Flame::Manifest& toProcess)
: m_network(network), m_toProcess(toProcess)
{}
@@ -84,18 +86,21 @@ void Flame::FileResolvingTask::modrinthCheckFinished() {
delete bytes;
continue;
}
+
QJsonDocument doc = QJsonDocument::fromJson(*bytes);
auto obj = doc.object();
- auto array = Json::requireArray(obj,"files");
- for (auto file: array) {
- auto fileObj = Json::requireObject(file);
- auto primary = Json::requireBoolean(fileObj,"primary");
- if (primary) {
- out->url = Json::requireUrl(fileObj,"url");
- qDebug() << "Found alternative on modrinth " << out->fileName;
- break;
- }
+ auto file = Modrinth::loadIndexedPackVersion(obj);
+
+ // If there's more than one mod loader for this version, we can't know for sure
+ // which file is relative to each loader, so it's best to not use any one and
+ // let the user download it manually.
+ if (file.loaders.size() <= 1) {
+ out->url = file.downloadUrl;
+ qDebug() << "Found alternative on modrinth " << out->fileName;
+ } else {
+ out->resolved = false;
}
+
delete bytes;
}
//copy to an output list and filter out projects found on modrinth