aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEzekiel Smith <ezekielsmith@protonmail.com>2022-03-19 11:41:36 +1100
committerSefa Eyeoglu <contact@scrumplex.net>2022-03-22 20:11:15 +0100
commit025a3cf730c5a523b1966d2a20cdfbfbc4542fd7 (patch)
treed099bd305917f4971c4d30e884d2225358006f8d
parent6d9eaee7f96f1ca255bf950323003af5d718aa5a (diff)
downloadPrismLauncher-025a3cf730c5a523b1966d2a20cdfbfbc4542fd7.tar.gz
PrismLauncher-025a3cf730c5a523b1966d2a20cdfbfbc4542fd7.tar.bz2
PrismLauncher-025a3cf730c5a523b1966d2a20cdfbfbc4542fd7.zip
Merge pull request #296 from flowln/right_file
Use primary file for mod downloading on Modrinth
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
index 9017eb67..9581ca04 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
@@ -51,31 +51,32 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
auto files = Json::requireArray(obj, "files");
int i = 0;
- while (files.count() > 1 && i < files.count()){
- //try to resolve the correct file
+
+ // Find correct file (needed in cases where one version may have multiple files)
+ // Will default to the last one if there's no primary (though I think Modrinth requires that
+ // at least one file is primary, idk)
+ while (i < files.count()){
auto parent = files[i].toObject();
auto fileName = Json::requireString(parent, "filename");
- //avoid grabbing "dev" files
- if(fileName.contains("javadocs",Qt::CaseInsensitive) || fileName.contains("sources",Qt::CaseInsensitive)){
+
+ // Grab the correct mod loader
+ if(hasFabric){
+ if(fileName.contains("forge",Qt::CaseInsensitive)){
+ i++;
+ continue;
+ }
+ } else if(fileName.contains("fabric", Qt::CaseInsensitive)){
i++;
continue;
}
- //grab the correct mod loader
- if(fileName.contains("forge",Qt::CaseInsensitive) || fileName.contains("fabric",Qt::CaseInsensitive) ){
- if(hasFabric){
- if(fileName.contains("forge",Qt::CaseInsensitive)){
- i++;
- continue;
- }
- }else{
- if(fileName.contains("fabric",Qt::CaseInsensitive)){
- i++;
- continue;
- }
- }
- }
- break;
+
+ // Grab the primary file, if available
+ if(Json::requireBoolean(parent, "primary"))
+ break;
+
+ i++;
}
+
auto parent = files[i].toObject();
if(parent.contains("url")) {
file.downloadUrl = Json::requireString(parent, "url");