From ee5583251d92d47f96b03c3b447c115bab901c17 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 7 Jul 2013 23:51:26 +0200 Subject: Legacy versions downloaded from the new location are treated as legacy versions! --- libmultimc/include/gameupdatetask.h | 72 ++++++++++--------------------------- 1 file changed, 19 insertions(+), 53 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/gameupdatetask.h b/libmultimc/include/gameupdatetask.h index c3f84356..f607db6b 100644 --- a/libmultimc/include/gameupdatetask.h +++ b/libmultimc/include/gameupdatetask.h @@ -22,47 +22,15 @@ #include #include +#include "dlqueue.h" #include "task.h" #include "loginresponse.h" #include "instance.h" #include "libmmc_config.h" -class FileToDownload; -typedef QSharedPointer FileToDownloadPtr; - -class FileToDownload : public QObject -{ - Q_OBJECT - - /*! - * The URL to download the file from. - */ - Q_PROPERTY(QUrl url READ url WRITE setURL) - - /*! - * The path to download to. - * This path is relative to the instance's root directory. - */ - Q_PROPERTY(QString path READ path WRITE setPath) - -private: - FileToDownload(const QUrl &url, const QString &path, QObject *parent = 0); -public: - static FileToDownloadPtr Create(const QUrl &url, const QString &path, QObject *parent = 0); - - virtual QUrl url() const { return m_dlURL; } - virtual void setURL(const QUrl &url) { m_dlURL = url; } - - virtual QString path() const { return m_dlPath; } - virtual void setPath(const QString &path) { m_dlPath = path; } - -private: - QUrl m_dlURL; - QString m_dlPath; -}; - +class MinecraftVersion; /*! * The game update task is the task that handles downloading instances' files. @@ -92,9 +60,6 @@ public: virtual void executeTask(); - virtual bool downloadFile(const FileToDownloadPtr file); - - ////////////////////// // STATE AND STATUS // ////////////////////// @@ -110,6 +75,10 @@ public: */ virtual QString getStateMessage(int state); +private: + void getLegacyJar(); + void determineNewVersion(); + public slots: /*! @@ -122,7 +91,12 @@ public slots: private slots: - virtual void updateDownloadProgress(qint64 current, qint64 total); + void updateDownloadProgress(qint64 current, qint64 total); + void legacyJarFinished(); + void legacyJarFailed(); + + void versionFileFinished(); + void versionFileFailed(); signals: /*! @@ -143,23 +117,8 @@ private: /////////// Instance *m_inst; - LoginResponse m_response; - QNetworkAccessManager *netMgr; - - - - //////////////////////// - // FILE DOWNLOAD LIST // - //////////////////////// - - // List of URLs that the game updater will need to download. - QList m_downloadList; - int m_currentDownload; - - - //////////////////////////// // STATE AND STATUS STUFF // //////////////////////////// @@ -184,6 +143,13 @@ private: // Finished StateFinished }; + JobListPtr legacyDownloadJob; + JobListPtr specificVersionDownloadJob; + JobListPtr jarlibDownloadJob; + JobListQueue download_queue; + + // target version, determined during this task + MinecraftVersion *targetVersion; }; -- cgit From c96ac2460522b9567a10831bcd1d8a6bc9f36d9d Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Tue, 9 Jul 2013 22:46:33 +0200 Subject: Replace one line. Get downloading of 1.6 jars working. Yay. --- libmultimc/include/gameupdatetask.h | 3 +++ libmultimc/src/gameupdatetask.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/gameupdatetask.h b/libmultimc/include/gameupdatetask.h index f607db6b..b56c448b 100644 --- a/libmultimc/include/gameupdatetask.h +++ b/libmultimc/include/gameupdatetask.h @@ -98,6 +98,9 @@ private slots: void versionFileFinished(); void versionFileFailed(); + void jarlibFinished(); + void jarlibFailed(); + signals: /*! * \brief Signal emitted when the game update is complete. diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp index 54e47410..a8abb0b6 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/libmultimc/src/gameupdatetask.cpp @@ -131,8 +131,32 @@ void GameUpdateTask::versionFileFinished() vfile2.close(); // download the right jar, save it in versions/$version/$version.jar - // determine and download all the libraries, save them in libraries/whatever... + QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/"); + urlstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".jar"; + QString targetstr ("versions/"); + targetstr += targetVersion->descriptor() + "/" + targetVersion->descriptor() + ".jar"; + auto dljob = DownloadJob::create(QUrl(urlstr), targetstr); + jarlibDownloadJob.reset(new JobList()); + jarlibDownloadJob->add(dljob); + connect(jarlibDownloadJob.data(), SIGNAL(finished()), SLOT(jarlibFinished())); + connect(jarlibDownloadJob.data(), SIGNAL(failed()), SLOT(jarlibFailed())); + connect(jarlibDownloadJob.data(), SIGNAL(progress(qint64,qint64)), SLOT(updateDownloadProgress(qint64,qint64))); + // determine and download all the libraries, save them in libraries/whatever... + download_queue.enqueue(jarlibDownloadJob); +} + +void GameUpdateTask::jarlibFinished() +{ + exit(1); + // YAYAYAYAYYAYAAUAYAYYAYYY!!!! + // WEE DID IT! + // YESSSSS! +} + +void GameUpdateTask::jarlibFailed() +{ + error("Failed to download the binary garbage. Try again. Maybe. IF YOU DARE"); exit(0); } -- cgit From 33b9b25da7d3d29f949c9418295de257d437c9f8 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sun, 14 Jul 2013 18:33:31 +0200 Subject: More work on the downloader and 1.6 instance creation --- gui/mainwindow.cpp | 2 +- libmultimc/include/instance.h | 30 +++++++++------------- libmultimc/src/gameupdatetask.cpp | 51 +++++++++++++++++++++++++++++++++++--- libmultimc/src/instance.cpp | 2 +- libsettings/src/settingsobject.cpp | 2 +- libutil/include/dlqueue.h | 2 ++ libutil/src/dlqueue.cpp | 34 ++++++++++++++++--------- 7 files changed, 87 insertions(+), 36 deletions(-) (limited to 'libmultimc/include') diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 5336b12c..8ba988c5 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -416,7 +416,7 @@ void MainWindow::onLoginComplete(LoginResponse response) { Q_ASSERT_X(m_activeInst != NULL, "onLoginComplete", "no active instance is set"); - if (!m_activeInst->shouldUpdateGame()) + if (!m_activeInst->shouldUpdate()) { launchInstance(m_activeInst, response); } diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index 717f8816..526025be 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -80,16 +80,7 @@ class LIBMULTIMC_EXPORT Instance : public QObject * This returns true if shouldForceUpdate game is true or if the intended and * current versions don't match. */ - Q_PROPERTY(bool shouldUpdateGame READ shouldUpdateGame STORED false) - - /*! - * Whether or not the game will be forced to update on the next launch. - * If this is set to true, shouldUpdateGame will be true, regardless of whether or not - * the current and intended versions match. - * It should be noted that this is set to false automatically when game updates are run. - */ - Q_PROPERTY(bool shouldForceUpdateGame READ shouldForceUpdateGame WRITE setShouldForceUpdateGame) - + Q_PROPERTY(bool shouldUpdate READ shouldUpdate WRITE setShouldUpdate) /*! * The instance's current version. @@ -236,14 +227,17 @@ public: virtual QString intendedVersion() const { return settings().get("IntendedJarVersion").toString(); } virtual void setIntendedVersion(QString val) { settings().set("IntendedJarVersion", val); } - virtual bool shouldUpdateGame() const - { return shouldForceUpdateGame() || intendedVersion() != currentVersion(); } - - virtual bool shouldForceUpdateGame() const { return settings().get("ShouldForceUpdate").toBool(); } - virtual void setShouldForceUpdateGame(bool val) { settings().set("ShouldForceUpdate", val); } - - - + virtual bool shouldUpdate() const + { + QVariant var = settings().get("ShouldUpdate"); + if(!var.isValid() || var.toBool() == false) + { + return intendedVersion() != currentVersion(); + } + return true; + } + virtual void setShouldUpdate(bool val) { settings().set("ShouldUpdate", val); } + //// Timestamps //// virtual qint64 lastLaunch() const { return settings().get("lastLaunchTime").value(); } diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp index a8abb0b6..b6c1f936 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/libmultimc/src/gameupdatetask.cpp @@ -112,6 +112,52 @@ void GameUpdateTask::versionFileFinished() getLegacyJar(); return; } + /* + // Iterate through the list. + QJsonObject groupList = root.value("libraries").toObject(); + + for (QJsonObject::iterator iter = groupList.begin(); + iter != groupList.end(); iter++) + { + QString groupName = iter.key(); + + // If not an object, complain and skip to the next one. + if (!iter.value().isObject()) + { + qWarning(QString("Group '%1' in the group list should " + "be an object.").arg(groupName).toUtf8()); + continue; + } + + QJsonObject groupObj = iter.value().toObject(); + + // Create the group object. + InstanceGroup *group = new InstanceGroup(groupName, this); + groups.push_back(group); + + // If 'hidden' isn't a bool value, just assume it's false. + if (groupObj.value("hidden").isBool() && groupObj.value("hidden").toBool()) + { + group->setHidden(groupObj.value("hidden").toBool()); + } + + if (!groupObj.value("instances").isArray()) + { + qWarning(QString("Group '%1' in the group list is invalid. " + "It should contain an array " + "called 'instances'.").arg(groupName).toUtf8()); + continue; + } + + // Iterate through the list of instances in the group. + QJsonArray instancesArray = groupObj.value("instances").toArray(); + + for (QJsonArray::iterator iter2 = instancesArray.begin(); + iter2 != instancesArray.end(); iter2++) + { + groupMap[(*iter2).toString()] = groupName; + } + }*/ // save the version file in $instanceId/version.json and versions/$version/$version.json QString version_id = targetVersion->descriptor(); @@ -148,10 +194,9 @@ void GameUpdateTask::versionFileFinished() void GameUpdateTask::jarlibFinished() { + m_inst->setCurrentVersion(targetVersion->descriptor()); + m_inst->setShouldUpdate(false); exit(1); - // YAYAYAYAYYAYAAUAYAYYAYYY!!!! - // WEE DID IT! - // YESSSSS! } void GameUpdateTask::jarlibFailed() diff --git a/libmultimc/src/instance.cpp b/libmultimc/src/instance.cpp index 08cd6605..fde31cf3 100644 --- a/libmultimc/src/instance.cpp +++ b/libmultimc/src/instance.cpp @@ -34,7 +34,7 @@ Instance::Instance(const QString &rootDir, QObject *parent) : settings().registerSetting(new Setting("iconKey", "default")); settings().registerSetting(new Setting("notes", "")); settings().registerSetting(new Setting("NeedsRebuild", true)); - settings().registerSetting(new Setting("ShouldForceUpdate", false)); + settings().registerSetting(new Setting("ShouldUpdate", false)); settings().registerSetting(new Setting("JarVersion", "Unknown")); settings().registerSetting(new Setting("LwjglVersion", "2.9.0")); settings().registerSetting(new Setting("IntendedJarVersion", "")); diff --git a/libsettings/src/settingsobject.cpp b/libsettings/src/settingsobject.cpp index 98c7b479..f94a6552 100644 --- a/libsettings/src/settingsobject.cpp +++ b/libsettings/src/settingsobject.cpp @@ -49,7 +49,7 @@ bool SettingsObject::registerSetting(Setting *setting) // Connect signals. connectSignals(*setting); - qDebug(QString("Registered setting %1.").arg(setting->id()).toUtf8()); + // qDebug(QString("Registered setting %1.").arg(setting->id()).toUtf8()); return true; } diff --git a/libutil/include/dlqueue.h b/libutil/include/dlqueue.h index 14fa6e60..69fc22a6 100644 --- a/libutil/include/dlqueue.h +++ b/libutil/include/dlqueue.h @@ -40,6 +40,8 @@ public: /// save to file? bool m_save_to_file; + /// is the saving file already open? + bool m_opened_for_saving; /// if saving to file, use the one specified in this string QString m_target_path; /// this is the output file, if any diff --git a/libutil/src/dlqueue.cpp b/libutil/src/dlqueue.cpp index 9a080c17..1ef8e212 100644 --- a/libutil/src/dlqueue.cpp +++ b/libutil/src/dlqueue.cpp @@ -10,6 +10,7 @@ DownloadJob::DownloadJob ( QUrl url, QString target_path, QString expected_md5 ) m_check_md5 = m_expected_md5.size(); m_save_to_file = m_target_path.size(); m_status = Job_NotStarted; + m_opened_for_saving = false; } JobPtr DownloadJob::create ( QUrl url, QString target_path, QString expected_md5 ) @@ -32,36 +33,32 @@ void DownloadJob::start() QString filename = m_target_path; m_output_file.setFileName ( filename ); // if there already is a file and md5 checking is in effect and it can be opened - if ( m_check_md5 && m_output_file.exists() && m_output_file.open ( QIODevice::ReadOnly ) ) + if ( m_output_file.exists() && m_output_file.open ( QIODevice::ReadOnly ) ) { // check the md5 against the expected one QString hash = QCryptographicHash::hash ( m_output_file.readAll(), QCryptographicHash::Md5 ).toHex().constData(); m_output_file.close(); // skip this file if they match - if ( hash == m_expected_md5 ) + if ( m_check_md5 && hash == m_expected_md5 ) { qDebug() << "Skipping " << m_url.toString() << ": md5 match."; emit finish(); return; } + else + { + m_expected_md5 = hash; + } } if(!ensurePathExists(filename)) { emit fail(); return; } - - if ( !m_output_file.open ( QIODevice::WriteOnly ) ) - { - /* - * Can't open the file... the job failed - */ - emit fail(); - return; - } } qDebug() << "Downloading " << m_url.toString(); QNetworkRequest request ( m_url ); + request.setRawHeader(QString("If-None-Match").toLatin1(), m_expected_md5.toLatin1()); QNetworkReply * rep = m_manager->get ( request ); m_reply = QSharedPointer ( rep, &QObject::deleteLater ); connect ( rep, SIGNAL ( downloadProgress ( qint64,qint64 ) ), SLOT ( downloadProgress ( qint64,qint64 ) ) ); @@ -120,8 +117,21 @@ void DownloadJob::downloadFinished() void DownloadJob::downloadReadyRead() { - if ( m_save_to_file ) + if( m_save_to_file ) { + if(!m_opened_for_saving) + { + if ( !m_output_file.open ( QIODevice::WriteOnly ) ) + { + /* + * Can't open the file... the job failed + */ + m_reply->abort(); + emit fail(); + return; + } + m_opened_for_saving = true; + } m_output_file.write ( m_reply->readAll() ); } } -- cgit From 18853ca3fa185f5fe5288a1d0c8ed6cf8c678007 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Mon, 22 Jul 2013 02:01:56 +0200 Subject: Parsing the version files, part I --- libmultimc/CMakeLists.txt | 6 ++ libmultimc/include/fullversion.h | 68 +++++++++++++++++++ libmultimc/include/fullversionfactory.h | 23 +++++++ libmultimc/include/library.h | 18 +++++ libmultimc/src/fullversion.cpp | 4 ++ libmultimc/src/fullversionfactory.cpp | 113 ++++++++++++++++++++++++++++++++ libmultimc/src/gameupdatetask.cpp | 71 +++----------------- libmultimc/src/library.cpp | 18 +++++ 8 files changed, 258 insertions(+), 63 deletions(-) create mode 100644 libmultimc/include/fullversion.h create mode 100644 libmultimc/include/fullversionfactory.h create mode 100644 libmultimc/include/library.h create mode 100644 libmultimc/src/fullversion.cpp create mode 100644 libmultimc/src/fullversionfactory.cpp create mode 100644 libmultimc/src/library.cpp (limited to 'libmultimc/include') diff --git a/libmultimc/CMakeLists.txt b/libmultimc/CMakeLists.txt index 0209f8a4..8adee1ec 100644 --- a/libmultimc/CMakeLists.txt +++ b/libmultimc/CMakeLists.txt @@ -32,6 +32,9 @@ include/instversionlist.h include/minecraftversion.h include/minecraftversionlist.h +include/library.h +include/fullversion.h +include/fullversionfactory.h # Tasks include/task.h @@ -63,6 +66,9 @@ src/instversionlist.cpp src/minecraftversion.cpp src/minecraftversionlist.cpp +src/library.cpp +src/fullversion.cpp +src/fullversionfactory.cpp # Tasks src/task.cpp diff --git a/libmultimc/include/fullversion.h b/libmultimc/include/fullversion.h new file mode 100644 index 00000000..b1de02a3 --- /dev/null +++ b/libmultimc/include/fullversion.h @@ -0,0 +1,68 @@ +#pragma once +#include +#include + +class FullVersion +{ +public: + FullVersion() + { + minimumLauncherVersion = 0xDEADBEEF; + isLegacy = false; + } + // the ID - determines which jar to use! ACTUALLY IMPORTANT! + QString id; + // do we actually care about parsing this? + QString time; + // I don't think we do. + QString releaseTime; + // eh, not caring - "release" or "snapshot" + QString type; + /* + * DEPRECATED: Old versions of the new vanilla launcher used this + * ex: "username_session_version" + */ + QString processArguments; + /* + * arguments that should be used for launching minecraft + * + * ex: "--username ${auth_player_name} --session ${auth_session} + * --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}" + */ + QString minecraftArguments; + /* + * the minimum launcher version required by this version ... current is 4 (at point of writing) + */ + int minimumLauncherVersion; + /* + * The main class to load first + */ + QString mainClass; + + // the list of libs. just the names for now. expand to full-blown strutures! + QStringList libraries; + + // is this actually a legacy version? if so, none of the other stuff here will be ever used. + // added by FullVersionFactory + bool isLegacy; + +/* +FIXME: add support for those rules here? Looks like a pile of quick hacks to me though. + + "rules": [ + { + "action": "allow" + }, + { + "action": "disallow", + "os": { + "name": "osx", + "version": "^10\\.5\\.\\d$" + } + } + ], + "incompatibilityReason": "There is a bug in LWJGL which makes it incompatible with OSX 10.5.8. Please go to New Profile and use 1.5.2 for now. Sorry!" +} +*/ + // QList rules; +}; \ No newline at end of file diff --git a/libmultimc/include/fullversionfactory.h b/libmultimc/include/fullversionfactory.h new file mode 100644 index 00000000..673a6a72 --- /dev/null +++ b/libmultimc/include/fullversionfactory.h @@ -0,0 +1,23 @@ +#pragma once +#include + +struct FullVersion; + +class FullVersionFactory +{ +public: + enum Error + { + AllOK, // all parsed OK + ParseError, // the file was corrupted somehow + UnsupportedVersion // the file was meant for a launcher version we don't support (yet) + } m_error; + QString error_string; + +public: + FullVersionFactory(); + QSharedPointer parse(QByteArray data); +private: + QSharedPointer parse4(QJsonObject root, QSharedPointer product); + QStringList legacyWhitelist; +}; \ No newline at end of file diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h new file mode 100644 index 00000000..10ecb9f3 --- /dev/null +++ b/libmultimc/include/library.h @@ -0,0 +1,18 @@ +/* Copyright 2013 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 + + diff --git a/libmultimc/src/fullversion.cpp b/libmultimc/src/fullversion.cpp new file mode 100644 index 00000000..d66ce5bb --- /dev/null +++ b/libmultimc/src/fullversion.cpp @@ -0,0 +1,4 @@ +#include "fullversion.h" + + +// ECHO, echo, echo, .... \ No newline at end of file diff --git a/libmultimc/src/fullversionfactory.cpp b/libmultimc/src/fullversionfactory.cpp new file mode 100644 index 00000000..8873ee2d --- /dev/null +++ b/libmultimc/src/fullversionfactory.cpp @@ -0,0 +1,113 @@ +#include "fullversionfactory.h" +#include "fullversion.h" + +QSharedPointer FullVersionFactory::parse4(QJsonObject root, QSharedPointer product) +{ + product->id = root.value("id").toString(); + + // if it's on our legacy list, it's legacy + if(legacyWhitelist.contains(product->id)) + product->isLegacy = true; + + product->mainClass = root.value("mainClass").toString(); + auto procArgsValue = root.value("processArguments"); + if(procArgsValue.isString()) + { + product->processArguments = procArgsValue.toString(); + QString toCompare = product->processArguments.toLower(); + if(toCompare == "legacy") + { + product->minecraftArguments = " ${auth_player_name} ${auth_session}"; + product->isLegacy = true; + } + else if(toCompare == "username_session") + { + product->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}"; + } + else if(toCompare == "username_session_version") + { + product->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}"; + } + } + + auto minecraftArgsValue = root.value("minecraftArguments"); + if(minecraftArgsValue.isString()) + { + product->minecraftArguments = minecraftArgsValue.toString(); + } + + product->releaseTime = root.value("releaseTime").toString(); + product->time = root.value("time").toString(); + + // Iterate through the list. + auto librariesValue = root.value("libraries"); + if(librariesValue.isArray()) + { + QJsonArray libList = root.value("libraries").toArray(); + for (auto lib : libList) + { + if (!lib.isObject()) + { + continue; + } + + QJsonObject libObj = lib.toObject(); + + QString crud = libObj.value("name").toString(); + product->libraries.append(crud); + + // TODO: improve! + /* + auto parts = crud.split(':'); + int zz = parts.size(); + */ + } + } + return product; +} + +QSharedPointer FullVersionFactory::parse(QByteArray data) +{ + QSharedPointer readVersion(new FullVersion()); + + QJsonParseError jsonError; + QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); + + if (jsonError.error != QJsonParseError::NoError) + { + error_string = QString( "Error reading version file :") + " " + jsonError.errorString(); + m_error = FullVersionFactory::ParseError; + return QSharedPointer(); + } + + if(!jsonDoc.isObject()) + { + error_string = "Error reading version file."; + m_error = FullVersionFactory::ParseError; + return QSharedPointer(); + } + QJsonObject root = jsonDoc.object(); + + readVersion->minimumLauncherVersion = root.value("minimumLauncherVersion").toDouble(); + switch(readVersion->minimumLauncherVersion) + { + case 1: + case 2: + case 3: + case 4: + return parse4(root, readVersion); + // ADD MORE HERE :D + default: + error_string = "Version file was for an unrecognized launcher version. RIP"; + m_error = FullVersionFactory::UnsupportedVersion; + return QSharedPointer(); + } +} + + +FullVersionFactory::FullVersionFactory() +{ + m_error = FullVersionFactory::AllOK; + legacyWhitelist.append("1.5.1"); + legacyWhitelist.append("1.5.2"); +} diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp index b6c1f936..61880118 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/libmultimc/src/gameupdatetask.cpp @@ -25,9 +25,12 @@ #include #include "minecraftversionlist.h" +#include "fullversionfactory.h" +#include #include "pathutils.h" + GameUpdateTask::GameUpdateTask(const LoginResponse &response, Instance *inst, QObject *parent) : Task(parent), m_response(response) { @@ -86,78 +89,20 @@ void GameUpdateTask::versionFileFinished() { JobPtr firstJob = specificVersionDownloadJob->getFirstJob(); auto DlJob = firstJob.dynamicCast(); - QJsonParseError jsonError; - QJsonDocument jsonDoc = QJsonDocument::fromJson(DlJob->m_data, &jsonError); + FullVersionFactory parser; + auto version = parser.parse(DlJob->m_data); - if (jsonError.error != QJsonParseError::NoError) + if(!version) { - error(QString( "Error reading version file :") + " " + jsonError.errorString()); + error(parser.error_string); exit(0); } - if(!jsonDoc.isObject()) - { - error("Error reading version file."); - exit(0); - } - QJsonObject root = jsonDoc.object(); - - /* - * FIXME: this distinction is pretty weak. The only other option - * is to have a list of all the legacy versions. - */ - QString args = root.value("processArguments").toString("legacy"); - if(args == "legacy") + if(version->isLegacy) { getLegacyJar(); return; } - /* - // Iterate through the list. - QJsonObject groupList = root.value("libraries").toObject(); - - for (QJsonObject::iterator iter = groupList.begin(); - iter != groupList.end(); iter++) - { - QString groupName = iter.key(); - - // If not an object, complain and skip to the next one. - if (!iter.value().isObject()) - { - qWarning(QString("Group '%1' in the group list should " - "be an object.").arg(groupName).toUtf8()); - continue; - } - - QJsonObject groupObj = iter.value().toObject(); - - // Create the group object. - InstanceGroup *group = new InstanceGroup(groupName, this); - groups.push_back(group); - - // If 'hidden' isn't a bool value, just assume it's false. - if (groupObj.value("hidden").isBool() && groupObj.value("hidden").toBool()) - { - group->setHidden(groupObj.value("hidden").toBool()); - } - - if (!groupObj.value("instances").isArray()) - { - qWarning(QString("Group '%1' in the group list is invalid. " - "It should contain an array " - "called 'instances'.").arg(groupName).toUtf8()); - continue; - } - - // Iterate through the list of instances in the group. - QJsonArray instancesArray = groupObj.value("instances").toArray(); - - for (QJsonArray::iterator iter2 = instancesArray.begin(); - iter2 != instancesArray.end(); iter2++) - { - groupMap[(*iter2).toString()] = groupName; - } - }*/ // save the version file in $instanceId/version.json and versions/$version/$version.json QString version_id = targetVersion->descriptor(); diff --git a/libmultimc/src/library.cpp b/libmultimc/src/library.cpp new file mode 100644 index 00000000..b0490616 --- /dev/null +++ b/libmultimc/src/library.cpp @@ -0,0 +1,18 @@ +/* Copyright 2013 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/library.h" + +// default url for lib: https://s3.amazonaws.com/Minecraft.Download/libraries/ -- cgit From 97cf08f964ceebf4cb98b46f473bf952007a8a21 Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Wed, 24 Jul 2013 23:44:00 +0200 Subject: Parsing the version files, part II --- libmultimc/include/fullversion.h | 5 +- libmultimc/include/library.h | 117 +++++++++++++++++++++++++++++ libmultimc/src/fullversion.cpp | 2 +- libmultimc/src/fullversionfactory.cpp | 137 ++++++++++++++++++++++++++-------- libmultimc/src/library.cpp | 19 +++++ 5 files changed, 246 insertions(+), 34 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/fullversion.h b/libmultimc/include/fullversion.h index b1de02a3..523ac87c 100644 --- a/libmultimc/include/fullversion.h +++ b/libmultimc/include/fullversion.h @@ -1,6 +1,7 @@ #pragma once #include -#include + +class Library; class FullVersion { @@ -40,7 +41,7 @@ public: QString mainClass; // the list of libs. just the names for now. expand to full-blown strutures! - QStringList libraries; + QList > libraries; // is this actually a legacy version? if so, none of the other stuff here will be ever used. // added by FullVersionFactory diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h index 10ecb9f3..30270bc1 100644 --- a/libmultimc/include/library.h +++ b/libmultimc/include/library.h @@ -15,4 +15,121 @@ #pragma once +#include +class Library; + +enum RuleAction +{ + Allow, + Disallow, + Defer +}; + +RuleAction RuleAction_fromString(QString); + +class Rule +{ +protected: + RuleAction m_result; + virtual bool applies(Library * parent) = 0; +public: + Rule(RuleAction result) + :m_result(result) {} + virtual ~Rule(){}; + RuleAction apply(Library * parent) + { + if(applies(parent)) + return m_result; + else + return Defer; + }; +}; + +enum OpSys +{ + Os_Windows, + Os_Linux, + Os_OSX, + Os_Other +}; + +OpSys OpSys_fromString(QString); + +#ifdef Q_OS_MAC + #define currentSystem Os_OSX +#endif + +#ifdef Q_OS_LINUX + #define currentSystem Os_Linux +#endif + +#ifdef Q_OS_WIN32 + #define currentSystem Os_Windows +#endif + +#ifndef currentSystem + #define currentSystem Os_Other +#endif + + +class OsRule : public Rule +{ +private: + // the OS + OpSys m_system; + // the OS version regexp + QString m_version_regexp; +protected: + virtual bool applies ( Library* ) + { + return (m_system == currentSystem); + } +public: + OsRule(RuleAction result, OpSys system, QString version_regexp) + : Rule(result), m_system(system), m_version_regexp(version_regexp) {} +}; + +class ImplicitRule : public Rule +{ +protected: + virtual bool applies ( Library* ) + { + return true; + } +public: + ImplicitRule(RuleAction result) + : Rule(result) {} +}; + +class Library +{ +public: + QString base_url; + QString name; + QList > rules; + QMap natives; + QStringList extract_excludes; + + void AddRule(RuleAction result) + { + rules.append(QSharedPointer(new ImplicitRule(result))); + } + void AddRule(RuleAction result, OpSys system, QString version_regexp) + { + rules.append(QSharedPointer(new OsRule(result, system, version_regexp))); + } + bool applies() + { + if(rules.empty()) + return true; + RuleAction result = Disallow; + for(auto rule: rules) + { + RuleAction temp = rule->apply( this ); + if(temp != Defer) + result = temp; + } + return result == Allow; + } +}; diff --git a/libmultimc/src/fullversion.cpp b/libmultimc/src/fullversion.cpp index d66ce5bb..6f4662b4 100644 --- a/libmultimc/src/fullversion.cpp +++ b/libmultimc/src/fullversion.cpp @@ -1,4 +1,4 @@ +#include #include "fullversion.h" - // ECHO, echo, echo, .... \ No newline at end of file diff --git a/libmultimc/src/fullversionfactory.cpp b/libmultimc/src/fullversionfactory.cpp index 8873ee2d..9b4ae266 100644 --- a/libmultimc/src/fullversionfactory.cpp +++ b/libmultimc/src/fullversionfactory.cpp @@ -1,69 +1,144 @@ #include "fullversionfactory.h" #include "fullversion.h" +#include -QSharedPointer FullVersionFactory::parse4(QJsonObject root, QSharedPointer product) +QSharedPointer FullVersionFactory::parse4(QJsonObject root, QSharedPointer fullVersion) { - product->id = root.value("id").toString(); + fullVersion->id = root.value("id").toString(); // if it's on our legacy list, it's legacy - if(legacyWhitelist.contains(product->id)) - product->isLegacy = true; + if(legacyWhitelist.contains(fullVersion->id)) + fullVersion->isLegacy = true; - product->mainClass = root.value("mainClass").toString(); + fullVersion->mainClass = root.value("mainClass").toString(); auto procArgsValue = root.value("processArguments"); if(procArgsValue.isString()) { - product->processArguments = procArgsValue.toString(); - QString toCompare = product->processArguments.toLower(); + fullVersion->processArguments = procArgsValue.toString(); + QString toCompare = fullVersion->processArguments.toLower(); if(toCompare == "legacy") { - product->minecraftArguments = " ${auth_player_name} ${auth_session}"; - product->isLegacy = true; + fullVersion->minecraftArguments = " ${auth_player_name} ${auth_session}"; + fullVersion->isLegacy = true; } else if(toCompare == "username_session") { - product->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}"; + fullVersion->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}"; } else if(toCompare == "username_session_version") { - product->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}"; + fullVersion->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}"; } } auto minecraftArgsValue = root.value("minecraftArguments"); if(minecraftArgsValue.isString()) { - product->minecraftArguments = minecraftArgsValue.toString(); + fullVersion->minecraftArguments = minecraftArgsValue.toString(); } - product->releaseTime = root.value("releaseTime").toString(); - product->time = root.value("time").toString(); + fullVersion->releaseTime = root.value("releaseTime").toString(); + fullVersion->time = root.value("time").toString(); - // Iterate through the list. + // Iterate through the list, if it's a list. auto librariesValue = root.value("libraries"); - if(librariesValue.isArray()) + if(!librariesValue.isArray()) + return fullVersion; + + QJsonArray libList = root.value("libraries").toArray(); + for (auto libVal : libList) { - QJsonArray libList = root.value("libraries").toArray(); - for (auto lib : libList) + QSharedPointer library(new Library()); + if (!libVal.isObject()) + { + continue; + } + + QJsonObject libObj = libVal.toObject(); + + // Library name + auto nameVal = libObj.value("name"); + if(!nameVal.isString()) + continue; + library->name = nameVal.toString(); + + // Extract excludes (if any) + auto extractVal = libObj.value("extract"); + if(extractVal.isObject()) { - if (!lib.isObject()) + QStringList excludes; + auto extractObj = extractVal.toObject(); + auto excludesVal = extractObj.value("exclude"); + if(!excludesVal.isArray()) + goto SKIP_EXTRACTS; + auto excludesList = excludesVal.toArray(); + for(auto excludeVal : excludesList) { - continue; + if(excludeVal.isString()) + excludes.append(excludeVal.toString()); } + library->extract_excludes = excludes; + } + SKIP_EXTRACTS: + + auto nativesVal = libObj.value("natives"); + if(nativesVal.isObject()) + { + auto nativesObj = nativesVal.toObject(); + auto iter = nativesObj.begin(); + while(iter != nativesObj.end()) + { + auto osType = OpSys_fromString(iter.key()); + if(osType == Os_Other) + continue; + if(!iter.value().isString()) + continue; + library->natives[osType] = iter.value().toString(); + iter++; + } + } + + // Library rules (if any) + auto rulesVal = libObj.value("rules"); + if(rulesVal.isArray()) + { + QList > rules; - QJsonObject libObj = lib.toObject(); - - QString crud = libObj.value("name").toString(); - product->libraries.append(crud); - - // TODO: improve! - /* - auto parts = crud.split(':'); - int zz = parts.size(); - */ + QJsonArray ruleList = rulesVal.toArray(); + for(auto ruleVal : ruleList) + { + QSharedPointer rule; + if(!ruleVal.isObject()) + continue; + auto ruleObj = ruleVal.toObject(); + auto actionVal = ruleObj.value("action"); + if(!actionVal.isString()) + continue; + auto action = RuleAction_fromString(actionVal.toString()); + if(action == Defer) + continue; + + auto osVal = ruleObj.value("os"); + if(!osVal.isObject()) + { + rule.reset(new ImplicitRule(action)); + } + else + { + auto osObj = osVal.toObject(); + auto osNameVal = osObj.value("name"); + if(!osNameVal.isString()) + continue; + OpSys requiredOs = OpSys_fromString(osNameVal.toString()); + QString versionRegex = osObj.value("version").toString(); + rule.reset(new OsRule(action, requiredOs, versionRegex)); + } + rules.append(rule); + } + library->rules = rules; } } - return product; + return fullVersion; } QSharedPointer FullVersionFactory::parse(QByteArray data) diff --git a/libmultimc/src/library.cpp b/libmultimc/src/library.cpp index b0490616..0fb4f9d3 100644 --- a/libmultimc/src/library.cpp +++ b/libmultimc/src/library.cpp @@ -15,4 +15,23 @@ #include "include/library.h" +RuleAction RuleAction_fromString(QString name) +{ + if(name == "allow") + return Allow; + if(name == "disallow") + return Disallow; + return Defer; +} + +OpSys OpSys_fromString(QString name) +{ + if(name == "linux") + return Os_Linux; + if(name == "windows") + return Os_Windows; + if(name == "osx") + return Os_OSX; + return Os_Other; +} // default url for lib: https://s3.amazonaws.com/Minecraft.Download/libraries/ -- cgit From a7a84d4dbb58565f108cb0886da6cb786e34d10d Mon Sep 17 00:00:00 2001 From: Petr Mrázek Date: Sat, 27 Jul 2013 11:41:45 +0200 Subject: Parsing the version files, part III --- libmultimc/include/fullversionfactory.h | 2 + libmultimc/include/instance.h | 16 ++- libmultimc/include/library.h | 178 +++++++++++++++++++++++--------- libmultimc/src/fullversion.cpp | 1 + libmultimc/src/fullversionfactory.cpp | 104 +++++++++++-------- libmultimc/src/gameupdatetask.cpp | 2 + libmultimc/src/instance.cpp | 1 + libmultimc/src/library.cpp | 2 +- 8 files changed, 213 insertions(+), 93 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/fullversionfactory.h b/libmultimc/include/fullversionfactory.h index 673a6a72..60e5c983 100644 --- a/libmultimc/include/fullversionfactory.h +++ b/libmultimc/include/fullversionfactory.h @@ -2,6 +2,7 @@ #include struct FullVersion; +class Rule; class FullVersionFactory { @@ -19,5 +20,6 @@ public: QSharedPointer parse(QByteArray data); private: QSharedPointer parse4(QJsonObject root, QSharedPointer product); + QList > parse4rules(QJsonObject & baseObj); QStringList legacyWhitelist; }; \ No newline at end of file diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index 526025be..f6857cd8 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -116,8 +116,11 @@ class LIBMULTIMC_EXPORT Instance : public QObject */ Q_PROPERTY(qint64 lastCurrentVersionUpdate READ lastCurrentVersionUpdate WRITE setLastCurrentVersionUpdate) - - + /*! + * Is the instance a new launcher instance? Get/Set + */ + Q_PROPERTY(bool isForNewLauncher READ isForNewLauncher WRITE setIsForNewLauncher) + // Dirs //! Path to the instance's .minecraft folder. Q_PROPERTY(QString minecraftDir READ minecraftDir STORED false) @@ -250,6 +253,15 @@ public: virtual qint64 lastCurrentVersionUpdate() const { return settings().get("lastVersionUpdate").value(); } virtual void setLastCurrentVersionUpdate(qint64 val) { settings().set("lastVersionUpdate", val); } + virtual bool isForNewLauncher() + { + return settings().get("IsForNewLauncher").value(); + } + + virtual void setIsForNewLauncher(bool value = true) + { + settings().set("IsForNewLauncher", value); + } ////// Directories ////// QString minecraftDir() const; diff --git a/libmultimc/include/library.h b/libmultimc/include/library.h index 30270bc1..8d97b4a6 100644 --- a/libmultimc/include/library.h +++ b/libmultimc/include/library.h @@ -19,33 +19,6 @@ class Library; -enum RuleAction -{ - Allow, - Disallow, - Defer -}; - -RuleAction RuleAction_fromString(QString); - -class Rule -{ -protected: - RuleAction m_result; - virtual bool applies(Library * parent) = 0; -public: - Rule(RuleAction result) - :m_result(result) {} - virtual ~Rule(){}; - RuleAction apply(Library * parent) - { - if(applies(parent)) - return m_result; - else - return Defer; - }; -}; - enum OpSys { Os_Windows, @@ -73,6 +46,33 @@ OpSys OpSys_fromString(QString); #endif +enum RuleAction +{ + Allow, + Disallow, + Defer +}; + +RuleAction RuleAction_fromString(QString); + +class Rule +{ +protected: + RuleAction m_result; + virtual bool applies(Library * parent) = 0; +public: + Rule(RuleAction result) + :m_result(result) {} + virtual ~Rule(){}; + RuleAction apply(Library * parent) + { + if(applies(parent)) + return m_result; + else + return Defer; + }; +}; + class OsRule : public Rule { private: @@ -85,9 +85,13 @@ protected: { return (m_system == currentSystem); } -public: OsRule(RuleAction result, OpSys system, QString version_regexp) : Rule(result), m_system(system), m_version_regexp(version_regexp) {} +public: + static QSharedPointer create(RuleAction result, OpSys system, QString version_regexp) + { + return QSharedPointer (new OsRule(result, system, version_regexp)); + } }; class ImplicitRule : public Rule @@ -97,39 +101,119 @@ protected: { return true; } -public: ImplicitRule(RuleAction result) : Rule(result) {} +public: + static QSharedPointer create(RuleAction result) + { + return QSharedPointer (new ImplicitRule(result)); + } }; class Library { +private: + // basic values used internally (so far) + QString m_name; + QString m_base_url; + QList > m_rules; + + // derived values used for real things + /// where to store the lib locally + QString m_storage_path; + /// where to download the lib from + QString m_download_path; + /// is this lib actuall active on the current OS? + bool m_is_active; + + // native lib? + bool m_is_native; + QMap m_native_suffixes; public: - QString base_url; - QString name; - QList > rules; - QMap natives; QStringList extract_excludes; - void AddRule(RuleAction result) +public: + /// finalize the library, processing the input values into derived values and state + void finalize() { - rules.append(QSharedPointer(new ImplicitRule(result))); + QStringList parts = m_name.split(':'); + QString relative = parts[0]; + relative.replace('.','/'); + relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2]; + if(!m_is_native) + relative += ".jar"; + else + { + if(m_native_suffixes.contains(currentSystem)) + { + relative += "-" + m_native_suffixes[currentSystem] + ".jar"; + } + else + { + // really, bad. + relative += ".jar"; + } + } + m_storage_path = relative; + m_download_path = m_base_url + relative; + + if(m_rules.empty()) + { + m_is_active = true; + } + else + { + RuleAction result = Disallow; + for(auto rule: m_rules) + { + RuleAction temp = rule->apply( this ); + if(temp != Defer) + result = temp; + } + m_is_active = (result == Allow); + } + if(m_is_native) + { + m_is_active = m_is_active && m_native_suffixes.contains(currentSystem); + } + }; + + Library(QString name) + { + m_is_native = false; + m_is_native = false; + m_name = name; + m_base_url = "https://s3.amazonaws.com/Minecraft.Download/libraries/"; + } + + void setName(QString name) + { + m_name = name; } - void AddRule(RuleAction result, OpSys system, QString version_regexp) + + void setBaseUrl(QString base_url) { - rules.append(QSharedPointer(new OsRule(result, system, version_regexp))); + m_base_url = base_url; } + + void setIsNative() + { + m_is_native = true; + } + + void addNative(OpSys os, QString suffix) + { + m_is_native = true; + m_native_suffixes[os] = suffix; + } + + void setRules(QList > rules) + { + m_rules = rules; + } + bool applies() { - if(rules.empty()) - return true; - RuleAction result = Disallow; - for(auto rule: rules) - { - RuleAction temp = rule->apply( this ); - if(temp != Defer) - result = temp; - } - return result == Allow; + return m_is_active; } }; diff --git a/libmultimc/src/fullversion.cpp b/libmultimc/src/fullversion.cpp index 6f4662b4..53664c2a 100644 --- a/libmultimc/src/fullversion.cpp +++ b/libmultimc/src/fullversion.cpp @@ -1,4 +1,5 @@ #include #include "fullversion.h" +#include // ECHO, echo, echo, .... \ No newline at end of file diff --git a/libmultimc/src/fullversionfactory.cpp b/libmultimc/src/fullversionfactory.cpp index 9b4ae266..bb55b4a9 100644 --- a/libmultimc/src/fullversionfactory.cpp +++ b/libmultimc/src/fullversionfactory.cpp @@ -2,6 +2,61 @@ #include "fullversion.h" #include +class LibraryFinalizer +{ +public: + LibraryFinalizer(QSharedPointer library) + { + m_library = library; + } + + QSharedPointer m_library; +}; + +// Library rules (if any) +QList > FullVersionFactory::parse4rules(QJsonObject & baseObj) +{ + QList > rules; + auto rulesVal = baseObj.value("rules"); + if(rulesVal.isArray()) + { + QJsonArray ruleList = rulesVal.toArray(); + for(auto ruleVal : ruleList) + { + QSharedPointer rule; + if(!ruleVal.isObject()) + continue; + auto ruleObj = ruleVal.toObject(); + auto actionVal = ruleObj.value("action"); + if(!actionVal.isString()) + continue; + auto action = RuleAction_fromString(actionVal.toString()); + if(action == Defer) + continue; + + auto osVal = ruleObj.value("os"); + if(!osVal.isObject()) + { + // add a new implicit action rule + rules.append(ImplicitRule::create(action)); + } + else + { + auto osObj = osVal.toObject(); + auto osNameVal = osObj.value("name"); + if(!osNameVal.isString()) + continue; + OpSys requiredOs = OpSys_fromString(osNameVal.toString()); + QString versionRegex = osObj.value("version").toString(); + // add a new OS rule + rules.append(OsRule::create(action, requiredOs, versionRegex)); + } + } + } + return rules; +} + + QSharedPointer FullVersionFactory::parse4(QJsonObject root, QSharedPointer fullVersion) { fullVersion->id = root.value("id").toString(); @@ -48,7 +103,6 @@ QSharedPointer FullVersionFactory::parse4(QJsonObject root, QShared QJsonArray libList = root.value("libraries").toArray(); for (auto libVal : libList) { - QSharedPointer library(new Library()); if (!libVal.isObject()) { continue; @@ -60,7 +114,7 @@ QSharedPointer FullVersionFactory::parse4(QJsonObject root, QShared auto nameVal = libObj.value("name"); if(!nameVal.isString()) continue; - library->name = nameVal.toString(); + QSharedPointer library(new Library(nameVal.toString())); // Extract excludes (if any) auto extractVal = libObj.value("extract"); @@ -84,6 +138,7 @@ QSharedPointer FullVersionFactory::parse4(QJsonObject root, QShared auto nativesVal = libObj.value("natives"); if(nativesVal.isObject()) { + library->setIsNative(); auto nativesObj = nativesVal.toObject(); auto iter = nativesObj.begin(); while(iter != nativesObj.end()) @@ -93,50 +148,13 @@ QSharedPointer FullVersionFactory::parse4(QJsonObject root, QShared continue; if(!iter.value().isString()) continue; - library->natives[osType] = iter.value().toString(); + library->addNative(osType, iter.value().toString()); iter++; } } - - // Library rules (if any) - auto rulesVal = libObj.value("rules"); - if(rulesVal.isArray()) - { - QList > rules; - - QJsonArray ruleList = rulesVal.toArray(); - for(auto ruleVal : ruleList) - { - QSharedPointer rule; - if(!ruleVal.isObject()) - continue; - auto ruleObj = ruleVal.toObject(); - auto actionVal = ruleObj.value("action"); - if(!actionVal.isString()) - continue; - auto action = RuleAction_fromString(actionVal.toString()); - if(action == Defer) - continue; - - auto osVal = ruleObj.value("os"); - if(!osVal.isObject()) - { - rule.reset(new ImplicitRule(action)); - } - else - { - auto osObj = osVal.toObject(); - auto osNameVal = osObj.value("name"); - if(!osNameVal.isString()) - continue; - OpSys requiredOs = OpSys_fromString(osNameVal.toString()); - QString versionRegex = osObj.value("version").toString(); - rule.reset(new OsRule(action, requiredOs, versionRegex)); - } - rules.append(rule); - } - library->rules = rules; - } + library->setRules(parse4rules(libObj)); + library->finalize(); + fullVersion->libraries.append(library); } return fullVersion; } diff --git a/libmultimc/src/gameupdatetask.cpp b/libmultimc/src/gameupdatetask.cpp index 61880118..bae85c17 100644 --- a/libmultimc/src/gameupdatetask.cpp +++ b/libmultimc/src/gameupdatetask.cpp @@ -141,6 +141,7 @@ void GameUpdateTask::jarlibFinished() { m_inst->setCurrentVersion(targetVersion->descriptor()); m_inst->setShouldUpdate(false); + m_inst->setIsForNewLauncher(true); exit(1); } @@ -195,6 +196,7 @@ void GameUpdateTask::legacyJarFinished() { setState(StateFinished); emit gameUpdateComplete(m_response); + m_inst->setIsForNewLauncher(true); exit(1); } diff --git a/libmultimc/src/instance.cpp b/libmultimc/src/instance.cpp index c1506a02..5fdb5064 100644 --- a/libmultimc/src/instance.cpp +++ b/libmultimc/src/instance.cpp @@ -34,6 +34,7 @@ Instance::Instance(const QString &rootDir, QObject *parent) : settings().registerSetting(new Setting("iconKey", "default")); settings().registerSetting(new Setting("notes", "")); settings().registerSetting(new Setting("NeedsRebuild", true)); + settings().registerSetting(new Setting("IsForNewLauncher", false)); settings().registerSetting(new Setting("ShouldUpdate", false)); settings().registerSetting(new Setting("JarVersion", "Unknown")); settings().registerSetting(new Setting("LwjglVersion", "2.9.0")); diff --git a/libmultimc/src/library.cpp b/libmultimc/src/library.cpp index 0fb4f9d3..9d4cc6e3 100644 --- a/libmultimc/src/library.cpp +++ b/libmultimc/src/library.cpp @@ -34,4 +34,4 @@ OpSys OpSys_fromString(QString name) return Os_OSX; return Os_Other; } -// default url for lib: https://s3.amazonaws.com/Minecraft.Download/libraries/ +// default url for lib: -- cgit