diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-03-19 02:13:49 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:20:02 +0200 |
commit | 2660418d58efb33cd3a0ab8ed9d48c359c076905 (patch) | |
tree | 0f947fea5c1dc59a2db83bab85e3fecbc19e4c5c /api/logic/minecraft | |
parent | e46aba9da584338db8d8a1a8a487bdcc6cf84343 (diff) | |
download | MultiMC-2660418d58efb33cd3a0ab8ed9d48c359c076905.tar MultiMC-2660418d58efb33cd3a0ab8ed9d48c359c076905.tar.gz MultiMC-2660418d58efb33cd3a0ab8ed9d48c359c076905.tar.lz MultiMC-2660418d58efb33cd3a0ab8ed9d48c359c076905.tar.xz MultiMC-2660418d58efb33cd3a0ab8ed9d48c359c076905.zip |
NOISSUE hack it together enough to get launching back
Meta index will now always return valid objects.
They just might never load if they don't exist on the server.
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r-- | api/logic/minecraft/ProfilePatch.h | 4 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixProfileStrategy.cpp | 6 | ||||
-rw-r--r-- | api/logic/minecraft/onesix/OneSixUpdate.cpp | 48 |
3 files changed, 30 insertions, 28 deletions
diff --git a/api/logic/minecraft/ProfilePatch.h b/api/logic/minecraft/ProfilePatch.h index 26230092..b61fb8b3 100644 --- a/api/logic/minecraft/ProfilePatch.h +++ b/api/logic/minecraft/ProfilePatch.h @@ -92,10 +92,6 @@ public: { return m_problemSeverity; } - virtual bool hasFailed() - { - return getProblemSeverity() == PROBLEM_ERROR; - } protected: QList<PatchProblem> m_problems; diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp index e3d3f674..b19a2dea 100644 --- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp +++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp @@ -12,6 +12,8 @@ #include <QJsonArray> #include <QSaveFile> #include <QResource> +#include <meta/Index.h> +#include <meta/Version.h> OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance) { @@ -98,7 +100,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches() } else { - auto mcversion = ENV.getVersion("net.minecraft", m_instance->intendedVersionId()); + auto mcversion = ENV.metadataIndex()->get("net.minecraft", m_instance->intendedVersionId()); minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion); } if (!minecraftPatch) @@ -121,7 +123,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches() } else { - auto lwjglversion = ENV.getVersion("org.lwjgl", "2.9.1" /*m_instance->intendedVersionId()*/); + auto lwjglversion = ENV.metadataIndex()->get("org.lwjgl", "2.9.1"); lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjglversion); } if (!lwjglPatch) diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp index ec40e086..5bc76b01 100644 --- a/api/logic/minecraft/onesix/OneSixUpdate.cpp +++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp @@ -34,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,30 +47,22 @@ 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", "2.9.1"); + loadVersion("net.minecraft", m_inst->intendedVersionId()); } // libraries download @@ -118,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() |