diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-04-01 00:07:37 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-04-30 23:59:03 +0200 |
commit | 5ae3b2c11416eb897a08b0d9531843d0357332f8 (patch) | |
tree | a5850f8e58ccb2db55c4a992677770126139429e /logic/minecraft | |
parent | 4392abfb8d3b45fb6c5cabe9d5e30c9416a5ad90 (diff) | |
download | MultiMC-5ae3b2c11416eb897a08b0d9531843d0357332f8.tar MultiMC-5ae3b2c11416eb897a08b0d9531843d0357332f8.tar.gz MultiMC-5ae3b2c11416eb897a08b0d9531843d0357332f8.tar.lz MultiMC-5ae3b2c11416eb897a08b0d9531843d0357332f8.tar.xz MultiMC-5ae3b2c11416eb897a08b0d9531843d0357332f8.zip |
NOISSUE nuke builtin Minecraft versions
Use upstream Mojang versions.
Diffstat (limited to 'logic/minecraft')
-rw-r--r-- | logic/minecraft/MinecraftVersion.cpp | 39 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersion.h | 21 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.cpp | 70 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.h | 3 | ||||
-rw-r--r-- | logic/minecraft/ProfilePatch.h | 1 |
5 files changed, 22 insertions, 112 deletions
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp index 3167fc4a..1e1d273c 100644 --- a/logic/minecraft/MinecraftVersion.cpp +++ b/logic/minecraft/MinecraftVersion.cpp @@ -3,20 +3,22 @@ #include "VersionBuildError.h" #include "ProfileUtils.h" #include "settings/SettingsObject.h" +#include "minecraft/VersionFilterData.h" bool MinecraftVersion::usesLegacyLauncher() { - return m_traits.contains("legacyLaunch") || m_traits.contains("aplhaLaunch"); + return getReleaseDateTime() < g_VersionFilterData.legacyCutoffDate; } + QString MinecraftVersion::descriptor() { - return m_descriptor; + return m_version; } QString MinecraftVersion::name() { - return m_name; + return m_version; } QString MinecraftVersion::typeString() const @@ -66,7 +68,7 @@ void MinecraftVersion::applyFileTo(MinecraftProfile *profile) } else { - throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_name)); + throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_version)); } } @@ -75,7 +77,7 @@ QString MinecraftVersion::getUrl() const // legacy fallback if(m_versionFileURL.isEmpty()) { - return QString("http://") + URLConstants::AWS_DOWNLOAD_VERSIONS + m_descriptor + "/" + m_descriptor + ".json"; + return QString("http://") + URLConstants::AWS_DOWNLOAD_VERSIONS + m_version + "/" + m_version + ".json"; } // current return m_versionFileURL; @@ -83,9 +85,8 @@ QString MinecraftVersion::getUrl() const VersionFilePtr MinecraftVersion::getVersionFile() { - QFileInfo versionFile(QString("versions/%1/%1.dat").arg(m_descriptor)); + QFileInfo versionFile(QString("versions/%1/%1.dat").arg(m_version)); m_problems.clear(); - m_problemSeverity = PROBLEM_NONE; if(!versionFile.exists()) { if(m_loadedVersionFile) @@ -124,8 +125,6 @@ bool MinecraftVersion::isCustomizable() case Remote: // locally cached file, or a remote file that we can acquire can be customized return true; - case Builtin: - // builtins do not follow the normal OneSix format. They are not customizable. default: // Everything else is undefined and therefore not customizable. return false; @@ -135,7 +134,7 @@ bool MinecraftVersion::isCustomizable() const QList<PatchProblem> &MinecraftVersion::getProblems() { - if(m_versionSource != Builtin && getVersionFile()) + if(getVersionFile()) { return getVersionFile()->getProblems(); } @@ -144,7 +143,7 @@ const QList<PatchProblem> &MinecraftVersion::getProblems() ProblemSeverity MinecraftVersion::getProblemSeverity() { - if(m_versionSource != Builtin && getVersionFile()) + if(getVersionFile()) { return getVersionFile()->getProblemSeverity(); } @@ -159,19 +158,7 @@ void MinecraftVersion::applyTo(MinecraftProfile *profile) applyFileTo(profile); return; } - // if not builtin, do not proceed any further. - if (m_versionSource != Builtin) - { - throw VersionIncomplete(QObject::tr( - "Minecraft version %1 could not be applied: version files are missing.").arg(m_descriptor)); - } - profile->applyMinecraftVersion(m_descriptor); - profile->applyMainClass(m_mainClass); - profile->applyAppletClass(m_appletClass); - profile->applyMinecraftArguments(" ${auth_player_name} ${auth_session}"); // all builtin versions are legacy - profile->applyMinecraftVersionType(m_type); - profile->applyTraits(m_traits); - profile->applyProblemSeverity(m_problemSeverity); + throw VersionIncomplete(QObject::tr("Minecraft version %1 could not be applied: version files are missing.").arg(m_version)); } int MinecraftVersion::getOrder() @@ -195,7 +182,7 @@ QString MinecraftVersion::getName() } QString MinecraftVersion::getVersion() { - return m_descriptor; + return m_version; } QString MinecraftVersion::getID() { @@ -224,5 +211,5 @@ bool MinecraftVersion::hasUpdate() bool MinecraftVersion::isCustom() { // if we add any other source types, this will evaluate to false for them. - return m_versionSource != Builtin && m_versionSource != Local && m_versionSource != Remote; + return m_versionSource != Local && m_versionSource != Remote; } diff --git a/logic/minecraft/MinecraftVersion.h b/logic/minecraft/MinecraftVersion.h index 1539ffd8..b21427d9 100644 --- a/logic/minecraft/MinecraftVersion.h +++ b/logic/minecraft/MinecraftVersion.h @@ -34,7 +34,9 @@ class MULTIMC_LOGIC_EXPORT MinecraftVersion : public BaseVersion, public Profile friend class MinecraftVersionList; public: /* methods */ + // FIXME: nuke this. bool usesLegacyLauncher(); + virtual QString descriptor() override; virtual QString name() override; virtual QString typeString() const override; @@ -89,25 +91,13 @@ private: /* methods */ void applyFileTo(MinecraftProfile *profile); protected: /* data */ - VersionSource m_versionSource = Builtin; + VersionSource m_versionSource = Remote; /// The URL that this version will be downloaded from. QString m_versionFileURL; /// the human readable version name - QString m_name; - - /// the version ID. - QString m_descriptor; - - /// version traits. added by MultiMC - QSet<QString> m_traits; - - /// The main class this version uses (if any, can be empty). - QString m_mainClass; - - /// The applet class this version uses (if any, can be empty). - QString m_appletClass; + QString m_version; /// The type of this release QString m_type; @@ -118,9 +108,6 @@ protected: /* data */ /// the time this version was last updated by Mojang QDateTime m_updateTime; - /// MD5 hash of the minecraft jar - QString m_jarChecksum; - /// order of this file... default = -2 int order = -2; diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp index bd679c73..eab55c9a 100644 --- a/logic/minecraft/MinecraftVersionList.cpp +++ b/logic/minecraft/MinecraftVersionList.cpp @@ -83,7 +83,6 @@ public: MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent) { - loadBuiltinList(); loadCachedList(); } @@ -141,7 +140,7 @@ void MinecraftVersionList::loadCachedList() { throw ListLoadError(tr("Error reading the version list.")); } - loadMojangList(jsonDoc, Local); + loadList(jsonDoc, Local); } catch (Exception &e) { @@ -153,57 +152,7 @@ void MinecraftVersionList::loadCachedList() m_hasLocalIndex = true; } -void MinecraftVersionList::loadBuiltinList() -{ - qDebug() << "Loading builtin version list."; - // grab the version list data from internal resources. - const QJsonDocument doc = - Json::requireDocument(QString(":/versions/minecraft.json"), "builtin version list"); - const QJsonObject root = doc.object(); - - // parse all the versions - for (const auto version : Json::requireArray(root.value("versions"))) - { - QJsonObject versionObj = version.toObject(); - QString versionID = versionObj.value("id").toString(""); - QString versionTypeStr = versionObj.value("type").toString(""); - if (versionID.isEmpty() || versionTypeStr.isEmpty()) - { - qCritical() << "Parsed version is missing ID or type"; - continue; - } - - if (g_VersionFilterData.legacyBlacklist.contains(versionID)) - { - qWarning() << "Blacklisted legacy version ignored: " << versionID; - continue; - } - - // Now, we construct the version object and add it to the list. - std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion()); - mcVersion->m_name = mcVersion->m_descriptor = versionID; - - // Parse the timestamp. - mcVersion->m_releaseTime = timeFromS3Time(versionObj.value("releaseTime").toString("")); - mcVersion->m_versionFileURL = QString(); - mcVersion->m_versionSource = Builtin; - mcVersion->m_type = versionTypeStr; - mcVersion->m_appletClass = versionObj.value("appletClass").toString(""); - mcVersion->m_mainClass = versionObj.value("mainClass").toString(""); - mcVersion->m_jarChecksum = versionObj.value("checksum").toString(""); - if (versionObj.contains("+traits")) - { - for (auto traitVal : Json::requireArray(versionObj.value("+traits"))) - { - mcVersion->m_traits.insert(Json::requireString(traitVal)); - } - } - m_lookup[versionID] = mcVersion; - m_vlist.append(mcVersion); - } -} - -void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource source) +void MinecraftVersionList::loadList(QJsonDocument jsonDoc, VersionSource source) { qDebug() << "Loading" << ((source == Remote) ? "remote" : "local") << "version list."; @@ -260,16 +209,11 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s // Now, we construct the version object and add it to the list. std::shared_ptr<MinecraftVersion> mcVersion(new MinecraftVersion()); - mcVersion->m_name = mcVersion->m_descriptor = versionID; + mcVersion->m_version = versionID; mcVersion->m_releaseTime = timeFromS3Time(versionObj.value("releaseTime").toString("")); mcVersion->m_updateTime = timeFromS3Time(versionObj.value("time").toString("")); - if (mcVersion->m_releaseTime < g_VersionFilterData.legacyCutoffDate) - { - continue; - } - // depends on where we load the version from -- network request or local file? mcVersion->m_versionSource = source; mcVersion->m_versionFileURL = versionObj.value("url").toString(""); @@ -444,7 +388,7 @@ void MCVListLoadTask::list_downloaded() throw ListLoadError( tr("Error parsing version list JSON: %1").arg(jsonError.errorString())); } - m_list->loadMojangList(jsonDoc, Remote); + m_list->loadList(jsonDoc, Remote); } catch (Exception &e) { @@ -502,8 +446,6 @@ void MCVListVersionUpdateTask::json_downloaded() // Strip LWJGL from the version file. We use our own. ProfileUtils::removeLwjglFromPatch(file); - // TODO: recognize and add LWJGL versions here. - file->fileId = "net.minecraft"; // now dump the file to disk @@ -627,10 +569,6 @@ void MinecraftVersionList::finalizeUpdate(QString version) auto updatedVersion = std::dynamic_pointer_cast<MinecraftVersion>(m_vlist[idx]); - // reject any updates to builtin versions. - if (updatedVersion->m_versionSource == Builtin) - return; - // if we have an update for the version, replace it, make the update local if (updatedVersion->upstreamUpdate) { diff --git a/logic/minecraft/MinecraftVersionList.h b/logic/minecraft/MinecraftVersionList.h index e414a1da..8643f0f0 100644 --- a/logic/minecraft/MinecraftVersionList.h +++ b/logic/minecraft/MinecraftVersionList.h @@ -34,8 +34,7 @@ class MULTIMC_LOGIC_EXPORT MinecraftVersionList : public BaseVersionList Q_OBJECT private: void sortInternal(); - void loadBuiltinList(); - void loadMojangList(QJsonDocument jsonDoc, VersionSource source); + void loadList(QJsonDocument jsonDoc, VersionSource source); void loadCachedList(); void saveCachedList(); void finalizeUpdate(QString version); diff --git a/logic/minecraft/ProfilePatch.h b/logic/minecraft/ProfilePatch.h index fa2f0a0f..f0c65360 100644 --- a/logic/minecraft/ProfilePatch.h +++ b/logic/minecraft/ProfilePatch.h @@ -18,7 +18,6 @@ enum ProblemSeverity /// where is a version from? enum VersionSource { - Builtin, //!< version loaded from the internal resources. Local, //!< version loaded from a file in the cache. Remote, //!< incomplete version on a remote server. }; |