diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-03-03 01:23:10 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-03-03 01:23:10 +0100 |
commit | 29cdc9364b0153d04a211adf3eab86076174c0a1 (patch) | |
tree | 9bb741e8c2291a31f0d210303550fec08df2cdd8 /logic/VersionFile.cpp | |
parent | 28ad9befdcac246eb69a434be970abc29a80bc80 (diff) | |
download | MultiMC-29cdc9364b0153d04a211adf3eab86076174c0a1.tar MultiMC-29cdc9364b0153d04a211adf3eab86076174c0a1.tar.gz MultiMC-29cdc9364b0153d04a211adf3eab86076174c0a1.tar.lz MultiMC-29cdc9364b0153d04a211adf3eab86076174c0a1.tar.xz MultiMC-29cdc9364b0153d04a211adf3eab86076174c0a1.zip |
More code butchery related to version files. No end in sight.
Diffstat (limited to 'logic/VersionFile.cpp')
-rw-r--r-- | logic/VersionFile.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/logic/VersionFile.cpp b/logic/VersionFile.cpp index 4423e733..b7695907 100644 --- a/logic/VersionFile.cpp +++ b/logic/VersionFile.cpp @@ -13,10 +13,10 @@ using namespace MMCJson; #define CURRENT_MINIMUM_LAUNCHER_VERSION 14 -VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, +RawLibrary RawLibrary::fromJson(const QJsonObject &libObj, const QString &filename) { - Library out; + RawLibrary out; if (!libObj.contains("name")) { throw JSONValidationError(filename + @@ -78,7 +78,8 @@ VersionFile::Library VersionFile::Library::fromJson(const QJsonObject &libObj, return out; } -VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder, const bool isFTB) +VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filename, + const bool requireOrder, const bool isFTB) { VersionFile out; if (doc.isEmpty() || doc.isNull()) @@ -173,12 +174,12 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen { auto libObj = ensureObject(libVal); - Library lib = Library::fromJson(libObj, filename); + RawLibrary lib = RawLibrary::fromJson(libObj, filename); // FIXME: This should be done when applying. if (isFTB) { lib.hint = "local"; - lib.insertType = Library::Prepend; + lib.insertType = RawLibrary::Prepend; out.addLibs.prepend(lib); } else @@ -196,7 +197,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen QJsonValue insertVal = ensureExists(libObj.value("insert")); // parse the library - Library lib = Library::fromJson(libObj, filename); + RawLibrary lib = RawLibrary::fromJson(libObj, filename); // TODO: utility functions for handling this case. templates? QString insertString; @@ -219,19 +220,19 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen } if (insertString == "apply") { - lib.insertType = Library::Apply; + lib.insertType = RawLibrary::Apply; } else if (insertString == "prepend") { - lib.insertType = Library::Prepend; + lib.insertType = RawLibrary::Prepend; } else if (insertString == "append") { - lib.insertType = Library::Prepend; + lib.insertType = RawLibrary::Prepend; } else if (insertString == "replace") { - lib.insertType = Library::Replace; + lib.insertType = RawLibrary::Replace; } else { @@ -243,11 +244,11 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen const QString dependString = ensureString(libObj.value("MMC-depend")); if (dependString == "hard") { - lib.dependType = Library::Hard; + lib.dependType = RawLibrary::Hard; } else if (dependString == "soft") { - lib.dependType = Library::Soft; + lib.dependType = RawLibrary::Soft; } else { @@ -269,7 +270,7 @@ VersionFile VersionFile::fromJson(const QJsonDocument &doc, const QString &filen return out; } -std::shared_ptr<OneSixLibrary> VersionFile::createLibrary(const VersionFile::Library &lib) +std::shared_ptr<OneSixLibrary> VersionFile::createLibrary(const RawLibrary &lib) { std::shared_ptr<OneSixLibrary> out(new OneSixLibrary(lib.name)); if (!lib.url.isEmpty()) @@ -396,7 +397,7 @@ void VersionFile::applyTo(VersionFinal *version) { switch (lib.insertType) { - case Library::Apply: + case RawLibrary::Apply: { int index = findLibrary(version->libraries, lib.name); @@ -439,8 +440,8 @@ void VersionFile::applyTo(VersionFinal *version) } break; } - case Library::Append: - case Library::Prepend: + case RawLibrary::Append: + case RawLibrary::Prepend: { const int startOfVersion = lib.name.lastIndexOf(':') + 1; @@ -448,7 +449,7 @@ void VersionFile::applyTo(VersionFinal *version) version->libraries, QString(lib.name).replace(startOfVersion, INT_MAX, '*')); if (index < 0) { - if (lib.insertType == Library::Append) + if (lib.insertType == RawLibrary::Append) { version->libraries.append(createLibrary(lib)); } @@ -469,7 +470,7 @@ void VersionFile::applyTo(VersionFinal *version) // we need a higher version, or we're hard to and the versions aren't // equal if (ourVersion > otherVersion || - (lib.dependType == Library::Hard && ourVersion != otherVersion)) + (lib.dependType == RawLibrary::Hard && ourVersion != otherVersion)) { throw VersionBuildError( QString( @@ -497,7 +498,7 @@ void VersionFile::applyTo(VersionFinal *version) { // our version is smaller than the existing version, but we require // it: fail - if (lib.dependType == Library::Hard) + if (lib.dependType == RawLibrary::Hard) { throw VersionBuildError(QString( "Error resolving library dependencies between %1 and %2 in %3.") @@ -509,7 +510,7 @@ void VersionFile::applyTo(VersionFinal *version) } break; } - case Library::Replace: + case RawLibrary::Replace: { int index = findLibrary(version->libraries, lib.insertData); if (index >= 0) |