@ -1,22 +1,20 @@
|
||||
#include "AssetUpdateTask.h"
|
||||
|
||||
#include "minecraft/AssetsUtils.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "net/ChecksumValidator.h"
|
||||
#include "minecraft/AssetsUtils.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
AssetUpdateTask::AssetUpdateTask(MinecraftInstance * inst)
|
||||
AssetUpdateTask::AssetUpdateTask(MinecraftInstance* inst)
|
||||
{
|
||||
m_inst = inst;
|
||||
}
|
||||
|
||||
AssetUpdateTask::~AssetUpdateTask()
|
||||
{
|
||||
}
|
||||
AssetUpdateTask::~AssetUpdateTask() {}
|
||||
|
||||
void AssetUpdateTask::executeTask()
|
||||
{
|
||||
@ -26,10 +24,7 @@ void AssetUpdateTask::executeTask()
|
||||
auto assets = profile->getMinecraftAssets();
|
||||
QUrl indexUrl = assets->url;
|
||||
QString localPath = assets->id + ".json";
|
||||
auto job = makeShared<NetJob>(
|
||||
tr("Asset index for %1").arg(m_inst->name()),
|
||||
APPLICATION->network()
|
||||
);
|
||||
auto job = makeShared<NetJob>(tr("Asset index for %1").arg(m_inst->name()), APPLICATION->network());
|
||||
|
||||
auto metacache = APPLICATION->metacache();
|
||||
auto entry = metacache->resolveEntry("asset_indexes", localPath);
|
||||
@ -45,7 +40,7 @@ void AssetUpdateTask::executeTask()
|
||||
|
||||
connect(downloadJob.get(), &NetJob::succeeded, this, &AssetUpdateTask::assetIndexFinished);
|
||||
connect(downloadJob.get(), &NetJob::failed, this, &AssetUpdateTask::assetIndexFailed);
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this] { emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
|
||||
connect(downloadJob.get(), &NetJob::stepProgress, this, &AssetUpdateTask::propagateStepProgress);
|
||||
|
||||
@ -69,8 +64,7 @@ void AssetUpdateTask::assetIndexFinished()
|
||||
|
||||
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))
|
||||
{
|
||||
if (!AssetsUtils::loadAssetsIndexJson(assets->id, asset_fname, index)) {
|
||||
auto metacache = APPLICATION->metacache();
|
||||
auto entry = metacache->resolveEntry("asset_indexes", assets->id + ".json");
|
||||
metacache->evictEntry(entry);
|
||||
@ -78,13 +72,12 @@ void AssetUpdateTask::assetIndexFinished()
|
||||
}
|
||||
|
||||
auto job = index.getDownloadJob();
|
||||
if(job)
|
||||
{
|
||||
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::aborted, this, [this]{ emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this] { emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::progress, this, &AssetUpdateTask::progress);
|
||||
connect(downloadJob.get(), &NetJob::stepProgress, this, &AssetUpdateTask::propagateStepProgress);
|
||||
downloadJob->start();
|
||||
@ -106,12 +99,9 @@ void AssetUpdateTask::assetsFailed(QString reason)
|
||||
|
||||
bool AssetUpdateTask::abort()
|
||||
{
|
||||
if(downloadJob)
|
||||
{
|
||||
if (downloadJob) {
|
||||
return downloadJob->abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qWarning() << "Prematurely aborted AssetUpdateTask";
|
||||
}
|
||||
return true;
|
||||
|
@ -1,28 +1,27 @@
|
||||
#pragma once
|
||||
#include "tasks/Task.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "tasks/Task.h"
|
||||
class MinecraftInstance;
|
||||
|
||||
class AssetUpdateTask : public Task
|
||||
{
|
||||
class AssetUpdateTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AssetUpdateTask(MinecraftInstance * inst);
|
||||
public:
|
||||
AssetUpdateTask(MinecraftInstance* inst);
|
||||
virtual ~AssetUpdateTask();
|
||||
|
||||
void executeTask() override;
|
||||
|
||||
bool canAbort() const override;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void assetIndexFinished();
|
||||
void assetIndexFailed(QString reason);
|
||||
void assetsFailed(QString reason);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
bool abort() override;
|
||||
|
||||
private:
|
||||
MinecraftInstance *m_inst;
|
||||
private:
|
||||
MinecraftInstance* m_inst;
|
||||
NetJob::Ptr downloadJob;
|
||||
};
|
||||
|
@ -1,53 +1,49 @@
|
||||
#include "FMLLibrariesTask.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include "minecraft/PackProfile.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
|
||||
#include "BuildConfig.h"
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
|
||||
#include "net/ApiDownload.h"
|
||||
|
||||
FMLLibrariesTask::FMLLibrariesTask(MinecraftInstance * inst)
|
||||
FMLLibrariesTask::FMLLibrariesTask(MinecraftInstance* inst)
|
||||
{
|
||||
m_inst = inst;
|
||||
}
|
||||
void FMLLibrariesTask::executeTask()
|
||||
{
|
||||
// Get the mod list
|
||||
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
|
||||
MinecraftInstance* inst = (MinecraftInstance*)m_inst;
|
||||
auto components = inst->getPackProfile();
|
||||
auto profile = components->getProfile();
|
||||
|
||||
if (!profile->hasTrait("legacyFML"))
|
||||
{
|
||||
if (!profile->hasTrait("legacyFML")) {
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
|
||||
QString version = components->getComponentVersion("net.minecraft");
|
||||
auto &fmlLibsMapping = g_VersionFilterData.fmlLibsMapping;
|
||||
if (!fmlLibsMapping.contains(version))
|
||||
{
|
||||
auto& fmlLibsMapping = g_VersionFilterData.fmlLibsMapping;
|
||||
if (!fmlLibsMapping.contains(version)) {
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
|
||||
auto &libList = fmlLibsMapping[version];
|
||||
auto& libList = fmlLibsMapping[version];
|
||||
|
||||
// determine if we need some libs for FML or forge
|
||||
setStatus(tr("Checking for FML libraries..."));
|
||||
if(!components->getComponent("net.minecraftforge"))
|
||||
{
|
||||
if (!components->getComponent("net.minecraftforge")) {
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
|
||||
// now check the lib folder inside the instance for files.
|
||||
for (auto &lib : libList)
|
||||
{
|
||||
for (auto& lib : libList) {
|
||||
QFileInfo libInfo(FS::PathCombine(inst->libDir(), lib.filename));
|
||||
if (libInfo.exists())
|
||||
continue;
|
||||
@ -55,8 +51,7 @@ void FMLLibrariesTask::executeTask()
|
||||
}
|
||||
|
||||
// if everything is in place, there's nothing to do here...
|
||||
if (fmlLibsToProcess.isEmpty())
|
||||
{
|
||||
if (fmlLibsToProcess.isEmpty()) {
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
@ -66,8 +61,7 @@ void FMLLibrariesTask::executeTask()
|
||||
NetJob::Ptr dljob{ new NetJob("FML libraries", APPLICATION->network()) };
|
||||
auto metacache = APPLICATION->metacache();
|
||||
Net::Download::Options options = Net::Download::Option::MakeEternal;
|
||||
for (auto &lib : fmlLibsToProcess)
|
||||
{
|
||||
for (auto& lib : fmlLibsToProcess) {
|
||||
auto entry = metacache->resolveEntry("fmllibs", lib.filename);
|
||||
QString urlString = BuildConfig.FMLLIBS_BASE_URL + lib.filename;
|
||||
dljob->addNetAction(Net::ApiDownload::makeCached(QUrl(urlString), entry, options));
|
||||
@ -75,7 +69,7 @@ void FMLLibrariesTask::executeTask()
|
||||
|
||||
connect(dljob.get(), &NetJob::succeeded, this, &FMLLibrariesTask::fmllibsFinished);
|
||||
connect(dljob.get(), &NetJob::failed, this, &FMLLibrariesTask::fmllibsFailed);
|
||||
connect(dljob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
|
||||
connect(dljob.get(), &NetJob::aborted, this, [this] { emitFailed(tr("Aborted")); });
|
||||
connect(dljob.get(), &NetJob::progress, this, &FMLLibrariesTask::progress);
|
||||
connect(dljob.get(), &NetJob::stepProgress, this, &FMLLibrariesTask::propagateStepProgress);
|
||||
downloadJob.reset(dljob);
|
||||
@ -90,24 +84,20 @@ bool FMLLibrariesTask::canAbort() const
|
||||
void FMLLibrariesTask::fmllibsFinished()
|
||||
{
|
||||
downloadJob.reset();
|
||||
if (!fmlLibsToProcess.isEmpty())
|
||||
{
|
||||
if (!fmlLibsToProcess.isEmpty()) {
|
||||
setStatus(tr("Copying FML libraries into the instance..."));
|
||||
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
|
||||
MinecraftInstance* inst = (MinecraftInstance*)m_inst;
|
||||
auto metacache = APPLICATION->metacache();
|
||||
int index = 0;
|
||||
for (auto &lib : fmlLibsToProcess)
|
||||
{
|
||||
for (auto& lib : fmlLibsToProcess) {
|
||||
progress(index, fmlLibsToProcess.size());
|
||||
auto entry = metacache->resolveEntry("fmllibs", lib.filename);
|
||||
auto path = FS::PathCombine(inst->libDir(), lib.filename);
|
||||
if (!FS::ensureFilePathExists(path))
|
||||
{
|
||||
if (!FS::ensureFilePathExists(path)) {
|
||||
emitFailed(tr("Failed creating FML library folder inside the instance."));
|
||||
return;
|
||||
}
|
||||
if (!QFile::copy(entry->getFullPath(), FS::PathCombine(inst->libDir(), lib.filename)))
|
||||
{
|
||||
if (!QFile::copy(entry->getFullPath(), FS::PathCombine(inst->libDir(), lib.filename))) {
|
||||
emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.filename));
|
||||
return;
|
||||
}
|
||||
@ -126,12 +116,9 @@ void FMLLibrariesTask::fmllibsFailed(QString reason)
|
||||
|
||||
bool FMLLibrariesTask::abort()
|
||||
{
|
||||
if(downloadJob)
|
||||
{
|
||||
if (downloadJob) {
|
||||
return downloadJob->abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qWarning() << "Prematurely aborted FMLLibrariesTask";
|
||||
}
|
||||
return true;
|
||||
|
@ -1,31 +1,29 @@
|
||||
#pragma once
|
||||
#include "tasks/Task.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "minecraft/VersionFilterData.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "tasks/Task.h"
|
||||
|
||||
class MinecraftInstance;
|
||||
|
||||
class FMLLibrariesTask : public Task
|
||||
{
|
||||
class FMLLibrariesTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FMLLibrariesTask(MinecraftInstance * inst);
|
||||
virtual ~FMLLibrariesTask() {};
|
||||
public:
|
||||
FMLLibrariesTask(MinecraftInstance* inst);
|
||||
virtual ~FMLLibrariesTask(){};
|
||||
|
||||
void executeTask() override;
|
||||
|
||||
bool canAbort() const override;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void fmllibsFinished();
|
||||
void fmllibsFailed(QString reason);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
bool abort() override;
|
||||
|
||||
private:
|
||||
MinecraftInstance *m_inst;
|
||||
private:
|
||||
MinecraftInstance* m_inst;
|
||||
NetJob::Ptr downloadJob;
|
||||
QList<FMLlib> fmlLibsToProcess;
|
||||
};
|
||||
|
||||
|
@ -34,11 +34,10 @@
|
||||
*/
|
||||
|
||||
#include "FoldersTask.h"
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
#include <QDir>
|
||||
#include "minecraft/MinecraftInstance.h"
|
||||
|
||||
FoldersTask::FoldersTask(MinecraftInstance * inst)
|
||||
:Task()
|
||||
FoldersTask::FoldersTask(MinecraftInstance* inst) : Task()
|
||||
{
|
||||
m_inst = inst;
|
||||
}
|
||||
@ -47,8 +46,7 @@ void FoldersTask::executeTask()
|
||||
{
|
||||
// Make directories
|
||||
QDir mcDir(m_inst->gameRoot());
|
||||
if (!mcDir.exists() && !mcDir.mkpath("."))
|
||||
{
|
||||
if (!mcDir.exists() && !mcDir.mkpath(".")) {
|
||||
emitFailed(tr("Failed to create folder for Minecraft binaries."));
|
||||
return;
|
||||
}
|
||||
|
@ -3,15 +3,14 @@
|
||||
#include "tasks/Task.h"
|
||||
|
||||
class MinecraftInstance;
|
||||
class FoldersTask : public Task
|
||||
{
|
||||
class FoldersTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FoldersTask(MinecraftInstance * inst);
|
||||
virtual ~FoldersTask() {};
|
||||
public:
|
||||
FoldersTask(MinecraftInstance* inst);
|
||||
virtual ~FoldersTask(){};
|
||||
|
||||
void executeTask() override;
|
||||
private:
|
||||
MinecraftInstance *m_inst;
|
||||
};
|
||||
|
||||
private:
|
||||
MinecraftInstance* m_inst;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
LibrariesTask::LibrariesTask(MinecraftInstance * inst)
|
||||
LibrariesTask::LibrariesTask(MinecraftInstance* inst)
|
||||
{
|
||||
m_inst = inst;
|
||||
}
|
||||
@ -14,7 +14,7 @@ void LibrariesTask::executeTask()
|
||||
{
|
||||
setStatus(tr("Downloading required library files..."));
|
||||
qDebug() << m_inst->name() << ": downloading libraries";
|
||||
MinecraftInstance *inst = (MinecraftInstance *)m_inst;
|
||||
MinecraftInstance* inst = (MinecraftInstance*)m_inst;
|
||||
|
||||
// Build a list of URLs that will need to be downloaded.
|
||||
auto components = inst->getPackProfile();
|
||||
@ -25,18 +25,14 @@ void LibrariesTask::executeTask()
|
||||
|
||||
auto metacache = APPLICATION->metacache();
|
||||
|
||||
auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
|
||||
{
|
||||
for (auto lib : pool)
|
||||
{
|
||||
if(!lib)
|
||||
{
|
||||
auto processArtifactPool = [&](const QList<LibraryPtr>& pool, QStringList& errors, const QString& localPath) {
|
||||
for (auto lib : pool) {
|
||||
if (!lib) {
|
||||
emitFailed(tr("Null jar is specified in the metadata, aborting."));
|
||||
return false;
|
||||
}
|
||||
auto dls = lib->getDownloads(inst->runtimeContext(), metacache.get(), errors, localPath);
|
||||
for(auto dl : dls)
|
||||
{
|
||||
for (auto dl : dls) {
|
||||
downloadJob->addNetAction(dl);
|
||||
}
|
||||
}
|
||||
@ -48,8 +44,7 @@ void LibrariesTask::executeTask()
|
||||
libArtifactPool.append(profile->getLibraries());
|
||||
libArtifactPool.append(profile->getNativeLibraries());
|
||||
libArtifactPool.append(profile->getMavenFiles());
|
||||
for (auto agent : profile->getAgents())
|
||||
{
|
||||
for (auto agent : profile->getAgents()) {
|
||||
libArtifactPool.append(agent->library());
|
||||
}
|
||||
libArtifactPool.append(profile->getMainJar());
|
||||
@ -58,17 +53,18 @@ void LibrariesTask::executeTask()
|
||||
QStringList failedLocalJarMods;
|
||||
processArtifactPool(profile->getJarMods(), failedLocalJarMods, inst->jarModsDir());
|
||||
|
||||
if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty())
|
||||
{
|
||||
if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty()) {
|
||||
downloadJob.reset();
|
||||
QString failed_all = (failedLocalLibraries + failedLocalJarMods).join("\n");
|
||||
emitFailed(tr("Some artifacts marked as 'local' are missing their files:\n%1\n\nYou need to either add the files, or removed the packages that require them.\nYou'll have to correct this problem manually.").arg(failed_all));
|
||||
emitFailed(tr("Some artifacts marked as 'local' are missing their files:\n%1\n\nYou need to either add the files, or removed the "
|
||||
"packages that require them.\nYou'll have to correct this problem manually.")
|
||||
.arg(failed_all));
|
||||
return;
|
||||
}
|
||||
|
||||
connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
|
||||
connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this]{ emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::aborted, this, [this] { emitFailed(tr("Aborted")); });
|
||||
connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
|
||||
connect(downloadJob.get(), &NetJob::stepProgress, this, &LibrariesTask::propagateStepProgress);
|
||||
|
||||
@ -87,12 +83,9 @@ void LibrariesTask::jarlibFailed(QString reason)
|
||||
|
||||
bool LibrariesTask::abort()
|
||||
{
|
||||
if(downloadJob)
|
||||
{
|
||||
if (downloadJob) {
|
||||
return downloadJob->abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
qWarning() << "Prematurely aborted LibrariesTask";
|
||||
}
|
||||
return true;
|
||||
|
@ -1,26 +1,25 @@
|
||||
#pragma once
|
||||
#include "tasks/Task.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "tasks/Task.h"
|
||||
class MinecraftInstance;
|
||||
|
||||
class LibrariesTask : public Task
|
||||
{
|
||||
class LibrariesTask : public Task {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LibrariesTask(MinecraftInstance * inst);
|
||||
virtual ~LibrariesTask() {};
|
||||
public:
|
||||
LibrariesTask(MinecraftInstance* inst);
|
||||
virtual ~LibrariesTask(){};
|
||||
|
||||
void executeTask() override;
|
||||
|
||||
bool canAbort() const override;
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void jarlibFailed(QString reason);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
bool abort() override;
|
||||
|
||||
private:
|
||||
MinecraftInstance *m_inst;
|
||||
private:
|
||||
MinecraftInstance* m_inst;
|
||||
NetJob::Ptr downloadJob;
|
||||
};
|
||||
|
Reference in New Issue
Block a user