made the loaders check more generic
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
6c0492c0d1
commit
5f3e9672cd
@ -1,7 +1,8 @@
|
|||||||
#include "FileResolvingTask.h"
|
#include "FileResolvingTask.h"
|
||||||
|
|
||||||
#include <bitset>
|
#include <bit>
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
#include "modplatform/ModIndex.h"
|
||||||
#include "net/ApiDownload.h"
|
#include "net/ApiDownload.h"
|
||||||
#include "net/ApiUpload.h"
|
#include "net/ApiUpload.h"
|
||||||
#include "net/Upload.h"
|
#include "net/Upload.h"
|
||||||
@ -135,6 +136,11 @@ void Flame::FileResolvingTask::netJobFinished()
|
|||||||
m_checkJob->start();
|
m_checkJob->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool has_single_bit(int x) noexcept
|
||||||
|
{
|
||||||
|
return x && !(x & (x - 1));
|
||||||
|
}
|
||||||
|
|
||||||
void Flame::FileResolvingTask::modrinthCheckFinished()
|
void Flame::FileResolvingTask::modrinthCheckFinished()
|
||||||
{
|
{
|
||||||
setProgress(2, 3);
|
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
|
// 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
|
// which file is relative to each loader, so it's best to not use any one and
|
||||||
// let the user download it manually.
|
// 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;
|
out->url = file.downloadUrl;
|
||||||
qDebug() << "Found alternative on modrinth " << out->fileName;
|
qDebug() << "Found alternative on modrinth " << out->fileName;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user