mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
chore(clang-tidy): fix clang tidy warnings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
f9e007ca2b
commit
97d570b343
4 changed files with 111 additions and 107 deletions
|
|
@ -15,15 +15,15 @@ class CheckUpdateTask : public Task {
|
||||||
std::vector<Version>& mcVersions,
|
std::vector<Version>& mcVersions,
|
||||||
QList<ModPlatform::ModLoaderType> loadersList,
|
QList<ModPlatform::ModLoaderType> loadersList,
|
||||||
ResourceFolderModel* resourceModel)
|
ResourceFolderModel* resourceModel)
|
||||||
: Task(), m_resources(resources), m_gameVersions(mcVersions), m_loadersList(std::move(loadersList)), m_resourceModel(resourceModel)
|
: m_resources(resources), m_gameVersions(mcVersions), m_loadersList(std::move(loadersList)), m_resourceModel(resourceModel)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
struct Update {
|
struct Update {
|
||||||
QString name;
|
QString name;
|
||||||
QString old_hash;
|
QString oldHash;
|
||||||
QString old_version;
|
QString oldVersion;
|
||||||
QString new_version;
|
QString newVersion;
|
||||||
std::optional<ModPlatform::IndexedVersionType> new_version_type;
|
std::optional<ModPlatform::IndexedVersionType> newVersionType;
|
||||||
QString changelog;
|
QString changelog;
|
||||||
ModPlatform::ResourceProvider provider;
|
ModPlatform::ResourceProvider provider;
|
||||||
shared_qobject_ptr<ResourceDownloadTask> download;
|
shared_qobject_ptr<ResourceDownloadTask> download;
|
||||||
|
|
@ -31,19 +31,19 @@ class CheckUpdateTask : public Task {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Update(QString name,
|
Update(QString name,
|
||||||
QString old_h,
|
QString oldH,
|
||||||
QString old_v,
|
QString oldV,
|
||||||
QString new_v,
|
QString newV,
|
||||||
std::optional<ModPlatform::IndexedVersionType> new_v_type,
|
std::optional<ModPlatform::IndexedVersionType> newVType,
|
||||||
QString changelog,
|
QString changelog,
|
||||||
ModPlatform::ResourceProvider p,
|
ModPlatform::ResourceProvider p,
|
||||||
shared_qobject_ptr<ResourceDownloadTask> t,
|
shared_qobject_ptr<ResourceDownloadTask> t,
|
||||||
bool enabled = true)
|
bool enabled = true)
|
||||||
: name(std::move(name))
|
: name(std::move(name))
|
||||||
, old_hash(std::move(old_h))
|
, oldHash(std::move(oldH))
|
||||||
, old_version(std::move(old_v))
|
, oldVersion(std::move(oldV))
|
||||||
, new_version(std::move(new_v))
|
, newVersion(std::move(newV))
|
||||||
, new_version_type(std::move(new_v_type))
|
, newVersionType(newVType)
|
||||||
, changelog(std::move(changelog))
|
, changelog(std::move(changelog))
|
||||||
, provider(p)
|
, provider(p)
|
||||||
, download(std::move(t))
|
, download(std::move(t))
|
||||||
|
|
@ -54,14 +54,11 @@ class CheckUpdateTask : public Task {
|
||||||
auto getUpdates() -> std::vector<Update>&& { return std::move(m_updates); }
|
auto getUpdates() -> std::vector<Update>&& { return std::move(m_updates); }
|
||||||
auto getDependencies() -> QList<std::shared_ptr<GetModDependenciesTask::PackDependency>>&& { return std::move(m_deps); }
|
auto getDependencies() -> QList<std::shared_ptr<GetModDependenciesTask::PackDependency>>&& { return std::move(m_deps); }
|
||||||
|
|
||||||
public slots:
|
|
||||||
bool abort() override = 0;
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void executeTask() override = 0;
|
void executeTask() override = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void checkFailed(Resource* failed, QString reason, QUrl recover_url = {});
|
void checkFailed(Resource* failed, QString reason, QUrl recoverUrl = {});
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<Resource*>& m_resources;
|
QList<Resource*>& m_resources;
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,6 @@
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
static FlameAPI api;
|
|
||||||
|
|
||||||
bool FlameCheckUpdate::abort()
|
bool FlameCheckUpdate::abort()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
@ -39,7 +37,7 @@ void FlameCheckUpdate::executeTask()
|
||||||
{
|
{
|
||||||
setStatus(tr("Preparing resources for CurseForge..."));
|
setStatus(tr("Preparing resources for CurseForge..."));
|
||||||
|
|
||||||
auto netJob = new NetJob("Get latest versions", APPLICATION->network());
|
auto* netJob = new NetJob("Get latest versions", APPLICATION->network());
|
||||||
connect(netJob, &Task::finished, this, &FlameCheckUpdate::collectBlockedMods);
|
connect(netJob, &Task::finished, this, &FlameCheckUpdate::collectBlockedMods);
|
||||||
|
|
||||||
connect(netJob, &Task::progress, this, &FlameCheckUpdate::setProgress);
|
connect(netJob, &Task::progress, this, &FlameCheckUpdate::setProgress);
|
||||||
|
|
@ -48,9 +46,10 @@ void FlameCheckUpdate::executeTask()
|
||||||
for (auto* resource : m_resources) {
|
for (auto* resource : m_resources) {
|
||||||
auto project = std::make_shared<ModPlatform::IndexedPack>();
|
auto project = std::make_shared<ModPlatform::IndexedPack>();
|
||||||
project->addonId = resource->metadata()->project_id.toString();
|
project->addonId = resource->metadata()->project_id.toString();
|
||||||
auto versionsUrlOptional = api.getVersionsURL({ project, m_gameVersions });
|
auto versionsUrlOptional = FlameAPI().getVersionsURL({ .pack = project, .mcVersions = m_gameVersions });
|
||||||
if (!versionsUrlOptional.has_value())
|
if (!versionsUrlOptional.has_value()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto [task, response] = Net::ApiDownload::makeByteArray(versionsUrlOptional.value());
|
auto [task, response] = Net::ApiDownload::makeByteArray(versionsUrlOptional.value());
|
||||||
|
|
||||||
|
|
@ -63,11 +62,11 @@ void FlameCheckUpdate::executeTask()
|
||||||
|
|
||||||
void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray* response)
|
void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray* response)
|
||||||
{
|
{
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parseError{};
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
QJsonDocument doc = QJsonDocument::fromJson(*response, &parseError);
|
||||||
if (parse_error.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qWarning() << "Error while parsing JSON response from latest mod version at" << parse_error.offset
|
qWarning() << "Error while parsing JSON response from latest mod version at" << parseError.offset
|
||||||
<< "reason:" << parse_error.errorString();
|
<< "reason:" << parseError.errorString();
|
||||||
qWarning() << *response;
|
qWarning() << *response;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -88,100 +87,104 @@ void FlameCheckUpdate::getLatestVersionCallback(Resource* resource, QByteArray*
|
||||||
qCritical() << e.what();
|
qCritical() << e.what();
|
||||||
qDebug() << doc;
|
qDebug() << doc;
|
||||||
}
|
}
|
||||||
auto latest_ver = api.getLatestVersion(pack->versions, m_loadersList, resource->metadata()->loaders, !m_loadersList.isEmpty());
|
auto latestVer = FlameAPI().getLatestVersion(pack->versions, m_loadersList, resource->metadata()->loaders, !m_loadersList.isEmpty());
|
||||||
|
|
||||||
setStatus(tr("Parsing the API response from CurseForge for '%1'...").arg(resource->name()));
|
setStatus(tr("Parsing the API response from CurseForge for '%1'...").arg(resource->name()));
|
||||||
|
|
||||||
if (!latest_ver.has_value() || !latest_ver->addonId.isValid()) {
|
if (!latestVer.has_value() || !latestVer->addonId.isValid()) {
|
||||||
QString reason;
|
QString reason;
|
||||||
if (dynamic_cast<Mod*>(resource) != nullptr)
|
if (dynamic_cast<Mod*>(resource) != nullptr) {
|
||||||
reason =
|
reason =
|
||||||
tr("No valid version found for this resource. It's probably unavailable for the current game "
|
tr("No valid version found for this resource. It's probably unavailable for the current game "
|
||||||
"version / mod loader.");
|
"version / mod loader.");
|
||||||
else
|
} else {
|
||||||
reason = tr("No valid version found for this resource. It's probably unavailable for the current game version.");
|
reason = tr("No valid version found for this resource. It's probably unavailable for the current game version.");
|
||||||
|
}
|
||||||
|
|
||||||
emit checkFailed(resource, reason);
|
emit checkFailed(resource, reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (latest_ver->downloadUrl.isEmpty() && latest_ver->fileId != resource->metadata()->file_id) {
|
if (latestVer->downloadUrl.isEmpty() && latestVer->fileId != resource->metadata()->file_id) {
|
||||||
m_blocked[resource] = latest_ver->fileId.toString();
|
m_blocked[resource] = latestVer->fileId.toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!latest_ver->hash.isEmpty() &&
|
if (!latestVer->hash.isEmpty() &&
|
||||||
(resource->metadata()->hash != latest_ver->hash || resource->status() == ResourceStatus::NOT_INSTALLED)) {
|
(resource->metadata()->hash != latestVer->hash || resource->status() == ResourceStatus::NOT_INSTALLED)) {
|
||||||
auto old_version = resource->metadata()->version_number;
|
auto oldVersion = resource->metadata()->version_number;
|
||||||
if (old_version.isEmpty()) {
|
if (oldVersion.isEmpty()) {
|
||||||
if (resource->status() == ResourceStatus::NOT_INSTALLED)
|
if (resource->status() == ResourceStatus::NOT_INSTALLED) {
|
||||||
old_version = tr("Not installed");
|
oldVersion = tr("Not installed");
|
||||||
else
|
} else {
|
||||||
old_version = tr("Unknown");
|
oldVersion = tr("Unknown");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto download_task = makeShared<ResourceDownloadTask>(pack, latest_ver.value(), m_resourceModel, true, "update");
|
auto downloadTask = makeShared<ResourceDownloadTask>(pack, latestVer.value(), m_resourceModel, true, "update");
|
||||||
m_updates.emplace_back(pack->name, resource->metadata()->hash, old_version, latest_ver->version, latest_ver->version_type,
|
m_updates.emplace_back(pack->name, resource->metadata()->hash, oldVersion, latestVer->version, latestVer->version_type,
|
||||||
api.getModFileChangelog(latest_ver->addonId.toInt(), latest_ver->fileId.toInt()),
|
FlameAPI().getModFileChangelog(latestVer->addonId.toInt(), latestVer->fileId.toInt()),
|
||||||
ModPlatform::ResourceProvider::FLAME, download_task, resource->enabled());
|
ModPlatform::ResourceProvider::FLAME, downloadTask, resource->enabled());
|
||||||
}
|
}
|
||||||
m_deps.append(std::make_shared<GetModDependenciesTask::PackDependency>(pack, latest_ver.value()));
|
m_deps.append(std::make_shared<GetModDependenciesTask::PackDependency>(pack, latestVer.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlameCheckUpdate::collectBlockedMods()
|
void FlameCheckUpdate::collectBlockedMods()
|
||||||
{
|
{
|
||||||
QStringList addonIds;
|
QStringList addonIds;
|
||||||
QHash<QString, Resource*> quickSearch;
|
QHash<QString, Resource*> quickSearch;
|
||||||
for (auto const& resource : m_blocked.keys()) {
|
for (const auto& resource : m_blocked.keys()) {
|
||||||
auto addonId = resource->metadata()->project_id.toString();
|
auto addonId = resource->metadata()->project_id.toString();
|
||||||
addonIds.append(addonId);
|
addonIds.append(addonId);
|
||||||
quickSearch[addonId] = resource;
|
quickSearch[addonId] = resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
Task::Ptr projTask;
|
Task::Ptr projTask;
|
||||||
QByteArray* response;
|
QByteArray* response = nullptr;
|
||||||
|
|
||||||
if (addonIds.isEmpty()) {
|
if (addonIds.isEmpty()) {
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
} else if (addonIds.size() == 1) {
|
}
|
||||||
std::tie(projTask, response) = api.getProject(*addonIds.begin());
|
if (addonIds.size() == 1) {
|
||||||
|
std::tie(projTask, response) = FlameAPI().getProject(*addonIds.begin());
|
||||||
} else {
|
} else {
|
||||||
std::tie(projTask, response) = api.getProjects(addonIds);
|
std::tie(projTask, response) = FlameAPI().getProjects(addonIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds, quickSearch] {
|
connect(projTask.get(), &Task::succeeded, this, [this, response, addonIds, quickSearch] {
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parseError{};
|
||||||
auto doc = QJsonDocument::fromJson(*response, &parse_error);
|
auto doc = QJsonDocument::fromJson(*response, &parseError);
|
||||||
if (parse_error.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qWarning() << "Error while parsing JSON response from Flame projects task at" << parse_error.offset
|
qWarning() << "Error while parsing JSON response from Flame projects task at" << parseError.offset
|
||||||
<< "reason:" << parse_error.errorString();
|
<< "reason:" << parseError.errorString();
|
||||||
qWarning() << *response;
|
qWarning() << *response;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
QJsonArray entries;
|
QJsonArray entries;
|
||||||
if (addonIds.size() == 1)
|
if (addonIds.size() == 1) {
|
||||||
entries = { Json::requireObject(Json::requireObject(doc), "data") };
|
entries = { Json::requireObject(Json::requireObject(doc), "data") };
|
||||||
else
|
} else {
|
||||||
entries = Json::requireArray(Json::requireObject(doc), "data");
|
entries = Json::requireArray(Json::requireObject(doc), "data");
|
||||||
|
}
|
||||||
|
|
||||||
for (auto entry : entries) {
|
for (auto entry : entries) {
|
||||||
auto entry_obj = Json::requireObject(entry);
|
auto entryObj = Json::requireObject(entry);
|
||||||
|
|
||||||
auto id = QString::number(Json::requireInteger(entry_obj, "id"));
|
auto id = QString::number(Json::requireInteger(entryObj, "id"));
|
||||||
|
|
||||||
auto resource = quickSearch.find(id).value();
|
auto* resource = quickSearch.find(id).value();
|
||||||
|
|
||||||
ModPlatform::IndexedPack pack;
|
ModPlatform::IndexedPack pack;
|
||||||
try {
|
try {
|
||||||
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(resource->name()));
|
setStatus(tr("Parsing API response from CurseForge for '%1'...").arg(resource->name()));
|
||||||
|
|
||||||
FlameMod::loadIndexedPack(pack, entry_obj);
|
FlameMod::loadIndexedPack(pack, entryObj);
|
||||||
auto recover_url = QString("%1/download/%2").arg(pack.websiteUrl, m_blocked[resource]);
|
auto recoverUrl = QString("%1/download/%2").arg(pack.websiteUrl, m_blocked[resource]);
|
||||||
emit checkFailed(resource, tr("Resource has a new update available, but is not downloadable using CurseForge."),
|
emit checkFailed(resource, tr("Resource has a new update available, but is not downloadable using CurseForge."),
|
||||||
recover_url);
|
recoverUrl);
|
||||||
} catch (Json::JsonException& e) {
|
} catch (Json::JsonException& e) {
|
||||||
qDebug() << e.cause();
|
qDebug() << e.cause();
|
||||||
qDebug() << entries;
|
qDebug() << entries;
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void ModrinthCheckUpdate::executeTask()
|
||||||
setStatus(tr("Preparing resources for Modrinth..."));
|
setStatus(tr("Preparing resources for Modrinth..."));
|
||||||
setProgress(0, ((m_loadersList.isEmpty() ? 1 : m_loadersList.length()) * 2) + 1);
|
setProgress(0, ((m_loadersList.isEmpty() ? 1 : m_loadersList.length()) * 2) + 1);
|
||||||
|
|
||||||
auto hashing_task =
|
auto hashingTask =
|
||||||
makeShared<ConcurrentTask>("MakeModrinthHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
makeShared<ConcurrentTask>("MakeModrinthHashesTask", APPLICATION->settings()->get("NumberOfConcurrentTasks").toInt());
|
||||||
bool startHasing = false;
|
bool startHasing = false;
|
||||||
for (auto* resource : m_resources) {
|
for (auto* resource : m_resources) {
|
||||||
|
|
@ -63,10 +63,11 @@ void ModrinthCheckUpdate::executeTask()
|
||||||
// need to generate a new hash if the current one is innadequate
|
// need to generate a new hash if the current one is innadequate
|
||||||
// (though it will rarely happen, if at all)
|
// (though it will rarely happen, if at all)
|
||||||
if (resource->metadata()->hash_format != m_hashType) {
|
if (resource->metadata()->hash_format != m_hashType) {
|
||||||
auto hash_task = Hashing::createHasher(resource->fileinfo().absoluteFilePath(), ModPlatform::ResourceProvider::MODRINTH);
|
auto hashTask = Hashing::createHasher(resource->fileinfo().absoluteFilePath(), ModPlatform::ResourceProvider::MODRINTH);
|
||||||
connect(hash_task.get(), &Hashing::Hasher::resultsReady, [this, resource](QString hash) { m_mappings.insert(hash, resource); });
|
connect(hashTask.get(), &Hashing::Hasher::resultsReady,
|
||||||
connect(hash_task.get(), &Task::failed, [this] { failed("Failed to generate hash"); });
|
[this, resource](const QString& hash) { m_mappings.insert(hash, resource); });
|
||||||
hashing_task->addTask(hash_task);
|
connect(hashTask.get(), &Task::failed, [this] { failed("Failed to generate hash"); });
|
||||||
|
hashingTask->addTask(hashTask);
|
||||||
startHasing = true;
|
startHasing = true;
|
||||||
} else {
|
} else {
|
||||||
m_mappings.insert(hash, resource);
|
m_mappings.insert(hash, resource);
|
||||||
|
|
@ -74,9 +75,9 @@ void ModrinthCheckUpdate::executeTask()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startHasing) {
|
if (startHasing) {
|
||||||
connect(hashing_task.get(), &Task::finished, this, &ModrinthCheckUpdate::checkNextLoader);
|
connect(hashingTask.get(), &Task::finished, this, &ModrinthCheckUpdate::checkNextLoader);
|
||||||
m_job = hashing_task;
|
m_job = hashingTask;
|
||||||
hashing_task->start();
|
hashingTask->start();
|
||||||
} else {
|
} else {
|
||||||
checkNextLoader();
|
checkNextLoader();
|
||||||
}
|
}
|
||||||
|
|
@ -120,14 +121,14 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio
|
||||||
setStatus(tr("Parsing the API response from Modrinth..."));
|
setStatus(tr("Parsing the API response from Modrinth..."));
|
||||||
setProgress(m_progress + 1, m_progressTotal);
|
setProgress(m_progress + 1, m_progressTotal);
|
||||||
|
|
||||||
QJsonParseError parse_error{};
|
QJsonParseError parseError{};
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
|
QJsonDocument doc = QJsonDocument::fromJson(*response, &parseError);
|
||||||
if (parse_error.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qWarning() << "Error while parsing JSON response from ModrinthCheckUpdate at" << parse_error.offset
|
qWarning() << "Error while parsing JSON response from ModrinthCheckUpdate at" << parseError.offset
|
||||||
<< "reason:" << parse_error.errorString();
|
<< "reason:" << parseError.errorString();
|
||||||
qWarning() << *response;
|
qWarning() << *response;
|
||||||
|
|
||||||
emitFailed(parse_error.errorString());
|
emitFailed(parseError.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,11 +139,11 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio
|
||||||
const QString hash = iter.key();
|
const QString hash = iter.key();
|
||||||
Resource* resource = iter.value();
|
Resource* resource = iter.value();
|
||||||
|
|
||||||
auto project_obj = doc[hash].toObject();
|
auto projectObj = doc[hash].toObject();
|
||||||
|
|
||||||
// If the returned project is empty, but we have Modrinth metadata,
|
// If the returned project is empty, but we have Modrinth metadata,
|
||||||
// it means this specific version is not available
|
// it means this specific version is not available
|
||||||
if (project_obj.isEmpty()) {
|
if (projectObj.isEmpty()) {
|
||||||
qDebug() << "Mod" << m_mappings.find(hash).value()->name() << "got an empty response. Hash:" << hash;
|
qDebug() << "Mod" << m_mappings.find(hash).value()->name() << "got an empty response. Hash:" << hash;
|
||||||
++iter;
|
++iter;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -150,11 +151,11 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio
|
||||||
|
|
||||||
// Sometimes a version may have multiple files, one with "forge" and one with "fabric",
|
// Sometimes a version may have multiple files, one with "forge" and one with "fabric",
|
||||||
// so we may want to filter it
|
// so we may want to filter it
|
||||||
QString loader_filter;
|
QString loaderFilter;
|
||||||
if (loader.has_value() && loader != 0) {
|
if (loader.has_value() && loader != 0) {
|
||||||
auto modLoaders = ModPlatform::modLoaderTypesToList(*loader);
|
auto modLoaders = ModPlatform::modLoaderTypesToList(*loader);
|
||||||
if (!modLoaders.isEmpty()) {
|
if (!modLoaders.isEmpty()) {
|
||||||
loader_filter = ModPlatform::getModLoaderAsString(modLoaders.first());
|
loaderFilter = ModPlatform::getModLoaderAsString(modLoaders.first());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,9 +165,9 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio
|
||||||
// - The version reported by the JAR is different from the version reported by the indexed version (it's usually the case)
|
// - The version reported by the JAR is different from the version reported by the indexed version (it's usually the case)
|
||||||
// Such is the pain of having arbitrary files for a given version .-.
|
// Such is the pain of having arbitrary files for a given version .-.
|
||||||
|
|
||||||
auto project_ver = Modrinth::loadIndexedPackVersion(project_obj, m_hashType, loader_filter);
|
auto projectVer = Modrinth::loadIndexedPackVersion(projectObj, m_hashType, loaderFilter);
|
||||||
if (project_ver.downloadUrl.isEmpty()) {
|
if (projectVer.downloadUrl.isEmpty()) {
|
||||||
qCritical() << "Modrinth mod without download url!" << project_ver.fileName;
|
qCritical() << "Modrinth mod without download url!" << projectVer.fileName;
|
||||||
++iter;
|
++iter;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -177,21 +178,22 @@ void ModrinthCheckUpdate::checkVersionsResponse(QByteArray* response, std::optio
|
||||||
pack->slug = resource->metadata()->slug;
|
pack->slug = resource->metadata()->slug;
|
||||||
pack->addonId = resource->metadata()->project_id;
|
pack->addonId = resource->metadata()->project_id;
|
||||||
pack->provider = ModPlatform::ResourceProvider::MODRINTH;
|
pack->provider = ModPlatform::ResourceProvider::MODRINTH;
|
||||||
if ((project_ver.hash != hash && project_ver.is_preferred) || (resource->status() == ResourceStatus::NOT_INSTALLED)) {
|
if ((projectVer.hash != hash && projectVer.is_preferred) || (resource->status() == ResourceStatus::NOT_INSTALLED)) {
|
||||||
auto download_task = makeShared<ResourceDownloadTask>(pack, project_ver, m_resourceModel, true, "update");
|
auto downloadTask = makeShared<ResourceDownloadTask>(pack, projectVer, m_resourceModel, true, "update");
|
||||||
|
|
||||||
QString old_version = resource->metadata()->version_number;
|
QString oldVersion = resource->metadata()->version_number;
|
||||||
if (old_version.isEmpty()) {
|
if (oldVersion.isEmpty()) {
|
||||||
if (resource->status() == ResourceStatus::NOT_INSTALLED)
|
if (resource->status() == ResourceStatus::NOT_INSTALLED) {
|
||||||
old_version = tr("Not installed");
|
oldVersion = tr("Not installed");
|
||||||
else
|
} else {
|
||||||
old_version = tr("Unknown");
|
oldVersion = tr("Unknown");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updates.emplace_back(pack->name, hash, old_version, project_ver.version_number, project_ver.version_type,
|
m_updates.emplace_back(pack->name, hash, oldVersion, projectVer.version_number, projectVer.version_type,
|
||||||
project_ver.changelog, ModPlatform::ResourceProvider::MODRINTH, download_task, resource->enabled());
|
projectVer.changelog, ModPlatform::ResourceProvider::MODRINTH, downloadTask, resource->enabled());
|
||||||
}
|
}
|
||||||
m_deps.append(std::make_shared<GetModDependenciesTask::PackDependency>(pack, project_ver));
|
m_deps.append(std::make_shared<GetModDependenciesTask::PackDependency>(pack, projectVer));
|
||||||
|
|
||||||
iter = m_mappings.erase(iter);
|
iter = m_mappings.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
@ -211,20 +213,22 @@ void ModrinthCheckUpdate::checkNextLoader()
|
||||||
if (m_loaderIdx < m_loadersList.size()) { // this are mods so check with loades
|
if (m_loaderIdx < m_loadersList.size()) { // this are mods so check with loades
|
||||||
getUpdateModsForLoader(m_loadersList.at(m_loaderIdx), m_loaderIdx > m_initialSize);
|
getUpdateModsForLoader(m_loadersList.at(m_loaderIdx), m_loaderIdx > m_initialSize);
|
||||||
return;
|
return;
|
||||||
} else if (m_loadersList.isEmpty() && m_loaderIdx == 0) { // this are other resources no need to check more than once with empty loader
|
}
|
||||||
|
if (m_loadersList.isEmpty() && m_loaderIdx == 0) { // this are other resources no need to check more than once with empty loader
|
||||||
getUpdateModsForLoader();
|
getUpdateModsForLoader();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto resource : m_mappings) {
|
for (auto* resource : m_mappings) {
|
||||||
QString reason;
|
QString reason;
|
||||||
|
|
||||||
if (dynamic_cast<Mod*>(resource) != nullptr)
|
if (dynamic_cast<Mod*>(resource) != nullptr) {
|
||||||
reason =
|
reason =
|
||||||
tr("No valid version found for this resource. It's probably unavailable for the current game "
|
tr("No valid version found for this resource. It's probably unavailable for the current game "
|
||||||
"version / mod loader.");
|
"version / mod loader.");
|
||||||
else
|
} else {
|
||||||
reason = tr("No valid version found for this resource. It's probably unavailable for the current game version.");
|
reason = tr("No valid version found for this resource. It's probably unavailable for the current game version.");
|
||||||
|
}
|
||||||
|
|
||||||
emit checkFailed(resource, reason);
|
emit checkFailed(resource, reason);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -465,17 +465,17 @@ void ResourceUpdateDialog::appendResource(const CheckUpdateTask::Update& info, Q
|
||||||
providerItem->setData(0, Qt::UserRole, providerName);
|
providerItem->setData(0, Qt::UserRole, providerName);
|
||||||
|
|
||||||
auto* oldVersionItem = new QTreeWidgetItem(itemTop);
|
auto* oldVersionItem = new QTreeWidgetItem(itemTop);
|
||||||
oldVersionItem->setText(0, tr("Old version: %1").arg(info.old_version));
|
oldVersionItem->setText(0, tr("Old version: %1").arg(info.oldVersion));
|
||||||
oldVersionItem->setData(0, Qt::UserRole, info.old_version);
|
oldVersionItem->setData(0, Qt::UserRole, info.oldVersion);
|
||||||
|
|
||||||
auto* newVersionItem = new QTreeWidgetItem(itemTop);
|
auto* newVersionItem = new QTreeWidgetItem(itemTop);
|
||||||
newVersionItem->setText(0, tr("New version: %1").arg(info.new_version));
|
newVersionItem->setText(0, tr("New version: %1").arg(info.newVersion));
|
||||||
newVersionItem->setData(0, Qt::UserRole, info.new_version);
|
newVersionItem->setData(0, Qt::UserRole, info.newVersion);
|
||||||
|
|
||||||
if (info.new_version_type.has_value()) {
|
if (info.newVersionType.has_value()) {
|
||||||
auto* newVersionTypeItem = new QTreeWidgetItem(itemTop);
|
auto* newVersionTypeItem = new QTreeWidgetItem(itemTop);
|
||||||
newVersionTypeItem->setText(0, tr("New Version Type: %1").arg(info.new_version_type.value().toString()));
|
newVersionTypeItem->setText(0, tr("New Version Type: %1").arg(info.newVersionType.value().toString()));
|
||||||
newVersionTypeItem->setData(0, Qt::UserRole, info.new_version_type.value().toString());
|
newVersionTypeItem->setData(0, Qt::UserRole, info.newVersionType.value().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!requiredBy.isEmpty()) {
|
if (!requiredBy.isEmpty()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue