From 075d900d45f25475c7fe600d6237f17d5c257d30 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 27 Feb 2022 15:05:38 -0300 Subject: [PATCH] fix: Always tell Flame API which modloader we are using Fixes #206 partially. Although we don't list mods that have no compatibility with the mod loader we are using, mods that have support for both loaders still show up, and the versions for both the loaders are still shown. Also simplifies a little the logic in FlameModIndex::loadIndexedPackVersions --- launcher/modplatform/flame/FlameModIndex.cpp | 32 ++++++++++--------- .../pages/modplatform/flame/FlameModModel.cpp | 4 +-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp index a8b2495a4..082ffa57b 100644 --- a/launcher/modplatform/flame/FlameModIndex.cpp +++ b/launcher/modplatform/flame/FlameModIndex.cpp @@ -50,42 +50,44 @@ void FlameMod::loadIndexedPackVersions(FlameMod::IndexedPack & pack, QJsonArray for(auto versionIter: arr) { auto obj = versionIter.toObject(); - FlameMod::IndexedVersion file; - file.addonId = pack.addonId; - file.fileId = Json::requireInteger(obj, "id"); - file.date = Json::requireString(obj, "fileDate"); + auto versionArray = Json::requireArray(obj, "gameVersion"); - if (versionArray.empty()) { + if (versionArray.isEmpty()) { continue; } + + FlameMod::IndexedVersion file; for(auto mcVer : versionArray){ file.mcVersion.append(mcVer.toString()); } + file.addonId = pack.addonId; + file.fileId = Json::requireInteger(obj, "id"); + file.date = Json::requireString(obj, "fileDate"); file.version = Json::requireString(obj, "displayName"); file.downloadUrl = Json::requireString(obj, "downloadUrl"); file.fileName = Json::requireString(obj, "fileName"); auto modules = Json::requireArray(obj, "modules"); - bool valid = false; + bool is_valid_fabric_version = false; for(auto m : modules){ auto fname = Json::requireString(m.toObject(),"foldername"); + // FIXME: This does not work properly when a mod supports more than one mod loader, since + // they bundle the meta files for all of them in the same arquive, even when that version + // doesn't support the given mod loader. if(hasFabric){ if(fname == "fabric.mod.json"){ - valid = true; - break; - } - }else{ - //this cannot check for the recent mcmod.toml formats - if(fname == "mcmod.info"){ - valid = true; + is_valid_fabric_version = true; break; } } + else if(fname == "mcmod.info"){ //this cannot check for the recent mcmod.toml formats + break; + } } - if(!valid && hasFabric){ + + if(hasFabric && !is_valid_fabric_version) continue; - } unsortedVersions.append(file); } diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp index 2cf83261c..e8afba5a1 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp @@ -175,13 +175,13 @@ void ListModel::performPaginatedSearch() "pageSize=25&" "searchFilter=%2&" "sort=%3&" - "%4" + "modLoaderType=%4&" "gameVersion=%5" ) .arg(nextSearchOffset) .arg(currentSearchTerm) .arg(sorts[currentSort]) - .arg(hasFabric ? "modLoaderType=4&" : "") + .arg(hasFabric ? 4 : 1) // Enum: https://docs.curseforge.com/?http#tocS_ModLoaderType .arg(mcVersion); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));