diff options
| author | Petr Mrázek <peterix@gmail.com> | 2016-03-26 16:56:57 +0100 |
|---|---|---|
| committer | Petr Mrázek <peterix@gmail.com> | 2016-03-27 22:35:06 +0200 |
| commit | f032e32133023ed8396fc2b6ead7eadc2816a25b (patch) | |
| tree | 10ce52261bf06dd9f000896b4e993fb45cd7e3fc /logic/minecraft | |
| parent | d587720010036e3335e321f192449808a75e958b (diff) | |
| download | PrismLauncher-f032e32133023ed8396fc2b6ead7eadc2816a25b.tar.gz PrismLauncher-f032e32133023ed8396fc2b6ead7eadc2816a25b.tar.bz2 PrismLauncher-f032e32133023ed8396fc2b6ead7eadc2816a25b.zip | |
NOISSUE finalize support for new mojang version format
Diffstat (limited to 'logic/minecraft')
25 files changed, 348 insertions, 508 deletions
diff --git a/logic/minecraft/Library.cpp b/logic/minecraft/Library.cpp index 9a1d2cc7..922db84e 100644 --- a/logic/minecraft/Library.cpp +++ b/logic/minecraft/Library.cpp @@ -1,57 +1,176 @@ #include "Library.h" +#include <net/CacheDownload.h> +#include <minecraft/forge/ForgeXzDownload.h> +#include <Env.h> #include <FileSystem.h> -QStringList Library::files() const +void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32, QStringList& native64) const { - QStringList retval; - QString storage = storageSuffix(); - if (storage.contains("${arch}")) + auto actualPath = [&](QString relPath) { - QString cooked_storage = storage; - cooked_storage.replace("${arch}", "32"); - retval.append(cooked_storage); - cooked_storage = storage; - cooked_storage.replace("${arch}", "64"); - retval.append(cooked_storage); + QFileInfo out(FS::PathCombine(storagePrefix(), relPath)); + return out.absoluteFilePath(); + }; + if(m_mojangDownloads) + { + if(m_mojangDownloads->artifact) + { + auto artifact = m_mojangDownloads->artifact; + jar += actualPath(artifact->path); + } + if(!isNative()) + return; + if(m_nativeClassifiers.contains(system)) + { + auto nativeClassifier = m_nativeClassifiers[system]; + if(nativeClassifier.contains("${arch}")) + { + auto nat32Classifier = nativeClassifier; + nat32Classifier.replace("${arch}", "32"); + auto nat64Classifier = nativeClassifier; + nat64Classifier.replace("${arch}", "64"); + auto nat32info = m_mojangDownloads->getDownloadInfo(nat32Classifier); + if(nat32info) + native32 += actualPath(nat32info->path); + auto nat64info = m_mojangDownloads->getDownloadInfo(nat64Classifier); + if(nat64info) + native64 += actualPath(nat64info->path); + } + else + { + native += actualPath(m_mojangDownloads->getDownloadInfo(nativeClassifier)->path); + } + } } else - retval.append(storage); - return retval; -} - -bool Library::filesExist(const QDir &base) const -{ - auto libFiles = files(); - for(auto file: libFiles) { - QFileInfo info(base, file); - qWarning() << info.absoluteFilePath() << "doesn't exist"; - if (!info.exists()) - return false; + QString raw_storage = storageSuffix(system); + if(isNative()) + { + if (raw_storage.contains("${arch}")) + { + auto nat32Storage = raw_storage; + nat32Storage.replace("${arch}", "32"); + auto nat64Storage = raw_storage; + nat64Storage.replace("${arch}", "64"); + native32 += actualPath(nat32Storage); + native64 += actualPath(nat64Storage); + } + else + { + native += actualPath(raw_storage); + } + } + else + { + jar += actualPath(raw_storage); + } } - return true; } -QString Library::url() const +QList<NetActionPtr> Library::getDownloads(OpSys system, HttpMetaCache * cache, QStringList &failedFiles) const { - if (!m_absolute_url.isEmpty()) - { - return m_absolute_url; - } + QList<NetActionPtr> out; + bool isLocal = (hint() == "local"); + bool isForge = (hint() == "forge-pack-xz"); - if (m_base_url.isEmpty()) + auto add_download = [&](QString storage, QString dl) { - return QString("https://" + URLConstants::LIBRARY_BASE) + storageSuffix(); - } + auto entry = cache->resolveEntry("libraries", storage); + if (!entry->isStale()) + return true; + if(isLocal) + { + QFileInfo fileinfo(entry->getFullPath()); + if(!fileinfo.exists()) + { + failedFiles.append(entry->getFullPath()); + return false; + } + return true; + } + if (isForge) + { + out.append(ForgeXzDownload::make(storage, entry)); + } + else + { + out.append(CacheDownload::make(dl, entry)); + } + return true; + }; - if(m_base_url.endsWith('/')) + if(m_mojangDownloads) { - return m_base_url + storageSuffix(); + if(m_mojangDownloads->artifact) + { + auto artifact = m_mojangDownloads->artifact; + add_download(artifact->path, artifact->url); + } + if(m_nativeClassifiers.contains(system)) + { + auto nativeClassifier = m_nativeClassifiers[system]; + if(nativeClassifier.contains("${arch}")) + { + auto nat32Classifier = nativeClassifier; + nat32Classifier.replace("${arch}", "32"); + auto nat64Classifier = nativeClassifier; + nat64Classifier.replace("${arch}", "64"); + auto nat32info = m_mojangDownloads->getDownloadInfo(nat32Classifier); + if(nat32info) + add_download(nat32info->path, nat32info->url); + auto nat64info = m_mojangDownloads->getDownloadInfo(nat64Classifier); + if(nat64info) + add_download(nat64info->path, nat64info->url); + } + else + { + auto info = m_mojangDownloads->getDownloadInfo(nativeClassifier); + if(info) + { + add_download(info->path, info->url); + } + } + } } else { - return m_base_url + QChar('/') + storageSuffix(); + QString raw_storage = storageSuffix(system); + auto raw_dl = [&](){ + if (!m_absoluteURL.isEmpty()) + { + return m_absoluteURL; + } + + if (m_repositoryURL.isEmpty()) + { + return QString("https://" + URLConstants::LIBRARY_BASE) + raw_storage; + } + + if(m_repositoryURL.endsWith('/')) + { + return m_repositoryURL + raw_storage; + } + else + { + return m_repositoryURL + QChar('/') + raw_storage; + } + }(); + if (raw_storage.contains("${arch}")) + { + QString cooked_storage = raw_storage; + QString cooked_dl = raw_dl; + add_download(cooked_storage.replace("${arch}", "32"), cooked_dl.replace("${arch}", "32")); + cooked_storage = raw_storage; + cooked_dl = raw_dl; + add_download(cooked_storage.replace("${arch}", "64"), cooked_dl.replace("${arch}", "64")); + } + else + { + add_download(raw_storage, raw_dl); + } } + return out; } bool Library::isActive() const @@ -74,7 +193,7 @@ bool Library::isActive() const } if (isNative()) { - result = result && m_native_classifiers.contains(currentSystem); + result = result && m_nativeClassifiers.contains(currentSystem); } return result; } @@ -98,7 +217,7 @@ QString Library::storagePrefix() const return m_storagePrefix; } -QString Library::storageSuffix() const +QString Library::storageSuffix(OpSys system) const { // non-native? use only the gradle specifier if (!isNative()) @@ -108,9 +227,9 @@ QString Library::storageSuffix() const // otherwise native, override classifiers. Mojang HACK! GradleSpecifier nativeSpec = m_name; - if (m_native_classifiers.contains(currentSystem)) + if (m_nativeClassifiers.contains(system)) { - nativeSpec.setClassifier(m_native_classifiers[currentSystem]); + nativeSpec.setClassifier(m_nativeClassifiers[system]); } else { @@ -118,13 +237,3 @@ QString Library::storageSuffix() const } return nativeSpec.toPath(); } - -QString Library::storagePath() const -{ - return FS::PathCombine(storagePrefix(), storageSuffix()); -} - -bool Library::storagePathIsDefault() const -{ - return m_storagePrefix.isEmpty(); -} diff --git a/logic/minecraft/Library.h b/logic/minecraft/Library.h index 35b5cb99..fdce93f3 100644 --- a/logic/minecraft/Library.h +++ b/logic/minecraft/Library.h @@ -1,5 +1,6 @@ #pragma once #include <QString> +#include <net/NetAction.h> #include <QPair> #include <QList> #include <QStringList> @@ -12,16 +13,19 @@ #include "minecraft/OpSys.h" #include "GradleSpecifier.h" #include "net/URLConstants.h" +#include "MojangDownloadInfo.h" + +#include "multimc_logic_export.h" -struct MojangLibraryDownloadInfo; class Library; typedef std::shared_ptr<Library> LibraryPtr; -class Library +class MULTIMC_LOGIC_EXPORT Library { friend class OneSixVersionFormat; friend class MojangVersionFormat; + friend class LibraryTest; public: Library() { @@ -35,13 +39,14 @@ public: { auto newlib = std::make_shared<Library>(); newlib->m_name = base->m_name; - newlib->m_base_url = base->m_base_url; + newlib->m_repositoryURL = base->m_repositoryURL; newlib->m_hint = base->m_hint; - newlib->m_absolute_url = base->m_absolute_url; - newlib->extract_excludes = base->extract_excludes; - newlib->m_native_classifiers = base->m_native_classifiers; + newlib->m_absoluteURL = base->m_absoluteURL; + newlib->m_extractExcludes = base->m_extractExcludes; + newlib->m_nativeClassifiers = base->m_nativeClassifiers; newlib->m_rules = base->m_rules; newlib->m_storagePrefix = base->m_storagePrefix; + newlib->m_mojangDownloads = base->m_mojangDownloads; return newlib; } @@ -83,45 +88,27 @@ public: /* methods */ /// Returns true if the library is native bool isNative() const { - return m_native_classifiers.size() != 0; + return m_nativeClassifiers.size() != 0; } void setStoragePrefix(QString prefix = QString()); - /// the default storage prefix used by MultiMC - static QString defaultStoragePrefix(); - - bool storagePathIsDefault() const; - - /// Get the prefix - root of the storage to be used - QString storagePrefix() const; - - /// Get the relative path where the library should be saved - QString storageSuffix() const; - - /// Get the absolute path where the library should be saved - QString storagePath() const; - /// Set the url base for downloads - void setBaseUrl(const QString &base_url) + void setRepositoryURL(const QString &base_url) { - m_base_url = base_url; + m_repositoryURL = base_url; } - /// List of files this library describes. Required because of platform-specificness of native libs - QStringList files() const; - - /// List Shortcut for checking if all the above files exist - bool filesExist(const QDir &base) const; + void getApplicableFiles(OpSys system, QStringList & jar, QStringList & native, QStringList & native32, QStringList & native64) const; void setAbsoluteUrl(const QString &absolute_url) { - m_absolute_url = absolute_url; + m_absoluteURL = absolute_url; } - QString absoluteUrl() const + void setMojangDownloadInfo(MojangLibraryDownloadInfo::Ptr info) { - return m_absolute_url; + m_mojangDownloads = info; } void setHint(const QString &hint) @@ -129,11 +116,6 @@ public: /* methods */ m_hint = hint; } - QString hint() const - { - return m_hint; - } - /// Set the load rules void setRules(QList<std::shared_ptr<Rule>> rules) { @@ -143,22 +125,33 @@ public: /* methods */ /// Returns true if the library should be loaded (or extracted, in case of natives) bool isActive() const; - /// Get the URL to download the library from - QString url() const; + // Get a list of downloads for this library + QList<NetActionPtr> getDownloads(OpSys system, class HttpMetaCache * cache, QStringList &failedFiles) const; + +private: /* methods */ + /// the default storage prefix used by MultiMC + static QString defaultStoragePrefix(); + + /// Get the prefix - root of the storage to be used + QString storagePrefix() const; + + /// Get the relative path where the library should be saved + QString storageSuffix(OpSys system) const; + + QString hint() const + { + return m_hint; + } protected: /* data */ /// the basic gradle dependency specifier. GradleSpecifier m_name; - /// where to store the lib locally - QString m_storage_path; - /// is this lib actually active on the current OS? - bool m_is_active = false; /// DEPRECATED URL prefix of the maven repo where the file can be downloaded - QString m_base_url; + QString m_repositoryURL; /// DEPRECATED: MultiMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined - QString m_absolute_url; + QString m_absoluteURL; /** * MultiMC-specific type hint - modifies how the library is treated @@ -172,13 +165,13 @@ protected: /* data */ QString m_storagePrefix; /// true if the library had an extract/excludes section (even empty) - bool applyExcludes = false; + bool m_hasExcludes = false; /// a list of files that shouldn't be extracted from the library - QStringList extract_excludes; + QStringList m_extractExcludes; /// native suffixes per OS - QMap<OpSys, QString> m_native_classifiers; + QMap<OpSys, QString> m_nativeClassifiers; /// true if the library had a rules section (even empty) bool applyRules = false; @@ -187,5 +180,5 @@ protected: /* data */ QList<std::shared_ptr<Rule>> m_rules; /// MOJANG: container with Mojang style download info - std::shared_ptr<MojangLibraryDownloadInfo> m_mojang_downloads; + MojangLibraryDownloadInfo::Ptr m_mojangDownloads; }; diff --git a/logic/minecraft/MinecraftProfile.cpp b/logic/minecraft/MinecraftProfile.cpp index 71ece012..70d0cee4 100644 --- a/logic/minecraft/MinecraftProfile.cpp +++ b/logic/minecraft/MinecraftProfile.cpp @@ -14,6 +14,7 @@ */ #include <QFile> +#include <QCryptographicHash> #include <Version.h> #include <QDir> #include <QJsonDocument> @@ -68,9 +69,9 @@ void MinecraftProfile::clear() m_mainClass.clear(); m_appletClass.clear(); m_libraries.clear(); - m_nativeLibraries.clear(); m_traits.clear(); m_jarMods.clear(); + mojangDownloads.clear(); m_problemSeverity = ProblemSeverity::PROBLEM_NONE; } @@ -428,6 +429,18 @@ void MinecraftProfile::applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets) } } +void MinecraftProfile::applyMojangDownload(const QString &key, MojangDownloadInfo::Ptr download) +{ + if(download) + { + mojangDownloads[key] = download; + } + else + { + mojangDownloads.remove(key); + } +} + void MinecraftProfile::applyTraits(const QSet<QString>& traits) { this->m_traits.unite(traits); @@ -466,35 +479,24 @@ static int findLibraryByName(QList<LibraryPtr> haystack, const GradleSpecifier & void MinecraftProfile::applyLibrary(LibraryPtr library) { - auto insert = [&](QList<LibraryPtr> & into) - { - // find the library by name. - const int index = findLibraryByName(into, library->rawName()); - // library not found? just add it. - if (index < 0) - { - into.append(Library::limitedCopy(library)); - return; - } - auto existingLibrary = into.at(index); - // if we are higher it means we should update - if (Version(library->version()) > Version(existingLibrary->version())) - { - auto libraryCopy = Library::limitedCopy(library); - into.replace(index, libraryCopy); - } - }; if(!library->isActive()) { return; } - if(library->isNative()) + // find the library by name. + const int index = findLibraryByName(m_libraries, library->rawName()); + // library not found? just add it. + if (index < 0) { - insert(m_nativeLibraries); + m_libraries.append(Library::limitedCopy(library)); + return; } - else + auto existingLibrary = m_libraries.at(index); + // if we are higher it means we should update + if (Version(library->version()) > Version(existingLibrary->version())) { - insert(m_libraries); + auto libraryCopy = Library::limitedCopy(library); + m_libraries.replace(index, libraryCopy); } } @@ -571,12 +573,21 @@ const QList<LibraryPtr> & MinecraftProfile::getLibraries() const return m_libraries; } -const QList<LibraryPtr> & MinecraftProfile::getNativeLibraries() const +QString MinecraftProfile::getMainJarUrl() const { - return m_nativeLibraries; + auto iter = mojangDownloads.find("client"); + if(iter != mojangDownloads.end()) + { + // current + return iter.value()->url; + } + else + { + // legacy fallback + return URLConstants::getLegacyJarUrl(getMinecraftVersion()); + } } - void MinecraftProfile::installJarMods(QStringList selectedFiles) { m_strategy->installJarMods(selectedFiles); diff --git a/logic/minecraft/MinecraftProfile.h b/logic/minecraft/MinecraftProfile.h index ce0ff3cf..ca9288ad 100644 --- a/logic/minecraft/MinecraftProfile.h +++ b/logic/minecraft/MinecraftProfile.h @@ -97,6 +97,7 @@ public: /* application of profile variables from patches */ void applyJarMods(const QList<JarmodPtr> &jarMods); void applyLibrary(LibraryPtr library); void applyProblemSeverity(ProblemSeverity severity); + void applyMojangDownload(const QString & key, MojangDownloadInfo::Ptr download); public: /* getters for profile variables */ QString getMinecraftVersion() const; @@ -109,7 +110,7 @@ public: /* getters for profile variables */ const QStringList & getTweakers() const; const QList<JarmodPtr> & getJarMods() const; const QList<LibraryPtr> & getLibraries() const; - const QList<LibraryPtr> & getNativeLibraries() const; + QString getMainJarUrl() const; bool hasTrait(const QString & trait) const; ProblemSeverity getProblemSeverity() const; @@ -139,6 +140,9 @@ private: /* data */ /// Assets type - "legacy" or a version ID MojangAssetIndexInfo::Ptr m_minecraftAssets; + // Mojang: list of 'downloads' - client jar, server jar, windows server exe, maybe more. + QMap <QString, std::shared_ptr<MojangDownloadInfo>> mojangDownloads; + /** * arguments that should be used for launching minecraft * @@ -159,9 +163,6 @@ private: /* data */ /// the list of libraries QList<LibraryPtr> m_libraries; - /// the list of native libraries - QList<LibraryPtr> m_nativeLibraries; - /// traits, collected from all the version files (version files can only add) QSet<QString> m_traits; diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp index a3855481..3167fc4a 100644 --- a/logic/minecraft/MinecraftVersion.cpp +++ b/logic/minecraft/MinecraftVersion.cpp @@ -72,10 +72,12 @@ void MinecraftVersion::applyFileTo(MinecraftProfile *profile) QString MinecraftVersion::getUrl() const { + // legacy fallback if(m_versionFileURL.isEmpty()) { return QString("http://") + URLConstants::AWS_DOWNLOAD_VERSIONS + m_descriptor + "/" + m_descriptor + ".json"; } + // current return m_versionFileURL; } diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp index 62c588d1..bd679c73 100644 --- a/logic/minecraft/MinecraftVersionList.cpp +++ b/logic/minecraft/MinecraftVersionList.cpp @@ -470,8 +470,7 @@ void MCVListVersionUpdateTask::executeTask() specificVersionDownloadJob.reset(job); connect(specificVersionDownloadJob.get(), SIGNAL(succeeded()), SLOT(json_downloaded())); connect(specificVersionDownloadJob.get(), SIGNAL(failed(QString)), SIGNAL(failed(QString))); - connect(specificVersionDownloadJob.get(), SIGNAL(progress(qint64, qint64)), - SIGNAL(progress(qint64, qint64))); + connect(specificVersionDownloadJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); specificVersionDownloadJob->start(); } diff --git a/logic/minecraft/MojangDownloadInfo.h b/logic/minecraft/MojangDownloadInfo.h index d8cd2e6d..1f3306e0 100644 --- a/logic/minecraft/MojangDownloadInfo.h +++ b/logic/minecraft/MojangDownloadInfo.h @@ -1,5 +1,6 @@ #pragma once #include <QString> +#include <QMap> #include <memory> struct MojangDownloadInfo @@ -22,6 +23,9 @@ struct MojangDownloadInfo struct MojangLibraryDownloadInfo { + MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact): artifact(artifact) {}; + MojangLibraryDownloadInfo() {}; + // types typedef std::shared_ptr<MojangLibraryDownloadInfo> Ptr; diff --git a/logic/minecraft/MojangVersionFormat.cpp b/logic/minecraft/MojangVersionFormat.cpp index 41723493..34129c9e 100644 --- a/logic/minecraft/MojangVersionFormat.cpp +++ b/logic/minecraft/MojangVersionFormat.cpp @@ -8,7 +8,7 @@ using namespace Json; #include "ParseUtils.h" -static const int CURRENT_MINIMUM_LAUNCHER_VERSION = 14; +static const int CURRENT_MINIMUM_LAUNCHER_VERSION = 18; static MojangAssetIndexInfo::Ptr assetIndexFromJson (const QJsonObject &obj); static MojangDownloadInfo::Ptr downloadInfoFromJson (const QJsonObject &obj); @@ -130,7 +130,7 @@ QJsonObject assetIndexToJson(MojangAssetIndexInfo::Ptr info) void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFile *out) { - Bits::readString(in, "id", out->id); + Bits::readString(in, "id", out->minecraftVersion); Bits::readString(in, "mainClass", out->mainClass); Bits::readString(in, "minecraftArguments", out->minecraftArguments); if(out->minecraftArguments.isEmpty()) @@ -212,7 +212,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc out->name = "Minecraft"; out->fileId = "net.minecraft"; - out->version = out->id; + out->version = out->minecraftVersion; out->filename = filename; @@ -231,7 +231,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObject& out) { - writeString(out, "id", in->id); + writeString(out, "id", in->minecraftVersion); writeString(out, "mainClass", in->mainClass); writeString(out, "minecraftArguments", in->minecraftArguments); writeString(out, "type", in->type); @@ -294,14 +294,14 @@ LibraryPtr MojangVersionFormat::libraryFromJson(const QJsonObject &libObj, const } out->m_name = libObj.value("name").toString(); - Bits::readString(libObj, "url", out->m_base_url); + Bits::readString(libObj, "url", out->m_repositoryURL); if (libObj.contains("extract")) { - out->applyExcludes = true; + out->m_hasExcludes = true; auto extractObj = requireObject(libObj.value("extract")); for (auto excludeVal : requireArray(extractObj.value("exclude"))) { - out->extract_excludes.append(requireString(excludeVal)); + out->m_extractExcludes.append(requireString(excludeVal)); } } if (libObj.contains("natives")) @@ -316,7 +316,7 @@ LibraryPtr MojangVersionFormat::libraryFromJson(const QJsonObject &libObj, const OpSys opSys = OpSys_fromString(it.key()); if (opSys != Os_Other) { - out->m_native_classifiers[opSys] = it.value().toString(); + out->m_nativeClassifiers[opSys] = it.value().toString(); } } } @@ -327,7 +327,7 @@ LibraryPtr MojangVersionFormat::libraryFromJson(const QJsonObject &libObj, const } if (libObj.contains("downloads")) { - out->m_mojang_downloads = libDownloadInfoFromJson(libObj); + out->m_mojangDownloads = libDownloadInfoFromJson(libObj); } return out; } @@ -336,27 +336,25 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library) { QJsonObject libRoot; libRoot.insert("name", (QString)library->m_name); - if (library->m_base_url != "http://" + URLConstants::AWS_DOWNLOAD_LIBRARIES && - library->m_base_url != "https://" + URLConstants::AWS_DOWNLOAD_LIBRARIES && - library->m_base_url != "https://" + URLConstants::LIBRARY_BASE && !library->m_base_url.isEmpty()) + if (!library->m_repositoryURL.isEmpty()) { - libRoot.insert("url", library->m_base_url); + libRoot.insert("url", library->m_repositoryURL); } if (library->isNative()) { QJsonObject nativeList; - auto iter = library->m_native_classifiers.begin(); - while (iter != library->m_native_classifiers.end()) + auto iter = library->m_nativeClassifiers.begin(); + while (iter != library->m_nativeClassifiers.end()) { nativeList.insert(OpSys_toString(iter.key()), iter.value()); iter++; } libRoot.insert("natives", nativeList); - if (library->extract_excludes.size()) + if (library->m_extractExcludes.size()) { QJsonArray excludes; QJsonObject extract; - for (auto exclude : library->extract_excludes) + for (auto exclude : library->m_extractExcludes) { excludes.append(exclude); } @@ -374,9 +372,9 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library) } libRoot.insert("rules", allRules); } - if(library->m_mojang_downloads) + if(library->m_mojangDownloads) { - auto downloadsObj = libDownloadInfoToJson(library->m_mojang_downloads); + auto downloadsObj = libDownloadInfoToJson(library->m_mojangDownloads); libRoot.insert("downloads", downloadsObj); } return libRoot; diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp index 451c3c8b..573c4cb4 100644 --- a/logic/minecraft/VersionFile.cpp +++ b/logic/minecraft/VersionFile.cpp @@ -25,14 +25,14 @@ bool VersionFile::hasJarMods() void VersionFile::applyTo(MinecraftProfile *profile) { auto theirVersion = profile->getMinecraftVersion(); - if (!theirVersion.isNull() && !mcVersion.isNull()) + if (!theirVersion.isNull() && !dependsOnMinecraftVersion.isNull()) { - if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1) + if (QRegExp(dependsOnMinecraftVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1) { - throw MinecraftVersionMismatch(fileId, mcVersion, theirVersion); + throw MinecraftVersionMismatch(fileId, dependsOnMinecraftVersion, theirVersion); } } - profile->applyMinecraftVersion(id); + profile->applyMinecraftVersion(minecraftVersion); profile->applyMainClass(mainClass); profile->applyAppletClass(appletClass); profile->applyMinecraftArguments(minecraftArguments); @@ -51,4 +51,10 @@ void VersionFile::applyTo(MinecraftProfile *profile) profile->applyLibrary(library); } profile->applyProblemSeverity(getProblemSeverity()); + auto iter = mojangDownloads.begin(); + while(iter != mojangDownloads.end()) + { + profile->applyMojangDownload(iter.key(), iter.value()); + iter++; + } } diff --git a/logic/minecraft/VersionFile.h b/logic/minecraft/VersionFile.h index 7627cc96..1b692f0f 100644 --- a/logic/minecraft/VersionFile.h +++ b/logic/minecraft/VersionFile.h @@ -143,13 +143,13 @@ public: /* data */ QString version; /// MultiMC: dependency on a Minecraft version - QString mcVersion; + QString dependsOnMinecraftVersion; /// Mojang: used to version the Mojang version format int minimumLauncherVersion = -1; /// Mojang: version of Minecraft this is - QString id; + QString minecraftVersion; /// Mojang: class to launch Minecraft with QString mainClass; diff --git a/logic/minecraft/forge/ForgeInstaller.cpp b/logic/minecraft/forge/ForgeInstaller.cpp index 7957de0e..155a2cac 100644 --- a/logic/minecraft/forge/ForgeInstaller.cpp +++ b/logic/minecraft/forge/ForgeInstaller.cpp @@ -126,8 +126,8 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr QCryptographicHash md5sum(QCryptographicHash::Md5); md5sum.addData(data); - cacheentry->stale = false; - cacheentry->md5sum = md5sum.result().toHex().constData(); |
