From 8cbe13c6560c3abe8ef73b8a376bd84dea281cf4 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 6 Mar 2017 00:39:25 +0100 Subject: NOISSUE remove legacy version blacklist --- api/logic/minecraft/MinecraftVersionList.cpp | 12 ------------ api/logic/minecraft/VersionFilterData.cpp | 2 -- api/logic/minecraft/VersionFilterData.h | 2 -- 3 files changed, 16 deletions(-) (limited to 'api/logic/minecraft') diff --git a/api/logic/minecraft/MinecraftVersionList.cpp b/api/logic/minecraft/MinecraftVersionList.cpp index 2c9a8035..29fa840e 100644 --- a/api/logic/minecraft/MinecraftVersionList.cpp +++ b/api/logic/minecraft/MinecraftVersionList.cpp @@ -179,12 +179,6 @@ void MinecraftVersionList::loadBuiltinList() 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 mcVersion(new MinecraftVersion()); mcVersion->m_name = mcVersion->m_descriptor = versionID; @@ -258,12 +252,6 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s 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 mcVersion(new MinecraftVersion()); mcVersion->m_name = mcVersion->m_descriptor = versionID; diff --git a/api/logic/minecraft/VersionFilterData.cpp b/api/logic/minecraft/VersionFilterData.cpp index 0c4a6e3d..60c64473 100644 --- a/api/logic/minecraft/VersionFilterData.cpp +++ b/api/logic/minecraft/VersionFilterData.cpp @@ -58,8 +58,6 @@ VersionFilterData::VersionFilterData() // don't use installers for those. forgeInstallerBlacklist = QSet({"1.5.2"}); - // these won't show up in version lists because they are extremely bad and dangerous - legacyBlacklist = QSet({"rd-160052"}); /* * nothing older than this will be accepted from Mojang servers * (these versions need to be tested by us first) diff --git a/api/logic/minecraft/VersionFilterData.h b/api/logic/minecraft/VersionFilterData.h index f7d4ebe7..f4213e1a 100644 --- a/api/logic/minecraft/VersionFilterData.h +++ b/api/logic/minecraft/VersionFilterData.h @@ -20,8 +20,6 @@ struct VersionFilterData QMap> fmlLibsMapping; // set of minecraft versions for which using forge installers is blacklisted QSet forgeInstallerBlacklist; - // set of 'legacy' versions that will not show up in the version lists. - QSet legacyBlacklist; // no new versions below this date will be accepted from Mojang servers QDateTime legacyCutoffDate; // Libraries that belong to LWJGL -- cgit From 7382360771f78e351740393262358bed3297d44c Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 6 Mar 2017 01:00:44 +0100 Subject: NOISSUE remove builtin Minecraft versions --- api/logic/minecraft/MinecraftVersionList.cpp | 51 ---------------------------- api/logic/minecraft/MinecraftVersionList.h | 1 - api/logic/minecraft/VersionFilterData.cpp | 9 ++--- api/logic/minecraft/VersionFilterData.h | 2 -- 4 files changed, 2 insertions(+), 61 deletions(-) (limited to 'api/logic/minecraft') diff --git a/api/logic/minecraft/MinecraftVersionList.cpp b/api/logic/minecraft/MinecraftVersionList.cpp index 29fa840e..0dc46289 100644 --- a/api/logic/minecraft/MinecraftVersionList.cpp +++ b/api/logic/minecraft/MinecraftVersionList.cpp @@ -26,7 +26,6 @@ #include "ParseUtils.h" #include "ProfileUtils.h" -#include "VersionFilterData.h" #include "onesix/OneSixVersionFormat.h" #include "MojangVersionFormat.h" #include @@ -89,7 +88,6 @@ public: MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent) { - loadBuiltinList(); loadCachedList(); } @@ -159,50 +157,6 @@ 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; - } - - // Now, we construct the version object and add it to the list. - std::shared_ptr 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 = 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) { qDebug() << "Loading" << ((source == VersionSource::Remote) ? "remote" : "local") << "version list."; @@ -259,11 +213,6 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s 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(""); diff --git a/api/logic/minecraft/MinecraftVersionList.h b/api/logic/minecraft/MinecraftVersionList.h index 42333678..fc421966 100644 --- a/api/logic/minecraft/MinecraftVersionList.h +++ b/api/logic/minecraft/MinecraftVersionList.h @@ -34,7 +34,6 @@ class MULTIMC_LOGIC_EXPORT MinecraftVersionList : public BaseVersionList Q_OBJECT private: void sortInternal(); - void loadBuiltinList(); void loadMojangList(QJsonDocument jsonDoc, VersionSource source); void loadCachedList(); void saveCachedList(); diff --git a/api/logic/minecraft/VersionFilterData.cpp b/api/logic/minecraft/VersionFilterData.cpp index 60c64473..5f4ceee6 100644 --- a/api/logic/minecraft/VersionFilterData.cpp +++ b/api/logic/minecraft/VersionFilterData.cpp @@ -58,16 +58,11 @@ VersionFilterData::VersionFilterData() // don't use installers for those. forgeInstallerBlacklist = QSet({"1.5.2"}); - /* - * nothing older than this will be accepted from Mojang servers - * (these versions need to be tested by us first) - */ + + // FIXME: remove, used for deciding when core mods should display legacyCutoffDate = timeFromS3Time("2013-06-25T15:08:56+02:00"); lwjglWhitelist = QSet{"net.java.jinput:jinput", "net.java.jinput:jinput-platform", "net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl", "org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"}; - - // Version list magic - recommendedMinecraftVersion = "1.7.10"; } diff --git a/api/logic/minecraft/VersionFilterData.h b/api/logic/minecraft/VersionFilterData.h index f4213e1a..2408e704 100644 --- a/api/logic/minecraft/VersionFilterData.h +++ b/api/logic/minecraft/VersionFilterData.h @@ -24,7 +24,5 @@ struct VersionFilterData QDateTime legacyCutoffDate; // Libraries that belong to LWJGL QSet lwjglWhitelist; - // Currently recommended minecraft version - QString recommendedMinecraftVersion; }; extern VersionFilterData MULTIMC_LOGIC_EXPORT g_VersionFilterData; -- cgit From 2980322c3b34b252ead838daee7a844853feccf6 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 12 Mar 2017 19:45:28 +0100 Subject: NOISSUE Remove Minecraft version list and versions. --- api/logic/minecraft/MinecraftInstance.cpp | 3 +- api/logic/minecraft/MinecraftVersion.cpp | 230 -------- api/logic/minecraft/MinecraftVersion.h | 132 ----- api/logic/minecraft/MinecraftVersionList.cpp | 614 --------------------- api/logic/minecraft/MinecraftVersionList.h | 72 --- api/logic/minecraft/MojangVersionFormat.cpp | 1 - api/logic/minecraft/forge/ForgeInstaller.cpp | 9 +- api/logic/minecraft/ftb/FTBInstanceProvider.cpp | 14 +- api/logic/minecraft/ftb/FTBPlugin.cpp | 2 - api/logic/minecraft/ftb/FTBProfileStrategy.cpp | 1 - api/logic/minecraft/ftb/FTBVersion.h | 32 -- api/logic/minecraft/legacy/LegacyUpdate.cpp | 1 - .../minecraft/onesix/OneSixProfileStrategy.cpp | 3 +- api/logic/minecraft/onesix/OneSixUpdate.cpp | 3 +- api/logic/minecraft/onesix/OneSixVersionFormat.cpp | 1 - 15 files changed, 16 insertions(+), 1102 deletions(-) delete mode 100644 api/logic/minecraft/MinecraftVersion.cpp delete mode 100644 api/logic/minecraft/MinecraftVersion.h delete mode 100644 api/logic/minecraft/MinecraftVersionList.cpp delete mode 100644 api/logic/minecraft/MinecraftVersionList.h delete mode 100644 api/logic/minecraft/ftb/FTBVersion.h (limited to 'api/logic/minecraft') diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index 7b1aef1e..b88d0c2a 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -5,7 +5,6 @@ #include #include "settings/SettingsObject.h" #include "Env.h" -#include "minecraft/MinecraftVersionList.h" #include #include #include @@ -24,6 +23,8 @@ #include +#include + #define IBUS "@im=ibus" // all of this because keeping things compatible with deprecated old settings diff --git a/api/logic/minecraft/MinecraftVersion.cpp b/api/logic/minecraft/MinecraftVersion.cpp deleted file mode 100644 index 248c7eed..00000000 --- a/api/logic/minecraft/MinecraftVersion.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "MinecraftVersion.h" -#include "MinecraftProfile.h" -#include "VersionBuildError.h" -#include "ProfileUtils.h" -#include "settings/SettingsObject.h" - -bool MinecraftVersion::usesLegacyLauncher() -{ - return m_traits.contains("legacyLaunch") || m_traits.contains("aplhaLaunch"); -} - -QString MinecraftVersion::descriptor() -{ - return m_descriptor; -} - -QString MinecraftVersion::name() -{ - return m_name; -} - -QString MinecraftVersion::typeString() const -{ - if(m_type == "snapshot") - { - return QObject::tr("Snapshot"); - } - else if (m_type == "release") - { - return QObject::tr("Regular release"); - } - else if (m_type == "old_alpha") - { - return QObject::tr("Alpha"); - } - else if (m_type == "old_beta") - { - return QObject::tr("Beta"); - } - else - { - return QString(); - } -} - -VersionSource MinecraftVersion::getVersionSource() -{ - return m_versionSource; -} - -bool MinecraftVersion::hasJarMods() -{ - return false; -} - -bool MinecraftVersion::isMinecraftVersion() -{ - return true; -} - -void MinecraftVersion::applyFileTo(MinecraftProfile *profile) -{ - if(m_versionSource == VersionSource::Local && getVersionFile()) - { - getVersionFile()->applyTo(profile); - } - else - { - throw VersionIncomplete(QObject::tr("Can't apply incomplete/builtin Minecraft version %1").arg(m_name)); - } -} - -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; -} - -VersionFilePtr MinecraftVersion::getVersionFile() -{ - QFileInfo versionFile(QString("versions/%1/%1.dat").arg(m_descriptor)); - m_problems.clear(); - m_problemSeverity = PROBLEM_NONE; - if(!versionFile.exists()) - { - if(m_loadedVersionFile) - { - m_loadedVersionFile.reset(); - } - addProblem(PROBLEM_WARNING, QObject::tr("The patch file doesn't exist locally. It's possible it just needs to be downloaded.")); - } - else - { - try - { - if(versionFile.lastModified() != m_loadedVersionFileTimestamp) - { - auto loadedVersionFile = ProfileUtils::parseBinaryJsonFile(versionFile); - loadedVersionFile->name = "Minecraft"; - loadedVersionFile->setCustomizable(true); - m_loadedVersionFileTimestamp = versionFile.lastModified(); - m_loadedVersionFile = loadedVersionFile; - } - } - catch(Exception e) - { - m_loadedVersionFile.reset(); - addProblem(PROBLEM_ERROR, QObject::tr("The patch file couldn't be read:\n%1").arg(e.cause())); - } - } - return m_loadedVersionFile; -} - -bool MinecraftVersion::isCustomizable() -{ - switch(m_versionSource) - { - case VersionSource::Local: - case VersionSource::Remote: - // locally cached file, or a remote file that we can acquire can be customized - return true; - case VersionSource::Builtin: - // builtins do not follow the normal OneSix format. They are not customizable. - default: - // Everything else is undefined and therefore not customizable. - return false; - } - return false; -} - -const QList &MinecraftVersion::getProblems() -{ - if(m_versionSource != VersionSource::Builtin && getVersionFile()) - { - return getVersionFile()->getProblems(); - } - return ProfilePatch::getProblems(); -} - -ProblemSeverity MinecraftVersion::getProblemSeverity() -{ - if(m_versionSource != VersionSource::Builtin && getVersionFile()) - { - return getVersionFile()->getProblemSeverity(); - } - return ProfilePatch::getProblemSeverity(); -} - -void MinecraftVersion::applyTo(MinecraftProfile *profile) -{ - // do we have this one cached? - if (m_versionSource == VersionSource::Local) - { - applyFileTo(profile); - return; - } - // if not builtin, do not proceed any further. - if (m_versionSource != 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); -} - -int MinecraftVersion::getOrder() -{ - return order; -} - -void MinecraftVersion::setOrder(int order) -{ - this->order = order; -} - -QList MinecraftVersion::getJarMods() -{ - return QList(); -} - -QString MinecraftVersion::getName() -{ - return "Minecraft"; -} -QString MinecraftVersion::getVersion() -{ - return m_descriptor; -} -QString MinecraftVersion::getID() -{ - return "net.minecraft"; -} -QString MinecraftVersion::getFilename() -{ - return QString(); -} -QDateTime MinecraftVersion::getReleaseDateTime() -{ - return m_releaseTime; -} - - -bool MinecraftVersion::needsUpdate() -{ - return m_versionSource == VersionSource::Remote || hasUpdate(); -} - -bool MinecraftVersion::hasUpdate() -{ - return m_versionSource == VersionSource::Remote || (m_versionSource == VersionSource::Local && upstreamUpdate); -} - -bool MinecraftVersion::isCustom() -{ - // if we add any other source types, this will evaluate to false for them. - return m_versionSource != VersionSource::Builtin - && m_versionSource != VersionSource::Local - && m_versionSource != VersionSource::Remote; -} diff --git a/api/logic/minecraft/MinecraftVersion.h b/api/logic/minecraft/MinecraftVersion.h deleted file mode 100644 index 7ac9bcbb..00000000 --- a/api/logic/minecraft/MinecraftVersion.h +++ /dev/null @@ -1,132 +0,0 @@ -/* Copyright 2013-2017 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include "BaseVersion.h" -#include "ProfilePatch.h" -#include "VersionFile.h" - -#include "multimc_logic_export.h" - -class MinecraftProfile; -class MinecraftVersion; -typedef std::shared_ptr MinecraftVersionPtr; - -class MULTIMC_LOGIC_EXPORT MinecraftVersion : public BaseVersion, public ProfilePatch -{ -friend class MinecraftVersionList; - -public: /* methods */ - bool usesLegacyLauncher(); - virtual QString descriptor() override; - virtual QString name() override; - virtual QString typeString() const override; - virtual bool hasJarMods() override; - virtual bool isMinecraftVersion() override; - virtual void applyTo(MinecraftProfile *profile) override; - virtual int getOrder() override; - virtual void setOrder(int order) override; - virtual QList getJarMods() override; - virtual QString getID() override; - virtual QString getVersion() override; - virtual QString getName() override; - virtual QString getFilename() override; - QDateTime getReleaseDateTime() override; - VersionSource getVersionSource() override; - - bool needsUpdate(); - bool hasUpdate(); - virtual bool isCustom() override; - virtual bool isMoveable() override - { - return false; - } - virtual bool isCustomizable() override; - virtual bool isRemovable() override - { - return false; - } - virtual bool isRevertible() override - { - return false; - } - virtual bool isEditable() override - { - return false; - } - virtual bool isVersionChangeable() override - { - return true; - } - - virtual VersionFilePtr getVersionFile() override; - - // virtual QJsonDocument toJson(bool saveOrder) override; - - QString getUrl() const; - - virtual const QList &getProblems() override; - virtual ProblemSeverity getProblemSeverity() override; - -private: /* methods */ - void applyFileTo(MinecraftProfile *profile); - -protected: /* data */ - VersionSource m_versionSource = VersionSource::Builtin; - - /// 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 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; - - /// The type of this release - QString m_type; - - /// the time this version was actually released by Mojang - QDateTime m_releaseTime; - - /// 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; - - /// an update available from Mojang - MinecraftVersionPtr upstreamUpdate; - - QDateTime m_loadedVersionFileTimestamp; - mutable VersionFilePtr m_loadedVersionFile; -}; diff --git a/api/logic/minecraft/MinecraftVersionList.cpp b/api/logic/minecraft/MinecraftVersionList.cpp deleted file mode 100644 index 0dc46289..00000000 --- a/api/logic/minecraft/MinecraftVersionList.cpp +++ /dev/null @@ -1,614 +0,0 @@ -/* Copyright 2013-2017 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include "Json.h" -#include -#include - -#include "Env.h" -#include "Exception.h" - -#include "MinecraftVersionList.h" -#include "net/URLConstants.h" - -#include "ParseUtils.h" -#include "ProfileUtils.h" -#include "onesix/OneSixVersionFormat.h" -#include "MojangVersionFormat.h" -#include - -static const char * localVersionCache = "versions/versions.dat"; - -class MCVListLoadTask : public Task -{ - Q_OBJECT - -public: - explicit MCVListLoadTask(MinecraftVersionList *vlist); - virtual ~MCVListLoadTask() override{}; - - virtual void executeTask() override; - -protected -slots: - void list_downloaded(); - -protected: - QNetworkReply *vlistReply; - MinecraftVersionList *m_list; - MinecraftVersion *m_currentStable; -}; - -class MCVListVersionUpdateTask : public Task -{ - Q_OBJECT - -public: - explicit MCVListVersionUpdateTask(MinecraftVersionList *vlist, std::shared_ptr updatedVersion); - virtual ~MCVListVersionUpdateTask() override{}; - virtual void executeTask() override; - bool canAbort() const override; - -public slots: - bool abort() override; - -protected -slots: - void json_downloaded(); - -protected: - NetJobPtr specificVersionDownloadJob; - QByteArray versionIndexData; - std::shared_ptr updatedVersion; - MinecraftVersionList *m_list; - bool m_aborted = false; -}; - -class ListLoadError : public Exception -{ -public: - ListLoadError(QString cause) : Exception(cause) {}; - virtual ~ListLoadError() noexcept - { - } -}; - -MinecraftVersionList::MinecraftVersionList(QObject *parent) : BaseVersionList(parent) -{ - loadCachedList(); -} - -Task *MinecraftVersionList::getLoadTask() -{ - return new MCVListLoadTask(this); -} - -bool MinecraftVersionList::isLoaded() -{ - return m_loaded; -} - -const BaseVersionPtr MinecraftVersionList::at(int i) const -{ - return m_vlist.at(i); -} - -int MinecraftVersionList::count() const -{ - return m_vlist.count(); -} - -static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second) -{ - auto left = std::dynamic_pointer_cast(first); - auto right = std::dynamic_pointer_cast(second); - return left->getReleaseDateTime() > right->getReleaseDateTime(); -} - -void MinecraftVersionList::sortInternal() -{ - qSort(m_vlist.begin(), m_vlist.end(), cmpVersions); -} - -void MinecraftVersionList::loadCachedList() -{ - QFile localIndex(localVersionCache); - if (!localIndex.exists()) - { - return; - } - if (!localIndex.open(QIODevice::ReadOnly)) - { - // FIXME: this is actually a very bad thing! How do we deal with this? - qCritical() << "The minecraft version cache can't be read."; - return; - } - auto data = localIndex.readAll(); - try - { - localIndex.close(); - QJsonDocument jsonDoc = QJsonDocument::fromBinaryData(data); - if (jsonDoc.isNull()) - { - throw ListLoadError(tr("Error reading the version list.")); - } - loadMojangList(jsonDoc, VersionSource::Local); - } - catch (Exception &e) - { - // the cache has gone bad for some reason... flush it. - qCritical() << "The minecraft version cache is corrupted. Flushing cache."; - localIndex.remove(); - return; - } - m_hasLocalIndex = true; -} - -void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource source) -{ - qDebug() << "Loading" << ((source == VersionSource::Remote) ? "remote" : "local") << "version list."; - - if (!jsonDoc.isObject()) - { - throw ListLoadError(tr("Error parsing version list JSON: jsonDoc is not an object")); - } - - QJsonObject root = jsonDoc.object(); - - try - { - QJsonObject latest = Json::requireObject(root.value("latest")); - m_latestReleaseID = Json::requireString(latest.value("release")); - m_latestSnapshotID = Json::requireString(latest.value("snapshot")); - } - catch (Exception &err) - { - qCritical() - << tr("Error parsing version list JSON: couldn't determine latest versions"); - } - - // Now, get the array of versions. - if (!root.value("versions").isArray()) - { - throw ListLoadError(tr("Error parsing version list JSON: version list object is " - "missing 'versions' array")); - } - QJsonArray versions = root.value("versions").toArray(); - - QList tempList; - for (auto version : versions) - { - // Load the version info. - if (!version.isObject()) - { - qCritical() << "Error while parsing version list : invalid JSON structure"; - continue; - } - - QJsonObject versionObj = version.toObject(); - QString versionID = versionObj.value("id").toString(""); - if (versionID.isEmpty()) - { - qCritical() << "Error while parsing version : version ID is missing"; - continue; - } - - // Now, we construct the version object and add it to the list. - std::shared_ptr mcVersion(new MinecraftVersion()); - mcVersion->m_name = mcVersion->m_descriptor = versionID; - - mcVersion->m_releaseTime = timeFromS3Time(versionObj.value("releaseTime").toString("")); - mcVersion->m_updateTime = timeFromS3Time(versionObj.value("time").toString("")); - - // depends on where we load the version from -- network request or local file? - mcVersion->m_versionSource = source; - mcVersion->m_versionFileURL = versionObj.value("url").toString(""); - QString versionTypeStr = versionObj.value("type").toString(""); - if (versionTypeStr.isEmpty()) - { - qCritical() << "Ignoring" << versionID - << "because it doesn't have the version type set."; - continue; - } - // OneSix or Legacy. use filter to determine type - if (versionTypeStr == "release") - { - } - else if (versionTypeStr == "snapshot") // It's a snapshot... yay - { - } - else if (versionTypeStr == "old_alpha") - { - } - else if (versionTypeStr == "old_beta") - { - } - else - { - qCritical() << "Ignoring" << versionID - << "because it has an invalid version type."; - continue; - } - mcVersion->m_type = versionTypeStr; - qDebug() << "Loaded version" << versionID << "from" - << ((source == VersionSource::Remote) ? "remote" : "local") << "version list."; - tempList.append(mcVersion); - } - updateListData(tempList); - if(source == VersionSource::Remote) - { - m_loaded = true; - } -} - -void MinecraftVersionList::sortVersions() -{ - beginResetModel(); - sortInternal(); - endResetModel(); -} - -QVariant MinecraftVersionList::data(const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() > count()) - return QVariant(); - - auto version = std::dynamic_pointer_cast(m_vlist[index.row()]); - switch (role) - { - case VersionPointerRole: - return qVariantFromValue(m_vlist[index.row()]); - - case VersionRole: - return version->name(); - - case VersionIdRole: - return version->descriptor(); - - case RecommendedRole: - return version->descriptor() == m_latestReleaseID; - - case LatestRole: - { - if(version->descriptor() != m_latestSnapshotID) - return false; - MinecraftVersionPtr latestRelease = std::dynamic_pointer_cast(getLatestStable()); - /* - if(latestRelease && latestRelease->m_releaseTime > version->m_releaseTime) - { - return false; - } - */ - return true; - } - - case TypeRole: - return version->typeString(); - - default: - return QVariant(); - } -} - -BaseVersionList::RoleList MinecraftVersionList::providesRoles() const -{ - return {VersionPointerRole, VersionRole, VersionIdRole, RecommendedRole, LatestRole, TypeRole}; -} - -BaseVersionPtr MinecraftVersionList::getLatestStable() const -{ - if(m_lookup.contains(m_latestReleaseID)) - return m_lookup[m_latestReleaseID]; - return BaseVersionPtr(); -} - -BaseVersionPtr MinecraftVersionList::getRecommended() const -{ - return getLatestStable(); -} - -void MinecraftVersionList::updateListData(QList versions) -{ - beginResetModel(); - for (auto version : versions) - { - auto descr = version->descriptor(); - - if (!m_lookup.contains(descr)) - { - m_lookup[version->descriptor()] = version; - m_vlist.append(version); - continue; - } - auto orig = std::dynamic_pointer_cast(m_lookup[descr]); - auto added = std::dynamic_pointer_cast(version); - // updateListData is called after Mojang list loads. those can be local or remote - // remote comes always after local - // any other options are ignored - if (orig->m_versionSource != VersionSource::Local || added->m_versionSource != VersionSource::Remote) - { - continue; - } - // alright, it's an update. put it inside the original, for further processing. - orig->upstreamUpdate = added; - } - sortInternal(); - endResetModel(); -} - -MCVListLoadTask::MCVListLoadTask(MinecraftVersionList *vlist) -{ - m_list = vlist; - m_currentStable = NULL; - vlistReply = nullptr; -} - -void MCVListLoadTask::executeTask() -{ - setStatus(tr("Loading instance version list...")); - vlistReply = ENV.qnam().get(QNetworkRequest(QUrl("https://launchermeta.mojang.com/mc/game/version_manifest.json"))); - connect(vlistReply, SIGNAL(finished()), this, SLOT(list_downloaded())); -} - -void MCVListLoadTask::list_downloaded() -{ - if (vlistReply->error() != QNetworkReply::NoError) - { - vlistReply->deleteLater(); - emitFailed("Failed to load Minecraft main version list" + vlistReply->errorString()); - return; - } - - auto data = vlistReply->readAll(); - vlistReply->deleteLater(); - try - { - QJsonParseError jsonError; - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); - if (jsonError.error != QJsonParseError::NoError) - { - throw ListLoadError( - tr("Error parsing version list JSON: %1").arg(jsonError.errorString())); - } - m_list->loadMojangList(jsonDoc, VersionSource::Remote); - } - catch (Exception &e) - { - emitFailed(e.cause()); - return; - } - - emitSucceeded(); - return; -} - -MCVListVersionUpdateTask::MCVListVersionUpdateTask(MinecraftVersionList *vlist, std::shared_ptr updatedVersion) - : Task() -{ - m_list = vlist; - this->updatedVersion = updatedVersion; -} - -void MCVListVersionUpdateTask::executeTask() -{ - if(m_aborted) - { - emitFailed(tr("Task aborted.")); - return; - } - auto job = new NetJob("Version index"); - job->addNetAction(Net::Download::makeByteArray(QUrl(updatedVersion->getUrl()), &versionIndexData)); - 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))); - specificVersionDownloadJob->start(); -} - -bool MCVListVersionUpdateTask::canAbort() const -{ - return true; -} - -bool MCVListVersionUpdateTask::abort() -{ - m_aborted = true; - if(specificVersionDownloadJob) - { - return specificVersionDownloadJob->abort(); - } - return true; -} - -void MCVListVersionUpdateTask::json_downloaded() -{ - specificVersionDownloadJob.reset(); - - QJsonParseError jsonError; - QJsonDocument jsonDoc = QJsonDocument::fromJson(versionIndexData, &jsonError); - versionIndexData.clear(); - - if (jsonError.error != QJsonParseError::NoError) - { - emitFailed(tr("The download version file is not valid.")); - return; - } - VersionFilePtr file; - try - { - file = MojangVersionFormat::versionFileFromJson(jsonDoc, "net.minecraft.json"); - } - catch (Exception &e) - { - emitFailed(tr("Couldn't process version file: %1").arg(e.cause())); - return; - } - - // 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 - auto doc = OneSixVersionFormat::versionFileToJson(file, false); - auto newdata = doc.toBinaryData(); - auto id = updatedVersion->descriptor(); - QString targetPath = "versions/" + id + "/" + id + ".dat"; - FS::ensureFilePathExists(targetPath); - QSaveFile vfile1(targetPath); - if (!vfile1.open(QIODevice::Truncate | QIODevice::WriteOnly)) - { - emitFailed(tr("Can't open %1 for writing.").arg(targetPath)); - return; - } - qint64 actual = 0; - if ((actual = vfile1.write(newdata)) != newdata.size()) - { - emitFailed(tr("Failed to write into %1. Written %2 out of %3.") - .arg(targetPath) - .arg(actual) - .arg(newdata.size())); - return; - } - if (!vfile1.commit()) - { - emitFailed(tr("Can't commit changes to %1").arg(targetPath)); - return; - } - - m_list->finalizeUpdate(id); - emitSucceeded(); -} - -std::shared_ptr MinecraftVersionList::createUpdateTask(QString version) -{ - auto iter = m_lookup.find(version); - if(iter == m_lookup.end()) - return nullptr; - - auto mcversion = std::dynamic_pointer_cast(*iter); - if(!mcversion) - { - return nullptr; - } - - return std::shared_ptr(new MCVListVersionUpdateTask(this, mcversion)); -} - -void MinecraftVersionList::saveCachedList() -{ - // FIXME: throw. - if (!FS::ensureFilePathExists(localVersionCache)) - return; - QSaveFile tfile(localVersionCache); - if (!tfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) - return; - QJsonObject toplevel; - QJsonArray entriesArr; - for (auto version : m_vlist) - { - auto mcversion = std::dynamic_pointer_cast(version); - // do not save the remote versions. - if (mcversion->m_versionSource != VersionSource::Local) - continue; - QJsonObject entryObj; - - entryObj.insert("id", mcversion->descriptor()); - entryObj.insert("version", mcversion->descriptor()); - entryObj.insert("time", timeToS3Time(mcversion->m_updateTime)); - entryObj.insert("releaseTime", timeToS3Time(mcversion->m_releaseTime)); - entryObj.insert("url", mcversion->m_versionFileURL); - entryObj.insert("type", mcversion->m_type); - entriesArr.append(entryObj); - } - toplevel.insert("versions", entriesArr); - - { - bool someLatest = false; - QJsonObject latestObj; - if(!m_latestReleaseID.isNull()) - { - latestObj.insert("release", m_latestReleaseID); - someLatest = true; - } - if(!m_latestSnapshotID.isNull()) - { - latestObj.insert("snapshot", m_latestSnapshotID); - someLatest = true; - } - if(someLatest) - { - toplevel.insert("latest", latestObj); - } - } - - QJsonDocument doc(toplevel); - QByteArray jsonData = doc.toBinaryData(); - qint64 result = tfile.write(jsonData); - if (result == -1) - return; - if (result != jsonData.size()) - return; - tfile.commit(); -} - -void MinecraftVersionList::finalizeUpdate(QString version) -{ - int idx = -1; - for (int i = 0; i < m_vlist.size(); i++) - { - if (version == m_vlist[i]->descriptor()) - { - idx = i; - break; - } - } - if (idx == -1) - { - return; - } - - auto updatedVersion = std::dynamic_pointer_cast(m_vlist[idx]); - - // reject any updates to builtin versions. - if (updatedVersion->m_versionSource == VersionSource::Builtin) - return; - - // if we have an update for the version, replace it, make the update local - if (updatedVersion->upstreamUpdate) - { - auto updatedWith = updatedVersion->upstreamUpdate; - updatedWith->m_versionSource = VersionSource::Local; - m_vlist[idx] = updatedWith; - m_lookup[version] = updatedWith; - } - else - { - // otherwise, just set the version as local; - updatedVersion->m_versionSource = VersionSource::Local; - } - - dataChanged(index(idx), index(idx)); - - saveCachedList(); -} - -#include "MinecraftVersionList.moc" diff --git a/api/logic/minecraft/MinecraftVersionList.h b/api/logic/minecraft/MinecraftVersionList.h deleted file mode 100644 index fc421966..00000000 --- a/api/logic/minecraft/MinecraftVersionList.h +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2013-2017 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include "BaseVersionList.h" -#include "tasks/Task.h" -#include "minecraft/MinecraftVersion.h" -#include - -#include "multimc_logic_export.h" - -class MCVListLoadTask; -class MCVListVersionUpdateTask; - -class MULTIMC_LOGIC_EXPORT MinecraftVersionList : public BaseVersionList -{ - Q_OBJECT -private: - void sortInternal(); - void loadMojangList(QJsonDocument jsonDoc, VersionSource source); - void loadCachedList(); - void saveCachedList(); - void finalizeUpdate(QString version); -public: - friend class MCVListLoadTask; - friend class MCVListVersionUpdateTask; - - explicit MinecraftVersionList(QObject *parent = 0); - - std::shared_ptr createUpdateTask(QString version); - - virtual Task *getLoadTask() override; - virtual bool isLoaded() override; - virtual const BaseVersionPtr at(int i) const override; - virtual int count() const override; - virtual void sortVersions() override; - virtual QVariant data(const QModelIndex & index, int role) const override; - virtual RoleList providesRoles() const override; - - virtual BaseVersionPtr getLatestStable() const override; - virtual BaseVersionPtr getRecommended() const override; - -protected: - QList m_vlist; - QMap m_lookup; - - bool m_loaded = false; - bool m_hasLocalIndex = false; - QString m_latestReleaseID = "INVALID"; - QString m_latestSnapshotID = "INVALID"; - -protected -slots: - virtual void updateListData(QList versions) override; -}; diff --git a/api/logic/minecraft/MojangVersionFormat.cpp b/api/logic/minecraft/MojangVersionFormat.cpp index 34129c9e..1312421f 100644 --- a/api/logic/minecraft/MojangVersionFormat.cpp +++ b/api/logic/minecraft/MojangVersionFormat.cpp @@ -1,6 +1,5 @@ #include "MojangVersionFormat.h" #include "onesix/OneSixVersionFormat.h" -#include "MinecraftVersion.h" #include "VersionBuildError.h" #include "MojangDownloadInfo.h" diff --git a/api/logic/minecraft/forge/ForgeInstaller.cpp b/api/logic/minecraft/forge/ForgeInstaller.cpp index a9c12fcd..f7ce4dec 100644 --- a/api/logic/minecraft/forge/ForgeInstaller.cpp +++ b/api/logic/minecraft/forge/ForgeInstaller.cpp @@ -23,7 +23,6 @@ #include "minecraft/onesix/OneSixInstance.h" #include #include "minecraft/VersionFilterData.h" -#include "minecraft/MinecraftVersion.h" #include "Env.h" #include "Exception.h" #include @@ -137,6 +136,9 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr bool ForgeInstaller::add(OneSixInstance *to) { + return false; + // TODO: move to python code. +/* if (!BaseInstaller::add(to)) { return false; @@ -286,10 +288,14 @@ bool ForgeInstaller::add(OneSixInstance *to) file.commit(); return true; + */ } bool ForgeInstaller::addLegacy(OneSixInstance *to) { + return false; + //FIXME: move to python code. + /* if (!BaseInstaller::add(to)) { return false; @@ -339,6 +345,7 @@ bool ForgeInstaller::addLegacy(OneSixInstance *to) file.write(QJsonDocument(obj).toJson()); file.close(); return true; + */ } class ForgeInstallTask : public Task diff --git a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp index 1321ea1b..fe23a84e 100644 --- a/api/logic/minecraft/ftb/FTBInstanceProvider.cpp +++ b/api/logic/minecraft/ftb/FTBInstanceProvider.cpp @@ -9,7 +9,6 @@ #include #include "Env.h" -#include "minecraft/MinecraftVersion.h" #include "LegacyFTBInstance.h" #include "OneSixFTBInstance.h" @@ -246,17 +245,8 @@ InstancePtr FTBInstanceProvider::createInstance(const FTBRecord & record) const m_settings->registerSetting("InstanceType", "Legacy"); // all legacy versions are built in. therefore we can do this even if we don't have ALL the versions Mojang has on their servers. - auto mcVersion = std::dynamic_pointer_cast(ENV.getVersion("net.minecraft", record.mcVersion)); - if (mcVersion && mcVersion->usesLegacyLauncher()) - { - m_settings->set("InstanceType", "LegacyFTB"); - inst.reset(new LegacyFTBInstance(m_globalSettings, m_settings, record.instanceDir)); - } - else - { - m_settings->set("InstanceType", "OneSixFTB"); - inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir)); - } + m_settings->set("InstanceType", "OneSixFTB"); + inst.reset(new OneSixFTBInstance(m_globalSettings, m_settings, record.instanceDir)); // initialize { diff --git a/api/logic/minecraft/ftb/FTBPlugin.cpp b/api/logic/minecraft/ftb/FTBPlugin.cpp index d14eea63..541879a1 100644 --- a/api/logic/minecraft/ftb/FTBPlugin.cpp +++ b/api/logic/minecraft/ftb/FTBPlugin.cpp @@ -1,11 +1,9 @@ #include "FTBPlugin.h" #include -#include "FTBVersion.h" #include "LegacyFTBInstance.h" #include "OneSixFTBInstance.h" #include #include -#include #include #include diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp index e4e6a6ae..92a1555a 100644 --- a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp +++ b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp @@ -2,7 +2,6 @@ #include "OneSixFTBInstance.h" #include "minecraft/VersionBuildError.h" -#include "minecraft/MinecraftVersionList.h" #include #include diff --git a/api/logic/minecraft/ftb/FTBVersion.h b/api/logic/minecraft/ftb/FTBVersion.h deleted file mode 100644 index 805319b4..00000000 --- a/api/logic/minecraft/ftb/FTBVersion.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include - -class FTBVersion : public BaseVersion -{ -public: - FTBVersion(MinecraftVersionPtr parent) : m_version(parent){}; - -public: - virtual QString descriptor() override - { - return m_version->descriptor(); - } - - virtual QString name() override - { - return m_version->name(); - } - - virtual QString typeString() const override - { - return m_version->typeString(); - } - - MinecraftVersionPtr getMinecraftVersion() - { - return m_version; - } - -private: - MinecraftVersionPtr m_version; -}; diff --git a/api/logic/minecraft/legacy/LegacyUpdate.cpp b/api/logic/minecraft/legacy/LegacyUpdate.cpp index fbef47f5..337a3e4e 100644 --- a/api/logic/minecraft/legacy/LegacyUpdate.cpp +++ b/api/logic/minecraft/legacy/LegacyUpdate.cpp @@ -27,7 +27,6 @@ #include "LegacyModList.h" #include "LwjglVersionList.h" -#include "minecraft/MinecraftVersionList.h" #include "LegacyInstance.h" #include diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp index 07c9f075..2b023e82 100644 --- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp +++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp @@ -3,7 +3,6 @@ #include "OneSixVersionFormat.h" #include "minecraft/VersionBuildError.h" -#include "minecraft/MinecraftVersionList.h" #include "Env.h" #include @@ -11,6 +10,8 @@ #include #include #include +#include +#include OneSixProfileStrategy::OneSixProfileStrategy(OneSixInstance* instance) { diff --git a/api/logic/minecraft/onesix/OneSixUpdate.cpp b/api/logic/minecraft/onesix/OneSixUpdate.cpp index 4bc80bfe..ec40e086 100644 --- a/api/logic/minecraft/onesix/OneSixUpdate.cpp +++ b/api/logic/minecraft/onesix/OneSixUpdate.cpp @@ -24,7 +24,6 @@ #include #include "BaseInstance.h" -#include "minecraft/MinecraftVersionList.h" #include "minecraft/MinecraftProfile.h" #include "minecraft/Library.h" #include "net/URLConstants.h" @@ -44,6 +43,7 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent) // add a version update task, if necessary { + /* auto list = std::dynamic_pointer_cast(ENV.getVersionList("net.minecraft")); auto version = std::dynamic_pointer_cast(list->findVersion(m_inst->intendedVersionId())); if (version == nullptr) @@ -67,6 +67,7 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent) m_tasks.append(versionUpdateTask); } } + */ } // libraries download diff --git a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp index 541fb109..403eb112 100644 --- a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp +++ b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp @@ -1,7 +1,6 @@ #include "OneSixVersionFormat.h" #include #include "minecraft/ParseUtils.h" -#include #include #include -- cgit From f6eb8fa1e43a412edb49401107de30d497f0f593 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 12 Mar 2017 20:08:56 +0100 Subject: NOISSUE Remove hardcoded LWJGL (modern) --- api/logic/minecraft/onesix/OneSixProfileStrategy.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'api/logic/minecraft') diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp index 2b023e82..e3d3f674 100644 --- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp +++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp @@ -121,12 +121,8 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches() } else { - // NOTE: this is obviously fake, is fixed in unstable. - QResource LWJGL(":/versions/LWJGL/2.9.1.json"); - auto lwjgl = ProfileUtils::parseJsonFile(LWJGL.absoluteFilePath(), false); - lwjgl->setVanilla(true); - lwjgl->setCustomizable(true); - lwjglPatch = std::dynamic_pointer_cast(lwjgl); + auto lwjglversion = ENV.getVersion("org.lwjgl", "2.9.1" /*m_instance->intendedVersionId()*/); + lwjglPatch = std::dynamic_pointer_cast(lwjglversion); } if (!lwjglPatch) { -- cgit From 40cf38bc3225c614e7e81d074f890e6f9da0507b Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 12 Mar 2017 23:19:45 +0100 Subject: NOISSUE remove liteloader and forge --- api/logic/minecraft/MinecraftProfile.cpp | 5 + api/logic/minecraft/MinecraftProfile.h | 4 + api/logic/minecraft/forge/ForgeInstaller.cpp | 465 --------------------- api/logic/minecraft/forge/ForgeInstaller.h | 52 --- api/logic/minecraft/forge/ForgeVersion.cpp | 55 --- api/logic/minecraft/forge/ForgeVersion.h | 42 -- api/logic/minecraft/forge/ForgeVersionList.cpp | 333 --------------- api/logic/minecraft/forge/ForgeVersionList.h | 90 ---- api/logic/minecraft/forge/LegacyForge.cpp | 56 --- api/logic/minecraft/forge/LegacyForge.h | 25 -- .../minecraft/liteloader/LiteLoaderInstaller.cpp | 106 ----- .../minecraft/liteloader/LiteLoaderInstaller.h | 39 -- .../minecraft/liteloader/LiteLoaderVersionList.cpp | 332 --------------- .../minecraft/liteloader/LiteLoaderVersionList.h | 123 ------ 14 files changed, 9 insertions(+), 1718 deletions(-) delete mode 100644 api/logic/minecraft/forge/ForgeInstaller.cpp delete mode 100644 api/logic/minecraft/forge/ForgeInstaller.h delete mode 100644 api/logic/minecraft/forge/ForgeVersion.cpp delete mode 100644 api/logic/minecraft/forge/ForgeVersion.h delete mode 100644 api/logic/minecraft/forge/ForgeVersionList.cpp delete mode 100644 api/logic/minecraft/forge/ForgeVersionList.h delete mode 100644 api/logic/minecraft/forge/LegacyForge.cpp delete mode 100644 api/logic/minecraft/forge/LegacyForge.h delete mode 100644 api/logic/minecraft/liteloader/LiteLoaderInstaller.cpp delete mode 100644 api/logic/minecraft/liteloader/LiteLoaderInstaller.h delete mode 100644 api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp delete mode 100644 api/logic/minecraft/liteloader/LiteLoaderVersionList.h (limited to 'api/logic/minecraft') diff --git a/api/logic/minecraft/MinecraftProfile.cpp b/api/logic/minecraft/MinecraftProfile.cpp index 46235a18..b74141d6 100644 --- a/api/logic/minecraft/MinecraftProfile.cpp +++ b/api/logic/minecraft/MinecraftProfile.cpp @@ -621,6 +621,11 @@ void MinecraftProfile::installJarMods(QStringList selectedFiles) m_strategy->installJarMods(selectedFiles); } +void MinecraftProfile::installVersion(BaseVersionPtr version) +{ + // TODO: implement +} + /* * TODO: get rid of this. Get rid of all order numbers. */ diff --git a/api/logic/minecraft/MinecraftProfile.h b/api/logic/minecraft/MinecraftProfile.h index 392c8f5f..a6845e9c 100644 --- a/api/logic/minecraft/MinecraftProfile.h +++ b/api/logic/minecraft/MinecraftProfile.h @@ -24,6 +24,7 @@ #include "Library.h" #include "VersionFile.h" #include "JarMod.h" +#include "BaseVersion.h" #include "MojangDownloadInfo.h" #include "multimc_logic_export.h" @@ -58,6 +59,9 @@ public: /// install more jar mods void installJarMods(QStringList selectedFiles); + /// install more jar mods + void installVersion(BaseVersionPtr version); + /// DEPRECATED, remove ASAP int getFreeOrderNumber(); diff --git a/api/logic/minecraft/forge/ForgeInstaller.cpp b/api/logic/minecraft/forge/ForgeInstaller.cpp deleted file mode 100644 index f7ce4dec..00000000 --- a/api/logic/minecraft/forge/ForgeInstaller.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/* Copyright 2013-2017 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "ForgeInstaller.h" -#include "ForgeVersionList.h" - -#include "minecraft/MinecraftProfile.h" -#include "minecraft/GradleSpecifier.h" -#include "net/HttpMetaCache.h" -#include "tasks/Task.h" -#include "minecraft/onesix/OneSixInstance.h" -#include -#include "minecraft/VersionFilterData.h" -#include "Env.h" -#include "Exception.h" -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -ForgeInstaller::ForgeInstaller() : BaseInstaller() -{ -} - -void ForgeInstaller::prepare(const QString &filename, const QString &universalUrl) -{ - VersionFilePtr newVersion; - m_universal_url = universalUrl; - - QuaZip zip(filename); - if (!zip.open(QuaZip::mdUnzip)) - return; - - QuaZipFile file(&zip); - - // read the install profile - if (!zip.setCurrentFile("install_profile.json")) - return; - - QJsonParseError jsonError; - if (!file.open(QIODevice::ReadOnly)) - return; - QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll(), &jsonError); - file.close(); - if (jsonError.error != QJsonParseError::NoError) - return; - - if (!jsonDoc.isObject()) - return; - - QJsonObject root = jsonDoc.object(); - - auto installVal = root.value("install"); - auto versionInfoVal = root.value("versionInfo"); - if (!installVal.isObject() || !versionInfoVal.isObject()) - return; - - try - { - newVersion = OneSixVersionFormat::versionFileFromJson(QJsonDocument(versionInfoVal.toObject()), QString(), false); - } - catch(Exception &err) - { - qWarning() << "Forge: Fatal error while parsing version file:" << err.what(); - return; - } - - for(auto problem: newVersion->getProblems()) - { - qWarning() << "Forge: Problem found: " << problem.getDescription(); - } - if(newVersion->getProblemSeverity() == ProblemSeverity::PROBLEM_ERROR) - { - qWarning() << "Forge: Errors found while parsing version file"; - return; - } - - QJsonObject installObj = installVal.toObject(); - QString libraryName = installObj.value("path").toString(); - internalPath = installObj.value("filePath").toString(); - m_forgeVersionString = installObj.value("version").toString().remove("Forge", Qt::CaseInsensitive).trimmed(); - - // where do we put the library? decode the mojang path - GradleSpecifier lib(libraryName); - - auto cacheentry = ENV.metacache()->resolveEntry("libraries", lib.toPath()); - finalPath = "libraries/" + lib.toPath(); - if (!FS::ensureFilePathExists(finalPath)) - return; - - if (!zip.setCurrentFile(internalPath)) - return; - if (!file.open(QIODevice::ReadOnly)) - return; - { - QByteArray data = file.readAll(); - // extract file - QSaveFile extraction(finalPath); - if (!extraction.open(QIODevice::WriteOnly)) - return; - if (extraction.write(data) != data.size()) - return; - if (!extraction.commit()) - return; - QCryptographicHash md5sum(QCryptographicHash::Md5); - md5sum.addData(data); - - cacheentry->setStale(false); - cacheentry->setMD5Sum(md5sum.result().toHex().constData()); - ENV.metacache()->updateEntry(cacheentry); - } - file.close(); - - m_forge_json = newVersion; -} - -bool ForgeInstaller::add(OneSixInstance *to) -{ - return false; - // TODO: move to python code. -/* - if (!BaseInstaller::add(to)) - { - return false; - } - - if (!m_forge_json) - { - return false; - } - - // A blacklist - QSet blacklist{"authlib", "realms"}; - QList xzlist{"org.scala-lang", "com.typesafe"}; - - // get the minecraft version from the instance - VersionFilePtr minecraft; - auto minecraftPatch = to->getMinecraftProfile()->versionPatch("net.minecraft"); - if(minecraftPatch) - { - minecraft = std::dynamic_pointer_cast(minecraftPatch); - if(!minecraft) - { - auto mcWrap = std::dynamic_pointer_cast(minecraftPatch); - if(mcWrap) - { - minecraft = mcWrap->getVersionFile(); - } - } - } - - // for each library in the version we are adding (except for the blacklisted) - QMutableListIterator iter(m_forge_json->libraries); - while (iter.hasNext()) - { - auto library = iter.next(); - QString libName = library->artifactId(); - QString libVersion = library->version(); - QString rawName = library->rawName(); - - // ignore lwjgl libraries. - if (g_VersionFilterData.lwjglWhitelist.contains(library->artifactPrefix())) - { - iter.remove(); - continue; - } - // ignore other blacklisted (realms, authlib) - if (blacklist.contains(libName)) - { - iter.remove(); - continue; - } - // if minecraft version was found, ignore everything that is already in the minecraft version - if(minecraft) - { - bool found = false; - for (auto & lib: minecraft->libraries) - { - if(library->artifactPrefix() == lib->artifactPrefix() && library->version() == lib->version()) - { - found = true; - break; - } - } - if (found) - continue; - } - - // if this is the actual forge lib, set an absolute url for the download - if (m_forge_version->type == ForgeVersion::Gradle) - { - if (libName == "forge") - { - library->setClassifier("universal"); - } - else if (libName == "minecraftforge") - { - QString forgeCoord("net.minecraftforge:forge:%1:universal"); - // using insane form of the MC version... - QString longVersion = m_forge_version->mcver + "-" + m_forge_version->jobbuildver; - GradleSpecifier spec(forgeCoord.arg(longVersion)); - library->setRawName(spec); - } - } - else - { - if (libName.contains("minecraftforge")) - { - library->setAbsoluteUrl(m_universal_url); - } - } - - // mark bad libraries based on the xzlist above - for (auto entry : xzlist) - { - qDebug() << "Testing " << rawName << " : " << entry; - if (rawName.startsWith(entry)) - { - library->setHint("forge-pack-xz"); - break; - } - } - } - QString &args = m_forge_json->minecraftArguments; - QStringList tweakers; - { - QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)"); - QRegularExpressionMatch match = expression.match(args); - while (match.hasMatch()) - { - tweakers.append(match.captured(1)); - args.remove(match.capturedStart(), match.capturedLength()); - match = expression.match(args); - } - if(tweakers.size()) - { - args.operator=(args.trimmed()); - m_forge_json->addTweakers = tweakers; - } - } - if(minecraft && args == minecraft->minecraftArguments) - { - args.clear(); - } - - m_forge_json->name = "Forge"; - m_forge_json->fileId = id(); - m_forge_json->version = m_forgeVersionString; - m_forge_json->dependsOnMinecraftVersion = to->intendedVersionId(); - m_forge_json->order = 5; - - // reset some things we do not want to be passed along. - m_forge_json->m_releaseTime = QDateTime(); - m_forge_json->m_updateTime = QDateTime(); - m_forge_json->minimumLauncherVersion = -1; - m_forge_json->type.clear(); - m_forge_json->minecraftArguments.clear(); - m_forge_json->minecraftVersion.clear(); - - QSaveFile file(filename(to->instanceRoot())); - if (!file.open(QFile::WriteOnly)) - { - qCritical() << "Error opening" << file.fileName() - << "for reading:" << file.errorString(); - return false; - } - file.write(OneSixVersionFormat::versionFileToJson(m_forge_json, true).toJson()); - file.commit(); - - return true; - */ -} - -bool ForgeInstaller::addLegacy(OneSixInstance *to) -{ - return false; - //FIXME: move to python code. - /* - if (!BaseInstaller::add(to)) - { - return false; - } - auto entry = ENV.metacache()->resolveEntry("minecraftforge", m_forge_version->filename()); - finalPath = FS::PathCombine(to->jarModsDir(), m_forge_version->filename()); - if (!FS::ensureFilePathExists(finalPath)) - { - return false; - } - if (!QFile::copy(entry->getFullPath(), finalPath)) - { - return false; - } - QJsonObject obj; - obj.insert("order", 5); - { - QJsonArray jarmodsPlus; - { - QJsonObject libObj; - libObj.insert("name", m_forge_version->universal_filename); - jarmodsPlus.append(libObj); - } - obj.insert("+jarMods", jarmodsPlus); - } - - obj.insert("name", QString("Forge")); - obj.insert("fileId", id()); - obj.insert("version", m_forge_version->jobbuildver); - obj.insert("mcVersion", to->intendedVersionId()); - if (g_VersionFilterData.fmlLibsMapping.contains(m_forge_version->mcver)) - { - QJsonArray traitsPlus; - traitsPlus.append(QString("legacyFML")); - obj.insert("+traits", traitsPlus); - } - auto fullversion = to->getMinecraftProfile(); - fullversion->remove("net.minecraftforge"); - - QFile file(filename(to->instanceRoot())); - if (!file.open(QFile::WriteOnly)) - { - qCritical() << "Error opening" << file.fileName() - << "for reading:" << file.errorString(); - return false; - } - file.write(QJsonDocument(obj).toJson()); - file.close(); - return true; - */ -} - -class ForgeInstallTask : public Task -{ - Q_OBJECT -public: - ForgeInstallTask(ForgeInstaller *installer, OneSixInstance *instance, - BaseVersionPtr version, QObject *parent = 0) - : Task(parent), m_installer(installer), m_instance(instance), m_version(version) - { - } - -protected: - void executeTask() override - { - setStatus(tr("Installing Forge...")); - ForgeVersionPtr forgeVersion = std::dynamic_pointer_cast(m_version); - if (!forgeVersion) - { - emitFailed(tr("Unknown error occured")); - return; - } - prepare(forgeVersion); - } - void prepare(ForgeVersionPtr forgeVersion) - { - auto entry = ENV.metacache()->resolveEntry("minecraftforge", forgeVersion->filename()); - auto installFunction = [this, entry, forgeVersion]() - { - if (!install(entry, forgeVersion)) - { - qCritical() << "Failure installing Forge"; - emitFailed(tr("Failure to install Forge")); - } - else - { - reload(); - } - }; - - /* - * HACK IF the local non-stale file is too small, mark is as stale - * - * This fixes some problems with bad files acquired because of unhandled HTTP redirects - * in old versions of MultiMC. - */ - if (!entry->isStale()) - { - QFileInfo localFile(entry->getFullPath()); - if (localFile.size() <= 0x4000) - { - entry->setStale(true); - } - } - - if (entry->isStale()) - { - NetJob *fjob = new NetJob("Forge download"); - fjob->addNetAction(Net::Download::makeCached(forgeVersion->url(), entry)); - connect(fjob, &NetJob::progress, this, &Task::setProgress); - connect(fjob, &NetJob::status, this, &Task::setStatus); - connect(fjob, &NetJob::failed, [this](QString reason) - { emitFailed(tr("Failure to download Forge:\n%1").arg(reason)); }); - connect(fjob, &NetJob::succeeded, installFunction); - fjob->start(); - } - else - { - installFunction(); - } - } - bool install(const std::shared_ptr &entry, const ForgeVersionPtr &forgeVersion) - { - if (forgeVersion->usesInstaller()) - { - QString forgePath = entry->getFullPath(); - m_installer->prepare(forgePath, forgeVersion->universal_url); - return m_installer->add(m_instance); - } - else - return m_installer->addLegacy(m_instance); - } - void reload() - { - try - { - m_instance->reloadProfile(); - emitSucceeded(); - } - catch (Exception &e) - { - emitFailed(e.cause()); - } - catch (...) - { - emitFailed(tr("Failed to load the version description file for reasons unknown.")); - } - } - -private: - ForgeInstaller *m_installer; - OneSixInstance *m_instance; - BaseVersionPtr m_version; -}; - -Task *ForgeInstaller::createInstallTask(OneSixInstance *instance, - BaseVersionPtr version, QObject *parent) -{ - if (!version) - { - return nullptr; - } - m_forge_version = std::dynamic_pointer_cast(version); - return new ForgeInstallTask(this, instance, version, parent); -} - -#include "ForgeInstaller.moc" diff --git a/api/logic/minecraft/forge/ForgeInstaller.h b/api/logic/minecraft/forge/ForgeInstaller.h deleted file mode 100644 index 26286be7..00000000 --- a/api/logic/minecraft/forge/ForgeInstaller.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright 2013-2017 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "BaseInstaller.h" - -#include -#include - -#include "multimc_logic_export.h" - -class VersionFile; -class ForgeInstallTask; -struct ForgeVersion; - -class MULTIMC_LOGIC_EXPORT ForgeInstaller : public BaseInstaller -{ - friend class ForgeInstallTask; -public: - ForgeInstaller(); - virtual ~ForgeInstaller(){} - virtual Task *createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent) override; - virtual QString id() const override { return "net.minecraftforge"; } - -protected: - void prepare(const QString &filename, const QString &universalUrl); - bool add(OneSixInstance *to) override; - bool addLegacy(OneSixInstance *to); - -private: - // the parsed version json, read from the installer - std::shared_ptr m_f