diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-03-28 09:45:51 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-04-07 00:20:02 +0200 |
commit | 53188386b807f1f1ca5eebcd08303633ca4a13fb (patch) | |
tree | a9f8e48577bc04ddbd7db8c9002eb405c3908d74 /api/logic/minecraft | |
parent | af3384c649cb0f71a78ade376386d0c873754bb5 (diff) | |
download | MultiMC-53188386b807f1f1ca5eebcd08303633ca4a13fb.tar MultiMC-53188386b807f1f1ca5eebcd08303633ca4a13fb.tar.gz MultiMC-53188386b807f1f1ca5eebcd08303633ca4a13fb.tar.lz MultiMC-53188386b807f1f1ca5eebcd08303633ca4a13fb.tar.xz MultiMC-53188386b807f1f1ca5eebcd08303633ca4a13fb.zip |
NOISSUE refactor builtin patch loading slightly
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r-- | api/logic/minecraft/onesix/OneSixProfileStrategy.cpp | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp index c8d4aa2e..8125b1d6 100644 --- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp +++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp @@ -85,58 +85,37 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles() void OneSixProfileStrategy::loadDefaultBuiltinPatches() { + auto addBuiltinPatch = [&](const QString &uid, const QString intendedVersion, int order) { - auto mcJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "net.minecraft.json"); + auto jsonFilePath = FS::PathCombine(m_instance->instanceRoot(), "patches" , uid + ".json"); // load up the base minecraft patch - ProfilePatchPtr minecraftPatch; - if(QFile::exists(mcJson)) + ProfilePatchPtr profilePatch; + if(QFile::exists(jsonFilePath)) { - auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false); + auto file = ProfileUtils::parseJsonFile(QFileInfo(jsonFilePath), false); if(file->version.isEmpty()) { - file->version = m_instance->intendedVersionId(); + file->version = intendedVersion; } - minecraftPatch = std::make_shared<ProfilePatch>(file, mcJson); - minecraftPatch->setVanilla(false); - minecraftPatch->setRevertible(true); + profilePatch = std::make_shared<ProfilePatch>(file, jsonFilePath); + profilePatch->setVanilla(false); + profilePatch->setRevertible(true); } else { - auto mcversion = ENV.metadataIndex()->get("net.minecraft", m_instance->intendedVersionId()); - minecraftPatch = std::make_shared<ProfilePatch>(mcversion); - minecraftPatch->setVanilla(true); + auto metaVersion = ENV.metadataIndex()->get(uid, intendedVersion); + profilePatch = std::make_shared<ProfilePatch>(metaVersion); + profilePatch->setVanilla(true); } - if (!minecraftPatch) + if (!profilePatch) { - throw VersionIncomplete("net.minecraft"); + throw VersionIncomplete(uid); } - minecraftPatch->setOrder(-2); - profile->appendPatch(minecraftPatch); - } - - { - auto lwjglJson = FS::PathCombine(m_instance->instanceRoot(), "patches" , "org.lwjgl.json"); - ProfilePatchPtr lwjglPatch; - if(QFile::exists(lwjglJson)) - { - auto file = ProfileUtils::parseJsonFile(QFileInfo(lwjglJson), false); - lwjglPatch = std::make_shared<ProfilePatch>(file, lwjglJson); - lwjglPatch->setVanilla(false); - lwjglPatch->setRevertible(true); - } - else - { - auto lwjglversion = ENV.metadataIndex()->get("org.lwjgl", "2.9.1"); - lwjglPatch = std::make_shared<ProfilePatch>(lwjglversion); - lwjglPatch->setVanilla(true); - } - if (!lwjglPatch) - { - throw VersionIncomplete("org.lwjgl"); - } - lwjglPatch->setOrder(-1); - profile->appendPatch(lwjglPatch); - } + profilePatch->setOrder(order); + profile->appendPatch(profilePatch); + }; + addBuiltinPatch("net.minecraft", m_instance->intendedVersionId(), -2); + addBuiltinPatch("org.lwjgl", "2.9.1", -1); } void OneSixProfileStrategy::loadUserPatches() |