diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-04-23 02:31:13 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-23 02:34:16 +0200 |
commit | 3f24c4cfe5afe47eb8ce6f0201b9099e4e50e8ba (patch) | |
tree | 298901b19ddf1bd645690bfe1d918d0c20e69780 /api/logic/minecraft/ftb/FTBProfileStrategy.cpp | |
parent | b414bbe395d8056365368fde823535fdde398e4c (diff) | |
download | PrismLauncher-3f24c4cfe5afe47eb8ce6f0201b9099e4e50e8ba.tar.gz PrismLauncher-3f24c4cfe5afe47eb8ce6f0201b9099e4e50e8ba.tar.bz2 PrismLauncher-3f24c4cfe5afe47eb8ce6f0201b9099e4e50e8ba.zip |
GH-1856 Make MultiMC fail hard when things are missing
Things like:
* jar mods
* valid version files
Diffstat (limited to 'api/logic/minecraft/ftb/FTBProfileStrategy.cpp')
-rw-r--r-- | api/logic/minecraft/ftb/FTBProfileStrategy.cpp | 67 |
1 files changed, 34 insertions, 33 deletions
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 <FileSystem.h> #include <QDir> @@ -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<ProfilePatch>(file); - minecraftPatch->setVanilla(true); } else { - throw VersionIncomplete("net.minecraft : " + mcJson); + file = std::make_shared<VersionFile>(); + 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<ProfilePatch>(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<VersionFile>(); + 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<ProfilePatch>(file); - packPatch->setVanilla(true); - } - else - { - throw VersionIncomplete("org.multimc.ftb.pack : " + mcJson); } + packPatch = std::make_shared<ProfilePatch>(file); + packPatch->setVanilla(true); packPatch->setOrder(1); } profile->appendPatch(packPatch); - } void FTBProfileStrategy::load() |