aboutsummaryrefslogtreecommitdiff
path: root/launcher/modplatform/flame
diff options
context:
space:
mode:
authorTrial97 <alexandru.tripon97@gmail.com>2023-08-24 13:31:57 +0300
committerTrial97 <alexandru.tripon97@gmail.com>2023-08-24 13:31:57 +0300
commit5f3e9672cd378b8f04afe469fda4e7d4b7fc64fc (patch)
tree9a57f143cecc41d6248f64a28f30c86474d08de0 /launcher/modplatform/flame
parent6c0492c0d174f45262f072d6900c2fcf098d209b (diff)
downloadPrismLauncher-5f3e9672cd378b8f04afe469fda4e7d4b7fc64fc.tar.gz
PrismLauncher-5f3e9672cd378b8f04afe469fda4e7d4b7fc64fc.tar.bz2
PrismLauncher-5f3e9672cd378b8f04afe469fda4e7d4b7fc64fc.zip
made the loaders check more generic
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/modplatform/flame')
-rw-r--r--launcher/modplatform/flame/FileResolvingTask.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp
index 463014b6..259d41cc 100644
--- a/launcher/modplatform/flame/FileResolvingTask.cpp
+++ b/launcher/modplatform/flame/FileResolvingTask.cpp
@@ -1,7 +1,8 @@
#include "FileResolvingTask.h"
-#include <bitset>
+#include <bit>
#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 {