diff options
-rw-r--r-- | logic/ftb/FTBProfileStrategy.cpp | 1 | ||||
-rw-r--r-- | logic/ftb/OneSixFTBInstance.cpp | 4 | ||||
-rw-r--r-- | logic/liteloader/LiteLoaderInstaller.cpp | 1 | ||||
-rw-r--r-- | logic/liteloader/LiteLoaderVersionList.cpp | 2 | ||||
-rw-r--r-- | logic/minecraft/OneSixLibrary.cpp | 1 | ||||
-rw-r--r-- | logic/minecraft/OneSixLibrary.h | 3 | ||||
-rw-r--r-- | logic/minecraft/RawLibrary.cpp | 76 | ||||
-rw-r--r-- | logic/minecraft/RawLibrary.h | 37 | ||||
-rw-r--r-- | logic/minecraft/VersionFile.cpp | 196 | ||||
-rw-r--r-- | logic/minecraft/VersionFile.h | 3 |
10 files changed, 36 insertions, 288 deletions
diff --git a/logic/ftb/FTBProfileStrategy.cpp b/logic/ftb/FTBProfileStrategy.cpp index 0876c707..53b43eec 100644 --- a/logic/ftb/FTBProfileStrategy.cpp +++ b/logic/ftb/FTBProfileStrategy.cpp @@ -60,7 +60,6 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches() for(auto addLib: file->addLibs) { addLib->m_hint = "local"; - addLib->insertType = RawLibrary::Prepend; addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath()); } file->fileId = "org.multimc.ftb.pack"; diff --git a/logic/ftb/OneSixFTBInstance.cpp b/logic/ftb/OneSixFTBInstance.cpp index 8d61997b..ebe421e0 100644 --- a/logic/ftb/OneSixFTBInstance.cpp +++ b/logic/ftb/OneSixFTBInstance.cpp @@ -87,9 +87,9 @@ void OneSixFTBInstance::copy(const QDir &newDir) { qCritical() << "Couldn't create folder structure for" << out; } - if (!QFile::copy(librariesPath().absoluteFilePath(lib->storageSuffix()), out)) + if (!QFile::copy(librariesPath().absoluteFilePath(lib.storageSuffix()), out)) { - qCritical() << "Couldn't copy" << lib->rawName(); + qCritical() << "Couldn't copy" << lib.rawName(); } } } diff --git a/logic/liteloader/LiteLoaderInstaller.cpp b/logic/liteloader/LiteLoaderInstaller.cpp index e255921f..28be614a 100644 --- a/logic/liteloader/LiteLoaderInstaller.cpp +++ b/logic/liteloader/LiteLoaderInstaller.cpp @@ -51,7 +51,6 @@ bool LiteLoaderInstaller::add(OneSixInstance *to) for (auto rawLibrary : m_version->libraries) { - rawLibrary->insertType = RawLibrary::Prepend; OneSixLibrary lib(rawLibrary); libraries.append(lib.toJson()); } diff --git a/logic/liteloader/LiteLoaderVersionList.cpp b/logic/liteloader/LiteLoaderVersionList.cpp index c1b43cb8..1d200e48 100644 --- a/logic/liteloader/LiteLoaderVersionList.cpp +++ b/logic/liteloader/LiteLoaderVersionList.cpp @@ -250,7 +250,7 @@ void LLListLoadTask::listDownloaded() // hack to make liteloader 1.7.10_00 work if(lib->rawName() == GradleSpecifier("org.ow2.asm:asm-all:5.0.3")) { - lib->m_base_url = "http://repo.maven.apache.org/maven2/"; + lib->setBaseUrl("http://repo.maven.apache.org/maven2/"); } version->libraries.append(lib); } diff --git a/logic/minecraft/OneSixLibrary.cpp b/logic/minecraft/OneSixLibrary.cpp index 1ebba507..fe94d817 100644 --- a/logic/minecraft/OneSixLibrary.cpp +++ b/logic/minecraft/OneSixLibrary.cpp @@ -28,7 +28,6 @@ OneSixLibrary::OneSixLibrary(RawLibraryPtr base) extract_excludes = base->extract_excludes; m_native_classifiers = base->m_native_classifiers; m_rules = base->m_rules; - dependType = base->dependType; m_storagePrefix = base->m_storagePrefix; // these only make sense for raw libraries. OneSix /* diff --git a/logic/minecraft/OneSixLibrary.h b/logic/minecraft/OneSixLibrary.h index 76e04c2c..e0ca52a8 100644 --- a/logic/minecraft/OneSixLibrary.h +++ b/logic/minecraft/OneSixLibrary.h @@ -40,10 +40,9 @@ class OneSixLibrary : public RawLibrary { public: /// Constructor - OneSixLibrary(const QString &name, const DependType type = Soft) + OneSixLibrary(const QString &name) { m_name = name; - dependType = type; } /// Constructor OneSixLibrary(RawLibraryPtr base); diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp index 9806a684..a10536ea 100644 --- a/logic/minecraft/RawLibrary.cpp +++ b/logic/minecraft/RawLibrary.cpp @@ -69,82 +69,6 @@ RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &fil return out; } -RawLibraryPtr RawLibrary::fromJsonPlus(const QJsonObject &libObj, const QString &filename) -{ - auto lib = RawLibrary::fromJson(libObj, filename); - if (libObj.contains("insert")) - { - QJsonValue insertVal = ensureJsonValue(libObj.value("insert"), QString("library insert rule")); - if (insertVal.isString()) - { - // it's just a simple string rule. OK. - QString insertString = insertVal.toString(); - if (insertString == "apply") - { - lib->insertType = RawLibrary::Apply; - } - else if (insertString == "prepend") - { - lib->insertType = RawLibrary::Prepend; - } - else if (insertString == "append") - { - lib->insertType = RawLibrary::Append; - } - else if (insertString == "replace") - { - lib->insertType = RawLibrary::Replace; - } - else - { - throw JSONValidationError("A '+' library in " + filename + - " contains an invalid insert type"); - } - } - else if (insertVal.isObject()) - { - // it's a more complex rule, specifying what should be: - // * replaced (for now only this) - // this was never used, AFAIK. tread carefully. - QJsonObject insertObj = insertVal.toObject(); - if (insertObj.isEmpty()) - { - throw JSONValidationError("Empty compound insert rule in " + filename); - } - QString insertString = insertObj.keys().first(); - // really, only replace makes sense in combination with - if(insertString != "replace") - { - throw JSONValidationError("Compound insert rule is not 'replace' in " + filename); - } - lib->insertData = insertObj.value(insertString).toString(); - } - else - { - throw JSONValidationError("A '+' library in " + filename + - " contains an unknown/invalid insert rule"); - } - } - if (libObj.contains("MMC-depend")) - { - const QString dependString = requireString(libObj.value("MMC-depend")); - if (dependString == "hard") - { - lib->dependType = RawLibrary::Hard; - } - else if (dependString == "soft") - { - lib->dependType = RawLibrary::Soft; - } - else - { - throw JSONValidationError("A '+' library in " + filename + - " contains an invalid depend type"); - } - } - return lib; -} - QJsonObject RawLibrary::toJson() const { QJsonObject libRoot; diff --git a/logic/minecraft/RawLibrary.h b/logic/minecraft/RawLibrary.h index e51cbf4c..efe51bc0 100644 --- a/logic/minecraft/RawLibrary.h +++ b/logic/minecraft/RawLibrary.h @@ -23,9 +23,6 @@ public: /* methods */ /// read and create a basic library static RawLibraryPtr fromJson(const QJsonObject &libObj, const QString &filename); - /// read and create a MultiMC '+' library. Those have some extra fields. - static RawLibraryPtr fromJsonPlus(const QJsonObject &libObj, const QString &filename); - /// Convert the library back to an JSON object QJsonObject toJson() const; @@ -137,19 +134,22 @@ protected: /* data */ /// is this lib actually active on the current OS? bool m_is_active = false; - -public: /* data */ - // TODO: make all of these protected, clean up semantics of implicit vs. explicit values. - /// URL where the file can be downloaded + /// DEPRECATED URL prefix of the maven repo where the file can be downloaded QString m_base_url; - /// DEPRECATED: absolute URL. takes precedence the normal download URL, if defined + /// DEPRECATED: MultiMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined QString m_absolute_url; - /// type hint - modifies how the library is treated +public: /* data */ + /** + * MultiMC-specific type hint - modifies how the library is treated + */ QString m_hint; - /// storage - by default the local libraries folder in multimc, but could be elsewhere + /** + * storage - by default the local libraries folder in multimc, but could be elsewhere + * MultiMC specific, because of FTB. + */ QString m_storagePrefix; /// true if the library had an extract/excludes section (even empty) @@ -166,21 +166,4 @@ public: /* data */ /// rules associated with the library QList<std::shared_ptr<Rule>> m_rules; - - /// used for '+' libraries, determines how to add them - enum InsertType - { - Apply, - Append, - Prepend, - Replace - } insertType = Append; - QString insertData; - - /// determines how can libraries be applied. conflicting dependencies cause errors. - enum DependType - { - Soft, //! needs equal or newer version - Hard //! needs equal version (different versions mean version conflict) - } dependType = Soft; }; diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp index fee83900..2bc08d20 100644 --- a/logic/minecraft/VersionFile.cpp +++ b/logic/minecraft/VersionFile.cpp @@ -150,7 +150,6 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi readString(root, "processArguments", out->processArguments); readString(root, "minecraftArguments", out->overwriteMinecraftArguments); readString(root, "+minecraftArguments", out->addMinecraftArguments); - readString(root, "-minecraftArguments", out->removeMinecraftArguments); readString(root, "type", out->type); parse_timestamp(readStringRet(root, "releaseTime"), out->m_releaseTimeString, out->m_releaseTime); @@ -181,13 +180,6 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi } } - if (root.contains("-tweakers")) - { - for (auto tweakerVal : requireArray(root.value("-tweakers"))) - { - out->removeTweakers.append(requireString(tweakerVal)); - } - } if (root.contains("+traits")) { @@ -233,18 +225,23 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi { QJsonObject libObj = requireObject(libVal); // parse the library - auto lib = RawLibrary::fromJsonPlus(libObj, filename); + auto lib = RawLibrary::fromJson(libObj, filename); out->addLibs.append(lib); } } + /* removed features that shouldn't be used */ if (root.contains("-libraries")) { - for (auto libVal : requireArray(root.value("-libraries"))) - { - auto libObj = requireObject(libVal); - out->removeLibs.append(requireString(libObj.value("name"))); - } + out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-libraries'")); + } + if (root.contains("-tweakers")) + { + out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-tweakers'")); + } + if (root.contains("-minecraftArguments")) + { + out->addProblem(PROBLEM_ERROR, QObject::tr("Version file contains unsupported element '-minecraftArguments'")); } return out; } @@ -266,7 +263,6 @@ QJsonDocument VersionFile::toJson(bool saveOrder) writeString(root, "processArguments", processArguments); writeString(root, "minecraftArguments", overwriteMinecraftArguments); writeString(root, "+minecraftArguments", addMinecraftArguments); - writeString(root, "-minecraftArguments", removeMinecraftArguments); writeString(root, "type", type); writeString(root, "assets", assets); if (isMinecraftVersion()) @@ -280,23 +276,10 @@ QJsonDocument VersionFile::toJson(bool saveOrder) } writeStringList(root, "tweakers", overwriteTweakers); writeStringList(root, "+tweakers", addTweakers); - writeStringList(root, "-tweakers", removeTweakers); writeStringList(root, "+traits", traits.toList()); writeObjectList(root, "libraries", overwriteLibs); writeObjectList(root, "+libraries", addLibs); writeObjectList(root, "+jarMods", jarMods); - // FIXME: removed libs are special snowflakes. - if (removeLibs.size()) - { - QJsonArray array; - for (auto lib : removeLibs) - { - QJsonObject rmlibobj; - rmlibobj.insert("name", lib); - array.append(rmlibobj); - } - root.insert("-libraries", array); - } // write the contents to a json document. { QJsonDocument out; @@ -384,10 +367,6 @@ void VersionFile::applyTo(MinecraftProfile *version) { version->minecraftArguments += addMinecraftArguments; } - if (!removeMinecraftArguments.isNull()) - { - version->minecraftArguments.remove(removeMinecraftArguments); - } if (shouldOverwriteTweakers) { version->tweakers = overwriteTweakers; @@ -396,10 +375,6 @@ void VersionFile::applyTo(MinecraftProfile *version) { version->tweakers += tweaker; } - for (auto tweaker : removeTweakers) - { - version->tweakers.removeAll(tweaker); - } version->jarMods.append(jarMods); version->traits.unite(traits); if (shouldOverwriteLibs) @@ -417,147 +392,20 @@ void VersionFile::applyTo(MinecraftProfile *version) } for (auto addedLibrary : addLibs) { - switch (addedLibrary->insertType) - { - case RawLibrary::Apply: - { - // qDebug() << "Applying lib " << lib->name; - int index = findLibraryByName(version->libraries, addedLibrary->rawName()); - if (index >= 0) - { - auto existingLibrary = version->libraries[index]; - if (!addedLibrary->m_base_url.isEmpty()) - { - existingLibrary->setBaseUrl(addedLibrary->m_base_url); - } - if (!addedLibrary->m_hint.isNull()) - { - existingLibrary->setHint(addedLibrary->m_hint); - } - if (!addedLibrary->m_absolute_url.isNull()) - { - existingLibrary->setAbsoluteUrl(addedLibrary->m_absolute_url); - } - if (addedLibrary->applyExcludes) - { - existingLibrary->extract_excludes = addedLibrary->extract_excludes; - } - if (addedLibrary->isNative()) - { - existingLibrary->m_native_classifiers = addedLibrary->m_native_classifiers; - } - if (addedLibrary->applyRules) - { - existingLibrary->setRules(addedLibrary->m_rules); - } - } - else - { - qWarning() << "Couldn't find" << addedLibrary->rawName() << "(skipping)"; - } - break; - } - case RawLibrary::Append: - case RawLibrary::Prepend: - { - // find the library by name. - const int index = findLibraryByName(version->libraries, addedLibrary->rawName()); - // library not found? just add it. - if (index < 0) - { - if (addedLibrary->insertType == RawLibrary::Append) - { - version->libraries.append(OneSixLibrary::fromRawLibrary(addedLibrary)); - } - else - { - version->libraries.prepend(OneSixLibrary::fromRawLibrary(addedLibrary)); - } - break; - } - - // otherwise apply differences, if allowed - auto existingLibrary = version->libraries.at(index); - const Version addedVersion(addedLibrary->version()); - const Version existingVersion(existingLibrary->version()); - // if the existing version is a hard dependency we can either use it or - // fail, but we can't change it - if (existingLibrary->dependType == OneSixLibrary::Hard) - { - // we need a higher version, or we're hard to and the versions aren't - // equal - if (addedVersion > existingVersion || - (addedLibrary->dependType == RawLibrary::Hard && addedVersion != existingVersion)) - { - throw VersionBuildError(QObject::tr( - "Error resolving library dependencies between %1 and %2 in %3.") - .arg(existingLibrary->rawName(), - addedLibrary->rawName(), filename)); - } - else - { - // the library is already existing, so we don't have to do anything - } - } - else if (existingLibrary->dependType == OneSixLibrary::Soft) - { - // if we are higher it means we should update - if (addedVersion > existingVersion) - { - auto library = OneSixLibrary::fromRawLibrary(addedLibrary); - version->libraries.replace(index, library); - } - else - { - // our version is smaller than the existing version, but we require - // it: fail - if (addedLibrary->dependType == RawLibrary::Hard) - { - throw VersionBuildError(QObject::tr( - "Error resolving library dependencies between %1 and %2 in %3.") - .arg(existingLibrary->rawName(), - addedLibrary->rawName(), filename)); - } - } - } - break; - } - case RawLibrary::Replace: - { - GradleSpecifier toReplace; - if (addedLibrary->insertData.isEmpty()) - { - toReplace = addedLibrary->rawName(); - } - else - { - toReplace = addedLibrary->insertData; - } - // qDebug() << "Replacing lib " << toReplace << " with " << lib->name; - int index = findLibraryByName(version->libraries, toReplace); - if (index >= 0) - { - version->libraries.replace(index, OneSixLibrary::fromRawLibrary(addedLibrary)); - } - else - { - qWarning() << "Couldn't find" << toReplace << "(skipping)"; - } - break; - } - } - } - for (auto lib : removeLibs) - { - int index = findLibraryByName(version->libraries, lib); - if (index >= 0) + // find the library by name. + const int index = findLibraryByName(version->libraries, addedLibrary->rawName()); + // library not found? just add it. + if (index < 0) { - // qDebug() << "Removing lib " << lib; - version->libraries.removeAt(index); + version->libraries.append(OneSixLibrary::fromRawLibrary(addedLibrary)); + continue; } - else + auto existingLibrary = version->libraries.at(index); + // if we are higher it means we should update + if (Version(addedLibrary->version()) > Version(existingLibrary->version())) { - qWarning() << "Couldn't find" << lib << "(skipping)"; + auto library = OneSixLibrary::fromRawLibrary(addedLibrary); + version->libraries.replace(index, library); } } } diff --git a/logic/minecraft/VersionFile.h b/logic/minecraft/VersionFile.h index 5df1cd29..ab94348b 100644 --- a/logic/minecraft/VersionFile.h +++ b/logic/minecraft/VersionFile.h @@ -126,7 +126,6 @@ public: /* data */ QString appletClass; QString overwriteMinecraftArguments; QString addMinecraftArguments; - QString removeMinecraftArguments; QString processArguments; QString type; @@ -145,12 +144,10 @@ public: /* data */ bool shouldOverwriteTweakers = false; QStringList overwriteTweakers; QStringList addTweakers; - QStringList removeTweakers; bool shouldOverwriteLibs = false; QList<RawLibraryPtr> overwriteLibs; QList<RawLibraryPtr> addLibs; - QList<QString> removeLibs; QSet<QString> traits; |