From 855e49bda0d83194f832c58e1cfe70886ba60c36 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 13 Jan 2025 13:56:55 +0200 Subject: [PATCH] fix curseforge with empty loader as newest version Signed-off-by: Trial97 (cherry picked from commit e4ad4051c8b87bd5102a76a860408de2b447d74d) --- launcher/modplatform/flame/FlameAPI.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/launcher/modplatform/flame/FlameAPI.cpp b/launcher/modplatform/flame/FlameAPI.cpp index 53eadcf02..699eb792a 100644 --- a/launcher/modplatform/flame/FlameAPI.cpp +++ b/launcher/modplatform/flame/FlameAPI.cpp @@ -270,6 +270,7 @@ std::optional FlameAPI::getLatestVersion(QList instanceLoaders, ModPlatform::ModLoaderTypes modLoaders) { + static const auto noLoader = ModPlatform::ModLoaderType(0); QHash bestMatch; auto checkVersion = [&bestMatch](const ModPlatform::IndexedVersion& version, const ModPlatform::ModLoaderType& loader) { if (bestMatch.contains(loader)) { @@ -284,7 +285,7 @@ std::optional FlameAPI::getLatestVersion(QList FlameAPI::getLatestVersion(QList fabric version will be prioritizated on update auto currentLoaders = instanceLoaders + ModPlatform::modLoaderTypesToList(modLoaders); - currentLoaders.append(ModPlatform::ModLoaderType(0)); // add a fallback in case the versions do not define a loader + currentLoaders.append(noLoader); // add a fallback in case the versions do not define a loader for (auto loader : currentLoaders) { if (bestMatch.contains(loader)) { - return bestMatch.value(loader); + auto bestForLoader = bestMatch.value(loader); + // awkward case where the mod has only two loaders and one of them is not specified + if (loader != noLoader && bestMatch.contains(noLoader) && bestMatch.size() == 2) { + auto bestForNoLoader = bestMatch.value(noLoader); + if (bestForNoLoader.date > bestForLoader.date) { + return bestForNoLoader; + } + } + return bestForLoader; } } return {};