From 3f24c4cfe5afe47eb8ce6f0201b9099e4e50e8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 23 Apr 2017 02:31:13 +0200 Subject: GH-1856 Make MultiMC fail hard when things are missing Things like: * jar mods * valid version files --- api/logic/minecraft/ftb/FTBProfileStrategy.cpp | 67 +++++++++++++------------- 1 file changed, 34 insertions(+), 33 deletions(-) (limited to 'api/logic/minecraft/ftb/FTBProfileStrategy.cpp') diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp index b017277d..9fa4e6a1 100644 --- a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp +++ b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp @@ -1,7 +1,6 @@ #include "FTBProfileStrategy.h" #include "OneSixFTBInstance.h" -#include "minecraft/VersionBuildError.h" #include #include @@ -22,41 +21,43 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches() ProfilePatchPtr minecraftPatch; { + std::shared_ptr< VersionFile > file; auto mcJson = m_instance->versionsPath().absoluteFilePath(mcVersion + "/" + mcVersion + ".json"); // load up the base minecraft patch if(QFile::exists(mcJson)) { - auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); - file->uid = "net.minecraft"; - file->name = QObject::tr("Minecraft (tracked)"); - if(file->version.isEmpty()) - { - file->version = mcVersion; - } + file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); for(auto addLib: file->libraries) { addLib->setHint("local"); addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); } - minecraftPatch = std::make_shared(file); - minecraftPatch->setVanilla(true); } else { - throw VersionIncomplete("net.minecraft : " + mcJson); + file = std::make_shared(); + file->addProblem(ProblemSeverity::Error, QObject::tr("Minecraft version is missing in the FTB data.")); + } + file->uid = "net.minecraft"; + file->name = QObject::tr("Minecraft (tracked)"); + if(file->version.isEmpty()) + { + file->version = mcVersion; } + minecraftPatch = std::make_shared(file); + minecraftPatch->setVanilla(true); minecraftPatch->setOrder(-2); } profile->appendPatch(minecraftPatch); ProfilePatchPtr packPatch; { + std::shared_ptr< VersionFile > file; auto mcJson = m_instance->minecraftRoot() + "/pack.json"; - // load up the base minecraft patch + // load up the base minecraft patch, if it's there... if(QFile::exists(mcJson)) { - auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); - + file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); // adapt the loaded file - the FTB patch file format is different than ours. file->minecraftVersion.clear(); file->mainJar = nullptr; @@ -65,33 +66,33 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches() addLib->setHint("local"); addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); } - file->uid = "org.multimc.ftb.pack"; - file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name()); - if(file->version.isEmpty()) + } + else + { + file = std::make_shared(); + file->addProblem(ProblemSeverity::Error, QObject::tr("Modpack version file is missing.")); + } + file->uid = "org.multimc.ftb.pack"; + file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name()); + if(file->version.isEmpty()) + { + file->version = QObject::tr("Unknown"); + QFile versionFile (FS::PathCombine(m_instance->instanceRoot(), "version")); + if(versionFile.exists()) { - file->version = QObject::tr("Unknown"); - QFile versionFile (FS::PathCombine(m_instance->instanceRoot(), "version")); - if(versionFile.exists()) + if(versionFile.open(QIODevice::ReadOnly)) { - if(versionFile.open(QIODevice::ReadOnly)) - { - // FIXME: just guessing the encoding/charset here. - auto version = QString::fromUtf8(versionFile.readAll()); - file->version = version; - } + // FIXME: just guessing the encoding/charset here. + auto version = QString::fromUtf8(versionFile.readAll()); + file->version = version; } } - packPatch = std::make_shared(file); - packPatch->setVanilla(true); - } - else - { - throw VersionIncomplete("org.multimc.ftb.pack : " + mcJson); } + packPatch = std::make_shared(file); + packPatch->setVanilla(true); packPatch->setOrder(1); } profile->appendPatch(packPatch); - } void FTBProfileStrategy::load() -- cgit v1.2.3