summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/onesix/OneSixUpdate.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-04-07 00:27:24 +0200
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:27:24 +0200
commit795889d934e8f4ebe89be1a49a3417fd98e89be1 (patch)
treec5b0d30d425003c4b88e84a2908e63eb5ed797b9 /api/logic/minecraft/onesix/OneSixUpdate.cpp
parent160b5033a79e6b5ee9f3e2a001b96c677f41ddcb (diff)
parent8e58d61150b0bdbe9eb91065d36342f3004fe97b (diff)
downloadMultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.gz
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.lz
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.tar.xz
MultiMC-795889d934e8f4ebe89be1a49a3417fd98e89be1.zip
Merge branch 'feature/meta' into develop
Diffstat (limited to 'api/logic/minecraft/onesix/OneSixUpdate.cpp')
-rw-r--r--api/logic/minecraft/onesix/OneSixUpdate.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp
index 4bc80bfe..bf234189 100644
--- a/api/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -24,7 +24,6 @@
#include <QDataStream>
#include "BaseInstance.h"
-#include "minecraft/MinecraftVersionList.h"
#include "minecraft/MinecraftProfile.h"
#include "minecraft/Library.h"
#include "net/URLConstants.h"
@@ -35,6 +34,9 @@
#include "update/FMLLibrariesTask.h"
#include "update/AssetUpdateTask.h"
+#include <meta/Index.h>
+#include <meta/Version.h>
+
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
{
// create folders
@@ -44,29 +46,23 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
// add a version update task, if necessary
{
- auto list = std::dynamic_pointer_cast<MinecraftVersionList>(ENV.getVersionList("net.minecraft"));
- auto version = std::dynamic_pointer_cast<MinecraftVersion>(list->findVersion(m_inst->intendedVersionId()));
- if (version == nullptr)
- {
- // don't do anything if it was invalid
- m_preFailure = tr("The specified Minecraft version is invalid. Choose a different one.");
- }
- else if (m_inst->providesVersionFile() || !version->needsUpdate())
+ /*
+ * FIXME: there are some corner cases here that remain unhandled:
+ * what if local load succeeds but remote fails? The version is still usable...
+ */
+ // FIXME: derive this from the actual list of version patches...
+ auto loadVersion = [&](const QString & uid, const QString & version)
{
- qDebug() << "Instance either provides a version file or doesn't need an update.";
- }
- else
- {
- auto versionUpdateTask = list->createUpdateTask(m_inst->intendedVersionId());
- if (!versionUpdateTask)
- {
- qDebug() << "Didn't spawn an update task.";
- }
- else
+ auto obj = ENV.metadataIndex()->get(uid, version);
+ obj->load();
+ auto task = obj->getCurrentTask();
+ if(task)
{
- m_tasks.append(versionUpdateTask);
+ m_tasks.append(task.unwrap());
}
- }
+ };
+ loadVersion("org.lwjgl", m_inst->getComponentVersion("org.lwjgl"));
+ loadVersion("net.minecraft", m_inst->getComponentVersion("net.minecraft"));
}
// libraries download
@@ -117,11 +113,20 @@ void OneSixUpdate::next()
return;
}
auto task = m_tasks[m_currentTask];
+ // if the task is already finished by the time we look at it, skip it
+ if(task->isFinished())
+ {
+ next();
+ }
connect(task.get(), &Task::succeeded, this, &OneSixUpdate::subtaskSucceeded);
connect(task.get(), &Task::failed, this, &OneSixUpdate::subtaskFailed);
connect(task.get(), &Task::progress, this, &OneSixUpdate::progress);
connect(task.get(), &Task::status, this, &OneSixUpdate::setStatus);
- task->start();
+ // if the task is already running, do not start it again
+ if(!task->isRunning())
+ {
+ task->start();
+ }
}
void OneSixUpdate::subtaskSucceeded()