From b6f133f579d77d4fa8d403448dd951563cda1a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 9 Nov 2016 01:22:02 +0100 Subject: [PATCH] GH-1713 fix FTB loading crashes --- api/logic/InstanceList.cpp | 5 ++++- api/logic/minecraft/ftb/FTBInstanceProvider.cpp | 16 +++++----------- application/MultiMC.cpp | 2 ++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index 9bdcc113..2c1e9e06 100644 --- a/api/logic/InstanceList.cpp +++ b/api/logic/InstanceList.cpp @@ -159,7 +159,10 @@ InstanceList::InstListError InstanceList::loadList(bool complete) else { InstancePtr instPtr = provider->loadInstance(id); - newList.append(instPtr); + if(instPtr) + { + newList.append(instPtr); + } } } }; diff --git a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp index a583c039..1321ea1b 100644 --- a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp +++ b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp @@ -236,15 +236,6 @@ InstancePtr FTBInstanceProvider::createInstance(const FTBRecord & record) const qDebug() << "Converting " << record.name << " as new."; - auto mcVersion = std::dynamic_pointer_cast(ENV.getVersion("net.minecraft", record.mcVersion)); - if (!mcVersion) - { - qCritical() << "Can't load instance " << record.instanceDir - << " because minecraft version " << record.mcVersion - << " can't be resolved."; - return nullptr; - } - if (!rootDir.exists() && !rootDir.mkpath(".")) { qCritical() << "Can't create instance folder" << record.instanceDir; @@ -254,7 +245,9 @@ InstancePtr FTBInstanceProvider::createInstance(const FTBRecord & record) const auto m_settings = std::make_shared(FS::PathCombine(record.instanceDir, "instance.cfg")); m_settings->registerSetting("InstanceType", "Legacy"); - if (mcVersion->usesLegacyLauncher()) + // all legacy versions are built in. therefore we can do this even if we don't have ALL the versions Mojang has on their servers. + auto mcVersion = std::dynamic_pointer_cast(ENV.getVersion("net.minecraft", record.mcVersion)); + if (mcVersion && mcVersion->usesLegacyLauncher()) { m_settings->set("InstanceType", "LegacyFTB"); inst.reset(new LegacyFTBInstance(m_globalSettings, m_settings, record.instanceDir)); @@ -264,10 +257,11 @@ InstancePtr FTBInstanceProvider::createInstance(const FTBRecord & record) const m_settings->set("InstanceType", "OneSixFTB"); inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir)); } + // initialize { SettingsObject::Lock lock(inst->settings()); - inst->setIntendedVersionId(mcVersion->descriptor()); + inst->setIntendedVersionId(record.mcVersion); inst->init(); inst->setGroupInitial("FTB"); inst->setName(record.name); diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 334c51fc..2cc934f1 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -258,6 +258,8 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) initIcons(); initThemes(); + // make sure we have at least some minecraft versions before we init instances + minecraftlist(); initInstances(); initAccounts(); initNetwork();