From 5f3e9672cd378b8f04afe469fda4e7d4b7fc64fc Mon Sep 17 00:00:00 2001 From: Trial97 Date: Thu, 24 Aug 2023 13:31:57 +0300 Subject: [PATCH] made the loaders check more generic Signed-off-by: Trial97 --- launcher/modplatform/flame/FileResolvingTask.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp index 463014b6e..259d41cc1 100644 --- a/launcher/modplatform/flame/FileResolvingTask.cpp +++ b/launcher/modplatform/flame/FileResolvingTask.cpp @@ -1,7 +1,8 @@ #include "FileResolvingTask.h" -#include +#include #include "Json.h" +#include "modplatform/ModIndex.h" #include "net/ApiDownload.h" #include "net/ApiUpload.h" #include "net/Upload.h" @@ -135,6 +136,11 @@ void Flame::FileResolvingTask::netJobFinished() m_checkJob->start(); } +constexpr bool has_single_bit(int x) noexcept +{ + return x && !(x & (x - 1)); +} + void Flame::FileResolvingTask::modrinthCheckFinished() { setProgress(2, 3); @@ -154,7 +160,7 @@ void Flame::FileResolvingTask::modrinthCheckFinished() // If there's more than one mod loader for this version, we can't know for sure // which file is relative to each loader, so it's best to not use any one and // let the user download it manually. - if (std::bitset<8>(file.loaders).count() <= 1) { + if (!file.loaders || has_single_bit(file.loaders)) { out->url = file.downloadUrl; qDebug() << "Found alternative on modrinth " << out->fileName; } else {