From 4fa3e2a7144c532af62520c9da53f423d6f002ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 24 Apr 2017 01:30:51 +0200 Subject: GH-1856 Fix metadata version and list loading Shouldn't crash anymore, shouldn't overwrite data in some bad way anymore either. --- api/logic/minecraft/onesix/OneSixUpdate.cpp | 33 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'api/logic/minecraft/onesix/OneSixUpdate.cpp') diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp index bf234189..e0027032 100644 --- a/api/logic/minecraft/onesix/OneSixUpdate.cpp +++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp @@ -44,25 +44,36 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent) m_tasks.append(std::make_shared(m_inst)); } - // add a version update task, if necessary + // add metadata update tasks, if necessary { /* * FIXME: there are some corner cases here that remain unhandled: * what if local load succeeds but remote fails? The version is still usable... + * We should not rely on the remote to be there... and prefer local files if it does not respond. */ - // FIXME: derive this from the actual list of version patches... - auto loadVersion = [&](const QString & uid, const QString & version) + qDebug() << "Updating patches..."; + auto profile = m_inst->getMinecraftProfile(); + m_inst->reloadProfile(); + for(int i = 0; i < profile->rowCount(); i++) { - auto obj = ENV.metadataIndex()->get(uid, version); - obj->load(); - auto task = obj->getCurrentTask(); - if(task) + auto patch = profile->versionPatch(i); + auto id = patch->getID(); + auto metadata = patch->getMeta(); + if(metadata) { - m_tasks.append(task.unwrap()); + metadata->load(); + auto task = metadata->getCurrentTask(); + if(task) + { + qDebug() << "Loading remote meta patch" << id; + m_tasks.append(task.unwrap()); + } } - }; - loadVersion("org.lwjgl", m_inst->getComponentVersion("org.lwjgl")); - loadVersion("net.minecraft", m_inst->getComponentVersion("net.minecraft")); + else + { + qDebug() << "Ignoring local patch" << id; + } + } } // libraries download -- cgit v1.2.3