aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform/modrinth
diff options
context:
space:
mode:
authorflow <thiagodonato300@gmail.com>2022-03-24 18:24:51 -0300
committerflow <thiagodonato300@gmail.com>2022-03-24 18:24:51 -0300
commite13ca94061c7fdfec9bd18b982b56a8d5a1f80b0 (patch)
treec04986ab61f789e4a01b854c374dc8ee15f4dffa /launcher/modplatform/modrinth
parentda43ed8ce1d804fe20c44788577a0387a698ed6e (diff)
parent92f3154e8f7c1421541a00ae7cf57f188cfe46a5 (diff)
downloadPrismLauncher-e13ca94061c7fdfec9bd18b982b56a8d5a1f80b0.tar.gz
PrismLauncher-e13ca94061c7fdfec9bd18b982b56a8d5a1f80b0.tar.bz2
PrismLauncher-e13ca94061c7fdfec9bd18b982b56a8d5a1f80b0.zip
chore: resolve conflicts and merge upstream
Diffstat (limited to 'launcher/modplatform/modrinth')
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
index ab6b451b..82988cf6 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
@@ -52,31 +52,33 @@ void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
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)
+ // NOTE: files.count() is 1-indexed, so we need to subtract 1 to become 0-indexed
+ while (i < files.count() - 1){
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");