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
This commit is contained in:
flow 2022-02-27 15:05:38 -03:00
parent 84e9ce71b0
commit 075d900d45
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 19 additions and 17 deletions

View File

@ -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);
}

View File

@ -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));