summaryrefslogtreecommitdiff
path: root/launcher/minecraft/update/AssetUpdateTask.cpp
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:36:40 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:36:40 +0300
commit1d4bf6e8b1208383021e22f61d859e9b721c482d (patch)
tree21c8e0c4350d7c44d817243ebf409be625ea4f21 /launcher/minecraft/update/AssetUpdateTask.cpp
parent38c57e163abad6216f7e0f44d401c362c5fd5da6 (diff)
downloadProject-Tick-1d4bf6e8b1208383021e22f61d859e9b721c482d.tar.gz
Project-Tick-1d4bf6e8b1208383021e22f61d859e9b721c482d.zip
NOISSUE reformat MeshMC to new clang format rules and fixed macOS portability issue and java find issue
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'launcher/minecraft/update/AssetUpdateTask.cpp')
-rw-r--r--launcher/minecraft/update/AssetUpdateTask.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/launcher/minecraft/update/AssetUpdateTask.cpp b/launcher/minecraft/update/AssetUpdateTask.cpp
index 778a4590bc..e6b2574df8 100644
--- a/launcher/minecraft/update/AssetUpdateTask.cpp
+++ b/launcher/minecraft/update/AssetUpdateTask.cpp
@@ -28,106 +28,106 @@
#include "Application.h"
-AssetUpdateTask::AssetUpdateTask(MinecraftInstance * inst)
+AssetUpdateTask::AssetUpdateTask(MinecraftInstance* inst)
{
- m_inst = inst;
+ m_inst = inst;
}
-AssetUpdateTask::~AssetUpdateTask()
-{
-}
+AssetUpdateTask::~AssetUpdateTask() {}
void AssetUpdateTask::executeTask()
{
- setStatus(tr("Updating assets index..."));
- auto components = m_inst->getPackProfile();
- auto profile = components->getProfile();
- auto assets = profile->getMinecraftAssets();
- QUrl indexUrl = assets->url;
- QString localPath = assets->id + ".json";
- auto job = new NetJob(
- tr("Asset index for %1").arg(m_inst->name()),
- APPLICATION->network()
- );
-
- auto metacache = APPLICATION->metacache();
- auto entry = metacache->resolveEntry("asset_indexes", localPath);
- entry->setStale(true);
- auto hexSha1 = assets->sha1.toLatin1();
- qDebug() << "Asset index SHA1:" << hexSha1;
- auto dl = Net::Download::makeCached(indexUrl, entry);
- auto rawSha1 = QByteArray::fromHex(assets->sha1.toLatin1());
- dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
- job->addNetAction(dl);
-
- downloadJob.reset(job);
-
- connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::assetIndexFinished);
- connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetIndexFailed);
- connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
-
- qDebug() << m_inst->name() << ": Starting asset index download";
- downloadJob->start();
+ setStatus(tr("Updating assets index..."));
+ auto components = m_inst->getPackProfile();
+ auto profile = components->getProfile();
+ auto assets = profile->getMinecraftAssets();
+ QUrl indexUrl = assets->url;
+ QString localPath = assets->id + ".json";
+ auto job = new NetJob(tr("Asset index for %1").arg(m_inst->name()),
+ APPLICATION->network());
+
+ auto metacache = APPLICATION->metacache();
+ auto entry = metacache->resolveEntry("asset_indexes", localPath);
+ entry->setStale(true);
+ auto hexSha1 = assets->sha1.toLatin1();
+ qDebug() << "Asset index SHA1:" << hexSha1;
+ auto dl = Net::Download::makeCached(indexUrl, entry);
+ auto rawSha1 = QByteArray::fromHex(assets->sha1.toLatin1());
+ dl->addValidator(
+ new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
+ job->addNetAction(dl);
+
+ downloadJob.reset(job);
+
+ connect(downloadJob.get(), &NetJob::succeeded, this,
+ &AssetUpdateTask::assetIndexFinished);
+ connect(downloadJob.get(), &NetJob::failed, this,
+ &AssetUpdateTask::assetIndexFailed);
+ connect(downloadJob.get(), &NetJob::progress, this,
+ &AssetUpdateTask::progress);
+
+ qDebug() << m_inst->name() << ": Starting asset index download";
+ downloadJob->start();
}
bool AssetUpdateTask::canAbort() const
{
- return true;
+ return true;
}
void AssetUpdateTask::assetIndexFinished()
{
- AssetsIndex index;
- qDebug() << m_inst->name() << ": Finished asset index download";
-
- auto components = m_inst->getPackProfile();
- auto profile = components->getProfile();
- auto assets = profile->getMinecraftAssets();
-
- QString asset_fname = "assets/indexes/" + assets->id + ".json";
- // FIXME: this looks like a job for a generic validator based on json schema?
- if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, index))
- {
- auto metacache = APPLICATION->metacache();
- auto entry = metacache->resolveEntry("asset_indexes", assets->id + ".json");
- metacache->evictEntry(entry);
- emitFailed(tr("Failed to read the assets index!"));
- }
-
- auto job = index.getDownloadJob();
- if(job)
- {
- setStatus(tr("Getting the assets files from Mojang..."));
- downloadJob = job;
- connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::emitSucceeded);
- connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetsFailed);
- connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
- downloadJob->start();
- return;
- }
- emitSucceeded();
+ AssetsIndex index;
+ qDebug() << m_inst->name() << ": Finished asset index download";
+
+ auto components = m_inst->getPackProfile();
+ auto profile = components->getProfile();
+ auto assets = profile->getMinecraftAssets();
+
+ QString asset_fname = "assets/indexes/" + assets->id + ".json";
+ // FIXME: this looks like a job for a generic validator based on json
+ // schema?
+ if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, index)) {
+ auto metacache = APPLICATION->metacache();
+ auto entry =
+ metacache->resolveEntry("asset_indexes", assets->id + ".json");
+ metacache->evictEntry(entry);
+ emitFailed(tr("Failed to read the assets index!"));
+ }
+
+ auto job = index.getDownloadJob();
+ if (job) {
+ setStatus(tr("Getting the assets files from Mojang..."));
+ downloadJob = job;
+ connect(downloadJob.get(), &NetJob::succeeded, this,
+ &AssetUpdateTask::emitSucceeded);
+ connect(downloadJob.get(), &NetJob::failed, this,
+ &AssetUpdateTask::assetsFailed);
+ connect(downloadJob.get(), &NetJob::progress, this,
+ &AssetUpdateTask::progress);
+ downloadJob->start();
+ return;
+ }
+ emitSucceeded();
}
void AssetUpdateTask::assetIndexFailed(QString reason)
{
- qDebug() << m_inst->name() << ": Failed asset index download";
- emitFailed(tr("Failed to download the assets index:\n%1").arg(reason));
+ qDebug() << m_inst->name() << ": Failed asset index download";
+ emitFailed(tr("Failed to download the assets index:\n%1").arg(reason));
}
void AssetUpdateTask::assetsFailed(QString reason)
{
- emitFailed(tr("Failed to download assets:\n%1").arg(reason));
+ emitFailed(tr("Failed to download assets:\n%1").arg(reason));
}
bool AssetUpdateTask::abort()
{
- if(downloadJob)
- {
- return downloadJob->abort();
- }
- else
- {
- qWarning() << "Prematurely aborted AssetUpdateTask";
- }
- return true;
+ if (downloadJob) {
+ return downloadJob->abort();
+ } else {
+ qWarning() << "Prematurely aborted AssetUpdateTask";
+ }
+ return true;
}