diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-05-09 17:16:25 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:30 +0200 |
commit | 9860d5ee12acde8f7893848dac53f59ea66da281 (patch) | |
tree | 966e1d9ba1bbb1d4303bfc742faaaccd0957de8f /logic | |
parent | 8a3a0f5a529a95c7511436051b63887dff158c50 (diff) | |
download | MultiMC-9860d5ee12acde8f7893848dac53f59ea66da281.tar MultiMC-9860d5ee12acde8f7893848dac53f59ea66da281.tar.gz MultiMC-9860d5ee12acde8f7893848dac53f59ea66da281.tar.lz MultiMC-9860d5ee12acde8f7893848dac53f59ea66da281.tar.xz MultiMC-9860d5ee12acde8f7893848dac53f59ea66da281.zip |
Introducing VersionPatch base class for version files and minecraft versions
Diffstat (limited to 'logic')
-rw-r--r-- | logic/OneSixFTBInstance.cpp | 2 | ||||
-rw-r--r-- | logic/OneSixUpdate.cpp | 2 | ||||
-rw-r--r-- | logic/minecraft/JarMod.cpp | 44 | ||||
-rw-r--r-- | logic/minecraft/JarMod.h | 17 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersion.cpp | 2 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersion.h | 18 | ||||
-rw-r--r-- | logic/minecraft/OneSixRule.cpp | 17 | ||||
-rw-r--r-- | logic/minecraft/OneSixRule.h | 1 | ||||
-rw-r--r-- | logic/minecraft/RawLibrary.cpp | 68 | ||||
-rw-r--r-- | logic/minecraft/RawLibrary.h | 47 | ||||
-rw-r--r-- | logic/minecraft/VersionBuilder.cpp (renamed from logic/minecraft/OneSixVersionBuilder.cpp) | 22 | ||||
-rw-r--r-- | logic/minecraft/VersionBuilder.h (renamed from logic/minecraft/OneSixVersionBuilder.h) | 4 | ||||
-rw-r--r-- | logic/minecraft/VersionFile.cpp | 124 | ||||
-rw-r--r-- | logic/minecraft/VersionFile.h | 63 | ||||
-rw-r--r-- | logic/minecraft/VersionFinal.cpp | 16 | ||||
-rw-r--r-- | logic/minecraft/VersionFinal.h | 3 | ||||
-rw-r--r-- | logic/minecraft/VersionPatch.h | 15 |
17 files changed, 267 insertions, 198 deletions
diff --git a/logic/OneSixFTBInstance.cpp b/logic/OneSixFTBInstance.cpp index 491b15ba..eb0e4ba4 100644 --- a/logic/OneSixFTBInstance.cpp +++ b/logic/OneSixFTBInstance.cpp @@ -2,7 +2,7 @@ #include "logic/minecraft/VersionFinal.h" #include "logic/minecraft/OneSixLibrary.h" -#include "logic/minecraft/OneSixVersionBuilder.h" +#include "logic/minecraft/VersionBuilder.h" #include "tasks/SequentialTask.h" #include "forge/ForgeInstaller.h" #include "forge/ForgeVersionList.h" diff --git a/logic/OneSixUpdate.cpp b/logic/OneSixUpdate.cpp index 66a699fe..beb293ff 100644 --- a/logic/OneSixUpdate.cpp +++ b/logic/OneSixUpdate.cpp @@ -480,7 +480,7 @@ void OneSixUpdate::fmllibsStart() // determine if we need some libs for FML or forge setStatus(tr("Checking for FML libraries...")); - forge_present = (fullversion->versionFile("net.minecraftforge") != nullptr); + forge_present = (fullversion->versionPatch("net.minecraftforge") != nullptr); // we don't... if (!forge_present) { diff --git a/logic/minecraft/JarMod.cpp b/logic/minecraft/JarMod.cpp new file mode 100644 index 00000000..99a30aa5 --- /dev/null +++ b/logic/minecraft/JarMod.cpp @@ -0,0 +1,44 @@ +#include "JarMod.h" +#include "logic/MMCJson.h" + +JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename) +{ + JarmodPtr out(new Jarmod()); + if (!libObj.contains("name")) + { + throw JSONValidationError(filename + + "contains a jarmod that doesn't have a 'name' field"); + } + out->name = libObj.value("name").toString(); + + auto readString = [libObj, filename](const QString & key, QString & variable) + { + if (libObj.contains(key)) + { + QJsonValue val = libObj.value(key); + if (!val.isString()) + { + QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; + } + else + { + variable = val.toString(); + } + } + }; + + readString("url", out->baseurl); + readString("MMC-absoluteUrl", out->absoluteUrl); + if(!out->baseurl.isEmpty() && out->absoluteUrl.isEmpty()) + { + out->absoluteUrl = out->baseurl + out->name; + } + return out; +} + +QString Jarmod::url() +{ + if(!absoluteUrl.isEmpty()) + return absoluteUrl; + else return baseurl + name; +} diff --git a/logic/minecraft/JarMod.h b/logic/minecraft/JarMod.h new file mode 100644 index 00000000..da5d8db0 --- /dev/null +++ b/logic/minecraft/JarMod.h @@ -0,0 +1,17 @@ +#pragma once +#include <QString> +#include <QJsonObject> +#include <memory> +class Jarmod; +typedef std::shared_ptr<Jarmod> JarmodPtr; +class Jarmod +{ +public: /* methods */ + static JarmodPtr fromJson(const QJsonObject &libObj, const QString &filename); + QString url(); +public: /* data */ + QString name; + QString baseurl; + QString hint; + QString absoluteUrl; +}; diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp new file mode 100644 index 00000000..a2e5a50a --- /dev/null +++ b/logic/minecraft/MinecraftVersion.cpp @@ -0,0 +1,2 @@ +#include "MinecraftVersion.h" + diff --git a/logic/minecraft/MinecraftVersion.h b/logic/minecraft/MinecraftVersion.h index 3be25912..dab08bb1 100644 --- a/logic/minecraft/MinecraftVersion.h +++ b/logic/minecraft/MinecraftVersion.h @@ -16,10 +16,11 @@ #pragma once #include "logic/BaseVersion.h" +#include "VersionPatch.h" #include <QStringList> #include <QSet> -struct MinecraftVersion : public BaseVersion +struct MinecraftVersion : public BaseVersion, public VersionPatch { /// The version's timestamp - this is primarily used for sorting versions in a list. qint64 timestamp; @@ -89,4 +90,19 @@ struct MinecraftVersion : public BaseVersion return QObject::tr("Regular release"); } } + + virtual bool hasJarMods() override + { + return false; + } + + virtual bool isVanilla() override + { + return true; + } + + virtual void applyTo(VersionFinal *version) + { + // umm... what now? + } }; diff --git a/logic/minecraft/OneSixRule.cpp b/logic/minecraft/OneSixRule.cpp index d8d13b50..93c49e5e 100644 --- a/logic/minecraft/OneSixRule.cpp +++ b/logic/minecraft/OneSixRule.cpp @@ -18,6 +18,15 @@ #include "OneSixRule.h" +RuleAction RuleAction_fromString(QString name) +{ + if (name == "allow") + return Allow; + if (name == "disallow") + return Disallow; + return Defer; +} + QList<std::shared_ptr<Rule>> rulesFromJsonV4(const QJsonObject &objectWithRules) { QList<std::shared_ptr<Rule>> rules; @@ -79,11 +88,3 @@ QJsonObject OsRule::toJson() return ruleObj; } -RuleAction RuleAction_fromString(QString name) -{ - if (name == "allow") - return Allow; - if (name == "disallow") - return Disallow; - return Defer; -} diff --git a/logic/minecraft/OneSixRule.h b/logic/minecraft/OneSixRule.h index 2c569b9f..23d04151 100644 --- a/logic/minecraft/OneSixRule.h +++ b/logic/minecraft/OneSixRule.h @@ -26,7 +26,6 @@ enum RuleAction Defer }; -RuleAction RuleAction_fromString(QString); QList<std::shared_ptr<Rule>> rulesFromJsonV4(const QJsonObject &objectWithRules); class Rule diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp new file mode 100644 index 00000000..12aac8c8 --- /dev/null +++ b/logic/minecraft/RawLibrary.cpp @@ -0,0 +1,68 @@ +#include "logic/MMCJson.h" +using namespace MMCJson; + +#include "RawLibrary.h" + +RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename) +{ + RawLibraryPtr out(new RawLibrary()); + if (!libObj.contains("name")) + { + throw JSONValidationError(filename + + "contains a library that doesn't have a 'name' field"); + } + out->name = libObj.value("name").toString(); + + auto readString = [libObj, filename](const QString & key, QString & variable) + { + if (libObj.contains(key)) + { + QJsonValue val = libObj.value(key); + if (!val.isString()) + { + QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; + } + else + { + variable = val.toString(); + } + } + }; + + readString("url", out->url); + readString("MMC-hint", out->hint); + readString("MMC-absulute_url", out->absoluteUrl); + readString("MMC-absoluteUrl", out->absoluteUrl); + if (libObj.contains("extract")) + { + out->applyExcludes = true; + auto extractObj = ensureObject(libObj.value("extract")); + for (auto excludeVal : ensureArray(extractObj.value("exclude"))) + { + out->excludes.append(ensureString(excludeVal)); + } + } + if (libObj.contains("natives")) + { + out->applyNatives = true; + QJsonObject nativesObj = ensureObject(libObj.value("natives")); + for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it) + { + if (!it.value().isString()) + { + QLOG_WARN() << filename << "contains an invalid native (skipping)"; + } + OpSys opSys = OpSys_fromString(it.key()); + if (opSys != Os_Other) + { + out->natives.append(qMakePair(opSys, it.value().toString())); + } + } + } + if (libObj.contains("rules")) + { + out->applyRules = true; + out->rules = rulesFromJsonV4(libObj); + } + return out; +} diff --git a/logic/minecraft/RawLibrary.h b/logic/minecraft/RawLibrary.h new file mode 100644 index 00000000..46178d8e --- /dev/null +++ b/logic/minecraft/RawLibrary.h @@ -0,0 +1,47 @@ +#pragma once +#include <QString> +#include <QPair> +#include <memory> + +#include "OneSixRule.h" + +class RawLibrary; +typedef std::shared_ptr<RawLibrary> RawLibraryPtr; + +class RawLibrary +{ +public: /* methods */ + static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename); + +public: /* data */ + QString name; + QString url; + QString hint; + QString absoluteUrl; + + bool applyExcludes = false; + QStringList excludes; + + bool applyNatives = false; + QList<QPair<OpSys, QString>> natives; + + bool applyRules = false; + QList<std::shared_ptr<Rule>> rules; + + // user for '+' libraries + enum InsertType + { + Apply, + Append, + Prepend, + Replace + } insertType = Append; + QString insertData; + + // soft or hard dependency? hard means 'needs equal', soft means 'needs equal or newer' + enum DependType + { + Soft, + Hard + } dependType = Soft; +}; diff --git a/logic/minecraft/OneSixVersionBuilder.cpp b/logic/minecraft/VersionBuilder.cpp index da8f956c..56eef424 100644 --- a/logic/minecraft/OneSixVersionBuilder.cpp +++ b/logic/minecraft/VersionBuilder.cpp @@ -25,7 +25,7 @@ #include <QDebug> #include <modutils.h> -#include "logic/minecraft/OneSixVersionBuilder.h" +#include "logic/minecraft/VersionBuilder.h" #include "logic/minecraft/VersionFinal.h" #include "logic/minecraft/OneSixRule.h" #include "logic/minecraft/VersionFile.h" @@ -35,28 +35,28 @@ #include "logger/QsLog.h" -OneSixVersionBuilder::OneSixVersionBuilder() +VersionBuilder::VersionBuilder() { } -void OneSixVersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const QStringList &external) +void VersionBuilder::build(VersionFinal *version, OneSixInstance *instance, const QStringList &external) { - OneSixVersionBuilder builder; + VersionBuilder builder; builder.m_version = version; builder.m_instance = instance; builder.buildInternal(external); } -void OneSixVersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, +void VersionBuilder::readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj) { - OneSixVersionBuilder builder; + VersionBuilder builder; builder.m_version = version; builder.m_instance = 0; builder.readJsonAndApply(obj); } -void OneSixVersionBuilder::buildInternal(const QStringList &external) +void VersionBuilder::buildInternal(const QStringList &external) { m_version->versionFiles.clear(); @@ -139,7 +139,7 @@ void OneSixVersionBuilder::buildInternal(const QStringList &external) -void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) +void VersionBuilder::readJsonAndApply(const QJsonObject &obj) { m_version->clear(); @@ -153,7 +153,7 @@ void OneSixVersionBuilder::readJsonAndApply(const QJsonObject &obj) // version of MultiMC")); } -VersionFilePtr OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, +VersionFilePtr VersionBuilder::parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder, bool isFTB) { QFile file(fileInfo.absoluteFilePath()); @@ -175,7 +175,7 @@ VersionFilePtr OneSixVersionBuilder::parseJsonFile(const QFileInfo &fileInfo, // info.").arg(file.fileName()); } -QMap<QString, int> OneSixVersionBuilder::readOverrideOrders(OneSixInstance *instance) +QMap<QString, int> VersionBuilder::readOverrideOrders(OneSixInstance *instance) { QMap<QString, int> out; @@ -225,7 +225,7 @@ QMap<QString, int> OneSixVersionBuilder::readOverrideOrders(OneSixInstance *inst return out; } -bool OneSixVersionBuilder::writeOverrideOrders(const QMap<QString, int> &order, +bool VersionBuilder::writeOverrideOrders(const QMap<QString, int> &order, OneSixInstance *instance) { QJsonObject obj; diff --git a/logic/minecraft/OneSixVersionBuilder.h b/logic/minecraft/VersionBuilder.h index 6646584e..ac93ef11 100644 --- a/logic/minecraft/OneSixVersionBuilder.h +++ b/logic/minecraft/VersionBuilder.h @@ -24,9 +24,9 @@ class OneSixInstance; class QJsonObject; class QFileInfo; -class OneSixVersionBuilder +class VersionBuilder { - OneSixVersionBuilder(); + VersionBuilder(); public: static void build(VersionFinal *version, OneSixInstance *instance, const QStringList &external); static void readJsonAndApplyToVersion(VersionFinal *version, const QJsonObject &obj); diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp index a011ce1a..e1b03e6c 100644 --- a/logic/minecraft/VersionFile.cpp +++ b/logic/minecraft/VersionFile.cpp @@ -7,111 +7,28 @@ #include "logic/minecraft/VersionFile.h" #include "logic/minecraft/OneSixLibrary.h" #include "logic/minecraft/VersionFinal.h" -#include "logic/MMCJson.h" +#include "logic/minecraft/JarMod.h" +#include "logic/MMCJson.h" using namespace MMCJson; #define CURRENT_MINIMUM_LAUNCHER_VERSION 14 -JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename) -{ - JarmodPtr out(new Jarmod()); - if (!libObj.contains("name")) - { - throw JSONValidationError(filename + - "contains a jarmod that doesn't have a 'name' field"); - } - out->name = libObj.value("name").toString(); - - auto readString = [libObj, filename](const QString & key, QString & variable) - { - if (libObj.contains(key)) - { - QJsonValue val = libObj.value(key); - if (!val.isString()) - { - QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; - } - else - { - variable = val.toString(); - } - } - }; - - readString("url", out->baseurl); - readString("MMC-absoluteUrl", out->absoluteUrl); - if(!out->baseurl.isEmpty() && out->absoluteUrl.isEmpty()) - { - out->absoluteUrl = out->baseurl + out->name; - } - return out; - -} - - -RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename) +int findLibrary(QList<OneSixLibraryPtr> haystack, const QString &needle) { - RawLibraryPtr out(new RawLibrary()); - if (!libObj.contains("name")) - { - throw JSONValidationError(filename + - "contains a library that doesn't have a 'name' field"); - } - out->name = libObj.value("name").toString(); - - auto readString = [libObj, filename](const QString & key, QString & variable) - { - if (libObj.contains(key)) - { - QJsonValue val = libObj.value(key); - if (!val.isString()) - { - QLOG_WARN() << key << "is not a string in" << filename << "(skipping)"; - } - else - { - variable = val.toString(); - } - } - }; - - readString("url", out->url); - readString("MMC-hint", out->hint); - readString("MMC-absulute_url", out->absoluteUrl); - readString("MMC-absoluteUrl", out->absoluteUrl); - if (libObj.contains("extract")) - { - out->applyExcludes = true; - auto extractObj = ensureObject(libObj.value("extract")); - for (auto excludeVal : ensureArray(extractObj.value("exclude"))) - { - out->excludes.append(ensureString(excludeVal)); - } - } - if (libObj.contains("natives")) + int retval = -1; + for (int i = 0; i < haystack.size(); ++i) { - out->applyNatives = true; - QJsonObject nativesObj = ensureObject(libObj.value("natives")); - for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it) + QString chunk = haystack.at(i)->rawName(); + if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix).indexIn(chunk) != -1) { - if (!it.value().isString()) - { - QLOG_WARN() << filename << "contains an invalid native (skipping)"; - } - OpSys opSys = OpSys_fromString(it.key()); - if (opSys != Os_Other) - { - out->natives.append(qMakePair(opSys, it.value().toString())); - } + // only one is allowed. + if(retval != -1) + return -1; + retval = i; } } - if (libObj.contains("rules")) - { - out->applyRules = true; - out->rules = rulesFromJsonV4(libObj); - } - return out; + return retval; } VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, @@ -351,23 +268,6 @@ OneSixLibraryPtr VersionFile::createLibrary(RawLibraryPtr lib) return out; } -int VersionFile::findLibrary(QList<OneSixLibraryPtr> haystack, const QString &needle) -{ - int retval = -1; - for (int i = 0; i < haystack.size(); ++i) - { - QString chunk = haystack.at(i)->rawName(); - if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix).indexIn(chunk) != -1) - { - // only one is allowed. - if(retval != -1) - return -1; - retval = i; - } - } - return retval; -} - bool VersionFile::isVanilla() { return fileId == "org.multimc.version.json"; diff --git a/logic/minecraft/VersionFile.h b/logic/minecraft/VersionFile.h index 8234445b..82b16913 100644 --- a/logic/minecraft/VersionFile.h +++ b/logic/minecraft/VersionFile.h @@ -5,10 +5,14 @@ #include <memory> #include "logic/minecraft/OpSys.h" #include "logic/minecraft/OneSixRule.h" +#include "VersionPatch.h" #include "MMCError.h" +#include "RawLibrary.h" +#include "JarMod.h" class VersionFinal; + class VersionBuildError : public MMCError { public: @@ -46,66 +50,19 @@ public: virtual ~MinecraftVersionMismatch() noexcept {} }; -struct RawLibrary; -typedef std::shared_ptr<RawLibrary> RawLibraryPtr; -struct RawLibrary -{ - QString name; - QString url; - QString hint; - QString absoluteUrl; - bool applyExcludes = false; - QStringList excludes; - bool applyNatives = false; - QList<QPair<OpSys, QString>> natives; - bool applyRules = false; - QList<std::shared_ptr<Rule>> rules; - - // user for '+' libraries - enum InsertType - { - Apply, - Append, - Prepend, - Replace - }; - InsertType insertType = Append; - QString insertData; - enum DependType - { - Soft, - Hard - }; - DependType dependType = Soft; - - static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename); -}; - -struct Jarmod; -typedef std::shared_ptr<Jarmod> JarmodPtr; -struct Jarmod -{ - QString name; - QString baseurl; - QString hint; - QString absoluteUrl; - - static JarmodPtr fromJson(const QJsonObject &libObj, const QString &filename); -}; - struct VersionFile; typedef std::shared_ptr<VersionFile> VersionFilePtr; -struct VersionFile +class VersionFile : public VersionPatch { public: /* methods */ static VersionFilePtr fromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder, const bool isFTB = false); static OneSixLibraryPtr createLibrary(RawLibraryPtr lib); - int findLibrary(QList<OneSixLibraryPtr> haystack, const QString &needle); - void applyTo(VersionFinal *version); - bool isVanilla(); - bool hasJarMods(); + virtual void applyTo(VersionFinal *version) override; + virtual bool isVanilla() override; + virtual bool hasJarMods() override; + public: /* data */ int order = 0; QString name; @@ -143,3 +100,5 @@ public: /* data */ QList<JarmodPtr> jarMods; }; + + diff --git a/logic/minecraft/VersionFinal.cpp b/logic/minecraft/VersionFinal.cpp index fbf6a160..07f58778 100644 --- a/logic/minecraft/VersionFinal.cpp +++ b/logic/minecraft/VersionFinal.cpp @@ -19,7 +19,7 @@ #include <pathutils.h> #include "logic/minecraft/VersionFinal.h" -#include "logic/minecraft/OneSixVersionBuilder.h" +#include "logic/minecraft/VersionBuilder.h" #include "logic/OneSixInstance.h" VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent) @@ -31,7 +31,7 @@ VersionFinal::VersionFinal(OneSixInstance *instance, QObject *parent) void VersionFinal::reload(const QStringList &external) { beginResetModel(); - OneSixVersionBuilder::build(this, m_instance, external); + VersionBuilder::build(this, m_instance, external); reapply(true); endResetModel(); } @@ -116,7 +116,7 @@ QString VersionFinal::versionFileId(const int index) const return versionFiles.at(index)->fileId; } -VersionFilePtr VersionFinal::versionFile(const QString &id) +VersionFilePtr VersionFinal::versionPatch(const QString &id) { for (auto file : versionFiles) { @@ -135,7 +135,7 @@ bool VersionFinal::hasJarMods() bool VersionFinal::hasFtbPack() { - return versionFile("org.multimc.ftb.pack.json") != nullptr; + return versionPatch("org.multimc.ftb.pack.json") != nullptr; } bool VersionFinal::removeFtbPack() @@ -216,7 +216,7 @@ std::shared_ptr<VersionFinal> VersionFinal::fromJson(const QJsonObject &obj) std::shared_ptr<VersionFinal> version(new VersionFinal(0)); try { - OneSixVersionBuilder::readJsonAndApplyToVersion(version.get(), obj); + VersionBuilder::readJsonAndApplyToVersion(version.get(), obj); } catch(MMCError & err) { @@ -299,7 +299,7 @@ QMap<QString, int> VersionFinal::getExistingOrder() const } // overriden { - QMap<QString, int> overridenOrder = OneSixVersionBuilder::readOverrideOrders(m_instance); + QMap<QString, int> overridenOrder = VersionBuilder::readOverrideOrders(m_instance); for (auto id : order.keys()) { if (overridenOrder.contains(id)) @@ -348,7 +348,7 @@ void VersionFinal::move(const int index, const MoveDirection direction) order[ourId] = theirIndex; order[theirId] = index; - if (!OneSixVersionBuilder::writeOverrideOrders(order, m_instance)) + if (!VersionBuilder::writeOverrideOrders(order, m_instance)) { throw MMCError(tr("Couldn't save the new order")); } @@ -378,7 +378,7 @@ void VersionFinal::reapply(const bool alreadyReseting) QList<VersionFilePtr> newVersionFiles; for (auto order : orders) { - auto file = versionFile(existingOrders.key(order)); + auto file = versionPatch(existingOrders.key(order)); newVersionFiles.append(file); file->applyTo(this); } diff --git a/logic/minecraft/VersionFinal.h b/logic/minecraft/VersionFinal.h index ceb90f57..7be981ed 100644 --- a/logic/minecraft/VersionFinal.h +++ b/logic/minecraft/VersionFinal.h @@ -23,6 +23,7 @@ #include "OneSixLibrary.h" #include "VersionFile.h" +#include "JarMod.h" class OneSixInstance; @@ -164,7 +165,7 @@ public: // QList<Rule> rules; QList<VersionFilePtr> versionFiles; - VersionFilePtr versionFile(const QString &id); + VersionFilePtr versionPatch(const QString &id); private: OneSixInstance *m_instance; diff --git a/logic/minecraft/VersionPatch.h b/logic/minecraft/VersionPatch.h new file mode 100644 index 00000000..c2258787 --- /dev/null +++ b/logic/minecraft/VersionPatch.h @@ -0,0 +1,15 @@ +#pragma once + +#include <memory> + +class VersionFinal; +class VersionPatch +{ +public: + virtual ~VersionPatch(){}; + virtual void applyTo(VersionFinal *version) = 0; + virtual bool isVanilla() = 0; + virtual bool hasJarMods() = 0; +}; + +typedef std::shared_ptr<VersionPatch> VersionPatchPtr; |