summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-03-19 23:58:54 +0100
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:20:02 +0200
commitf557c1367994a61935fa0e8d0b1b67688d2692d0 (patch)
tree8eff9809b158cd1e65ba0eadc2b1c140b78c4e8b /api
parent2660418d58efb33cd3a0ab8ed9d48c359c076905 (diff)
downloadMultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.gz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.lz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.tar.xz
MultiMC-f557c1367994a61935fa0e8d0b1b67688d2692d0.zip
NOISSUE stuff and things happened. Maybe.
Diffstat (limited to 'api')
-rw-r--r--api/logic/BaseVersionList.h13
-rw-r--r--api/logic/java/JavaInstallList.cpp2
-rw-r--r--api/logic/java/JavaInstallList.h18
-rw-r--r--api/logic/meta/BaseEntity.cpp8
-rw-r--r--api/logic/meta/Index_test.cpp2
-rw-r--r--api/logic/meta/Version.cpp12
-rw-r--r--api/logic/meta/Version.h82
-rw-r--r--api/logic/meta/VersionList.cpp8
-rw-r--r--api/logic/meta/VersionList.h2
-rw-r--r--api/logic/minecraft/MinecraftInstance.cpp4
-rw-r--r--api/logic/minecraft/MojangVersionFormat.cpp2
-rw-r--r--api/logic/minecraft/ProfilePatch.h2
-rw-r--r--api/logic/minecraft/ProfileUtils.cpp2
-rw-r--r--api/logic/minecraft/VersionFile.cpp9
-rw-r--r--api/logic/minecraft/VersionFile.h17
-rw-r--r--api/logic/minecraft/ftb/FTBProfileStrategy.cpp4
-rw-r--r--api/logic/minecraft/legacy/LwjglVersionList.cpp5
-rw-r--r--api/logic/minecraft/legacy/LwjglVersionList.h4
-rw-r--r--api/logic/minecraft/onesix/OneSixProfileStrategy.cpp130
-rw-r--r--api/logic/minecraft/onesix/OneSixVersionFormat.cpp20
20 files changed, 186 insertions, 160 deletions
diff --git a/api/logic/BaseVersionList.h b/api/logic/BaseVersionList.h
index eadc6933..8afcae1d 100644
--- a/api/logic/BaseVersionList.h
+++ b/api/logic/BaseVersionList.h
@@ -22,6 +22,7 @@
#include "BaseVersion.h"
#include "tasks/Task.h"
#include "multimc_logic_export.h"
+#include "QObjectPtr.h"
/*!
* \brief Class that each instance type's version list derives from.
@@ -63,7 +64,7 @@ public:
* The task returned by this function should reset the model when it's done.
* \return A pointer to a task that reloads the version list.
*/
- virtual Task *getLoadTask() = 0;
+ virtual shared_qobject_ptr<Task> getLoadTask() = 0;
//! Checks whether or not the list is loaded. If this returns false, the list should be
//loaded.
@@ -76,17 +77,17 @@ public:
virtual int count() const = 0;
//////// List Model Functions ////////
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual int rowCount(const QModelIndex &parent) const;
- virtual int columnCount(const QModelIndex &parent) const;
- virtual QHash<int, QByteArray> roleNames() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ int columnCount(const QModelIndex &parent) const override;
+ virtual QHash<int, QByteArray> roleNames() const;
//! which roles are provided by this version list?
virtual RoleList providesRoles() const;
/*!
* \brief Finds a version by its descriptor.
- * \param The descriptor of the version to find.
+ * \param descriptor The descriptor of the version to find.
* \return A const pointer to the version with the given descriptor. NULL if
* one doesn't exist.
*/
diff --git a/api/logic/java/JavaInstallList.cpp b/api/logic/java/JavaInstallList.cpp
index c98ef279..dbf66f5f 100644
--- a/api/logic/java/JavaInstallList.cpp
+++ b/api/logic/java/JavaInstallList.cpp
@@ -29,7 +29,7 @@ JavaInstallList::JavaInstallList(QObject *parent) : BaseVersionList(parent)
{
}
-Task *JavaInstallList::getLoadTask()
+shared_qobject_ptr<Task> JavaInstallList::getLoadTask()
{
return new JavaListLoadTask(this);
}
diff --git a/api/logic/java/JavaInstallList.h b/api/logic/java/JavaInstallList.h
index 2055d154..afc5ef43 100644
--- a/api/logic/java/JavaInstallList.h
+++ b/api/logic/java/JavaInstallList.h
@@ -34,17 +34,17 @@ class MULTIMC_LOGIC_EXPORT JavaInstallList : public BaseVersionList
public:
explicit JavaInstallList(QObject *parent = 0);
- 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;
+ shared_qobject_ptr<Task> getLoadTask() override;
+ bool isLoaded() override;
+ const BaseVersionPtr at(int i) const override;
+ int count() const override;
+ void sortVersions() override;
- virtual QVariant data(const QModelIndex &index, int role) const override;
- virtual RoleList providesRoles() const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ RoleList providesRoles() const override;
public slots:
- virtual void updateListData(QList<BaseVersionPtr> versions) override;
+ void updateListData(QList<BaseVersionPtr> versions) override;
protected:
QList<BaseVersionPtr> m_vlist;
@@ -60,7 +60,7 @@ public:
explicit JavaListLoadTask(JavaInstallList *vlist);
~JavaListLoadTask();
- virtual void executeTask();
+ void executeTask() override;
public slots:
void javaCheckerFinished(QList<JavaCheckResult> results);
diff --git a/api/logic/meta/BaseEntity.cpp b/api/logic/meta/BaseEntity.cpp
index 809f88cb..633afab2 100644
--- a/api/logic/meta/BaseEntity.cpp
+++ b/api/logic/meta/BaseEntity.cpp
@@ -101,16 +101,20 @@ bool Meta::BaseEntity::loadLocalFile()
void Meta::BaseEntity::load()
{
+ // load local file if nothing is loaded yet
if(!isLoaded())
{
- loadLocalFile();
+ if(loadLocalFile())
+ {
+ m_loadStatus = LoadStatus::Local;
+ }
}
+ // if we need remote update, run the update task
if(!shouldStartRemoteUpdate())
{
return;
}
NetJob *job = new NetJob(QObject::tr("Download of meta file %1").arg(localFilename()));
-
auto url = this->url();
auto entry = ENV.metacache()->resolveEntry("meta", localFilename());
entry->setStale(true);
diff --git a/api/logic/meta/Index_test.cpp b/api/logic/meta/Index_test.cpp
index d4343c37..1c5face2 100644
--- a/api/logic/meta/Index_test.cpp
+++ b/api/logic/meta/Index_test.cpp
@@ -23,7 +23,7 @@ slots:
QVERIFY(!windex.hasUid("asdf"));
QVERIFY(windex.get("list2") != nullptr);
QCOMPARE(windex.get("list2")->uid(), QString("list2"));
- QVERIFY(windex.get("adsf") == nullptr);
+ QVERIFY(windex.get("adsf") != nullptr);
}
void test_merge()
diff --git a/api/logic/meta/Version.cpp b/api/logic/meta/Version.cpp
index 2790b2f3..fee7d049 100644
--- a/api/logic/meta/Version.cpp
+++ b/api/logic/meta/Version.cpp
@@ -20,14 +20,6 @@
#include "JsonFormat.h"
#include "minecraft/MinecraftProfile.h"
-void Meta::Version::applyTo(MinecraftProfile* profile)
-{
- if(m_data)
- {
- m_data->applyTo(profile);
- }
-}
-
Meta::Version::Version(const QString &uid, const QString &version)
: BaseVersion(), m_uid(uid), m_version(version)
{
@@ -39,7 +31,9 @@ QString Meta::Version::descriptor()
}
QString Meta::Version::name()
{
- return m_version;
+ if(m_data)
+ return m_data->getName();
+ return m_uid;
}
QString Meta::Version::typeString() const
{
diff --git a/api/logic/meta/Version.h b/api/logic/meta/Version.h
index b8ea7e44..b3943f47 100644
--- a/api/logic/meta/Version.h
+++ b/api/logic/meta/Version.h
@@ -33,7 +33,7 @@ namespace Meta
{
using VersionPtr = std::shared_ptr<class Version>;
-class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity, public ProfilePatch
+class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public BaseEntity
{
Q_OBJECT
Q_PROPERTY(QString uid READ uid CONSTANT)
@@ -45,85 +45,6 @@ class MULTIMC_LOGIC_EXPORT Version : public QObject, public BaseVersion, public
public: /* con/des */
explicit Version(const QString &uid, const QString &version);
-// FIXME: none of this belongs here...
-public: /* ProfilePatch overrides */
- QString getFilename() override
- {
- return QString();
- }
- QString getID() override
- {
- return m_uid;
- }
- QList<JarmodPtr> getJarMods() override
- {
- return {};
- }
- QString getName() override
- {
- return name();
- }
- QDateTime getReleaseDateTime() override
- {
- return time();
- }
- QString getVersion() override
- {
- return m_version;
- }
- std::shared_ptr<class VersionFile> getVersionFile() override
- {
- return m_data;
- }
- int getOrder() override
- {
- return 0;
- }
- VersionSource getVersionSource() override
- {
- return VersionSource::Local;
- }
- bool isVersionChangeable() override
- {
- return true;
- }
- bool isRevertible() override
- {
- return false;
- }
- bool isRemovable() override
- {
- return true;
- }
- bool isCustom() override
- {
- return false;
- }
- bool isCustomizable() override
- {
- return true;
- }
- bool isMoveable() override
- {
- return true;
- }
- bool isEditable() override
- {
- return false;
- }
- void setOrder(int) override
- {
- }
- bool hasJarMods() override
- {
- return false;
- }
- bool isMinecraftVersion() override
- {
- return m_uid == "net.minecraft";
- }
- void applyTo(MinecraftProfile * profile) override;
-
QString descriptor() override;
QString name() override;
QString typeString() const override;
@@ -153,6 +74,7 @@ signals:
void requiresChanged();
private:
+ QString m_name;
QString m_uid;
QString m_version;
QString m_type;
diff --git a/api/logic/meta/VersionList.cpp b/api/logic/meta/VersionList.cpp
index d6bbf70f..28d9dd26 100644
--- a/api/logic/meta/VersionList.cpp
+++ b/api/logic/meta/VersionList.cpp
@@ -29,15 +29,15 @@ VersionList::VersionList(const QString &uid, QObject *parent)
setObjectName("Version list: " + uid);
}
-Task *VersionList::getLoadTask()
+shared_qobject_ptr<Task> VersionList::getLoadTask()
{
- // TODO: create a wrapper task that will chain from root to here.
- return nullptr;
+ load();
+ return getCurrentTask();
}
bool VersionList::isLoaded()
{
- return isLoaded();
+ return BaseEntity::isLoaded();
}
const BaseVersionPtr VersionList::at(int i) const
diff --git a/api/logic/meta/VersionList.h b/api/logic/meta/VersionList.h
index 26fa6c5a..08d71230 100644
--- a/api/logic/meta/VersionList.h
+++ b/api/logic/meta/VersionList.h
@@ -41,7 +41,7 @@ public:
VersionPtrRole
};
- Task *getLoadTask() override;
+ shared_qobject_ptr<Task> getLoadTask() override;
bool isLoaded() override;
const BaseVersionPtr at(int i) const override;
int count() const override;
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp
index b88d0c2a..cb080bfe 100644
--- a/api/logic/minecraft/MinecraftInstance.cpp
+++ b/api/logic/minecraft/MinecraftInstance.cpp
@@ -20,6 +20,8 @@
#include "minecraft/launch/ModMinecraftJar.h"
#include "minecraft/launch/ClaimAccount.h"
#include "java/launch/CheckJava.h"
+#include <meta/Index.h>
+#include <meta/VersionList.h>
#include <icons/IIconList.h>
@@ -105,7 +107,7 @@ QString MinecraftInstance::binRoot() const
std::shared_ptr< BaseVersionList > MinecraftInstance::versionList() const
{
- return ENV.getVersionList("net.minecraft");
+ return ENV.metadataIndex()->get("net.minecraft");
}
QStringList MinecraftInstance::javaArguments() const
diff --git a/api/logic/minecraft/MojangVersionFormat.cpp b/api/logic/minecraft/MojangVersionFormat.cpp
index 1312421f..651e2fbc 100644
--- a/api/logic/minecraft/MojangVersionFormat.cpp
+++ b/api/logic/minecraft/MojangVersionFormat.cpp
@@ -210,7 +210,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
readVersionProperties(root, out.get());
out->name = "Minecraft";
- out->fileId = "net.minecraft";
+ out->uid = "net.minecraft";
out->version = out->minecraftVersion;
out->filename = filename;
diff --git a/api/logic/minecraft/ProfilePatch.h b/api/logic/minecraft/ProfilePatch.h
index b61fb8b3..6f63f3c4 100644
--- a/api/logic/minecraft/ProfilePatch.h
+++ b/api/logic/minecraft/ProfilePatch.h
@@ -51,8 +51,6 @@ public:
virtual void applyTo(MinecraftProfile *profile) = 0;
virtual bool isMinecraftVersion() = 0;
- virtual bool hasJarMods() = 0;
- virtual QList<JarmodPtr> getJarMods() = 0;
virtual bool isMoveable() = 0;
virtual bool isCustomizable() = 0;
diff --git a/api/logic/minecraft/ProfileUtils.cpp b/api/logic/minecraft/ProfileUtils.cpp
index ef9b3b28..c7c56dd6 100644
--- a/api/logic/minecraft/ProfileUtils.cpp
+++ b/api/logic/minecraft/ProfileUtils.cpp
@@ -102,7 +102,7 @@ bool readOverrideOrders(QString path, PatchOrder &order)
static VersionFilePtr createErrorVersionFile(QString fileId, QString filepath, QString error)
{
auto outError = std::make_shared<VersionFile>();
- outError->fileId = outError->name = fileId;
+ outError->uid = outError->name = fileId;
outError->filename = filepath;
outError->addProblem(PROBLEM_ERROR, error);
return outError;
diff --git a/api/logic/minecraft/VersionFile.cpp b/api/logic/minecraft/VersionFile.cpp
index 573c4cb4..17dc6a49 100644
--- a/api/logic/minecraft/VersionFile.cpp
+++ b/api/logic/minecraft/VersionFile.cpp
@@ -14,12 +14,7 @@
bool VersionFile::isMinecraftVersion()
{
- return fileId == "net.minecraft";
-}
-
-bool VersionFile::hasJarMods()
-{
- return !jarMods.isEmpty();
+ return uid == "net.minecraft";
}
void VersionFile::applyTo(MinecraftProfile *profile)
@@ -29,7 +24,7 @@ void VersionFile::applyTo(MinecraftProfile *profile)
{
if (QRegExp(dependsOnMinecraftVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
{
- throw MinecraftVersionMismatch(fileId, dependsOnMinecraftVersion, theirVersion);
+ throw MinecraftVersionMismatch(uid, dependsOnMinecraftVersion, theirVersion);
}
}
profile->applyMinecraftVersion(minecraftVersion);
diff --git a/api/logic/minecraft/VersionFile.h b/api/logic/minecraft/VersionFile.h
index 249d0965..6a922d74 100644
--- a/api/logic/minecraft/VersionFile.h
+++ b/api/logic/minecraft/VersionFile.h
@@ -25,7 +25,6 @@ class VersionFile : public ProfilePatch
public: /* methods */
virtual void applyTo(MinecraftProfile *profile) override;
virtual bool isMinecraftVersion() override;
- virtual bool hasJarMods() override;
virtual int getOrder() override
{
return order;
@@ -34,13 +33,9 @@ public: /* methods */
{
this->order = order;
}
- virtual QList<JarmodPtr> getJarMods() override
- {
- return jarMods;
- }
virtual QString getID() override
{
- return fileId;
+ return uid;
}
virtual QString getName() override
{
@@ -120,9 +115,6 @@ public: /* methods */
public: /* data */
- /// MultiMC: order hint for this version file if no explicit order is set
- int order = 0;
-
// Flags for UI and version file manipulation in general
bool m_isVanilla = false;
bool m_isRemovable = false;
@@ -130,6 +122,9 @@ public: /* data */
bool m_isCustomizable = false;
bool m_isMovable = false;
+ /// MultiMC: order hint for this version file if no explicit order is set
+ int order = 0;
+
/// MultiMC: filename of the file this was loaded from
QString filename;
@@ -137,7 +132,7 @@ public: /* data */
QString name;
/// MultiMC: package ID of this package
- QString fileId;
+ QString uid;
/// MultiMC: version of this package
QString version;
@@ -191,5 +186,3 @@ public:
// Mojang: extended asset index download information
std::shared_ptr<MojangAssetIndexInfo> mojangAssetIndex;
};
-
-
diff --git a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp
index 92a1555a..45765cd4 100644
--- a/api/logic/minecraft/ftb/FTBProfileStrategy.cpp
+++ b/api/logic/minecraft/ftb/FTBProfileStrategy.cpp
@@ -27,7 +27,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
if(QFile::exists(mcJson))
{
auto file = ProfileUtils::parseJsonFile(QFileInfo(mcJson), false);
- file->fileId = "net.minecraft";
+ file->uid = "net.minecraft";
file->name = QObject::tr("Minecraft (tracked)");
file->setVanilla(true);
if(file->version.isEmpty())
@@ -64,7 +64,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
addLib->setHint("local");
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
}
- file->fileId = "org.multimc.ftb.pack";
+ file->uid = "org.multimc.ftb.pack";
file->setVanilla(true);
file->name = QObject::tr("%1 (FTB pack)").arg(m_instance->name());
if(file->version.isEmpty())
diff --git a/api/logic/minecraft/legacy/LwjglVersionList.cpp b/api/logic/minecraft/legacy/LwjglVersionList.cpp
index 7f4e7b38..3d7ad2d4 100644
--- a/api/logic/minecraft/legacy/LwjglVersionList.cpp
+++ b/api/logic/minecraft/legacy/LwjglVersionList.cpp
@@ -99,6 +99,7 @@ inline QDomElement getDomElementByTagName(QDomElement parent, QString tagname)
void LWJGLVersionList::rssFailed(const QString& reason)
{
+ m_rssDLJob.reset();
m_loading = false;
qWarning() << "Failed to load LWJGL list. Network error: " + reason;
}
@@ -116,8 +117,9 @@ void LWJGLVersionList::rssSucceeded()
if (!doc.setContent(m_rssData, false, &xmlErrorMsg, &errorLine))
{
qWarning() << "Failed to load LWJGL list. XML error: " + xmlErrorMsg + " at line " + QString::number(errorLine);
- m_loading = false;
+ m_rssDLJob.reset();
m_rssData.clear();
+ m_loading = false;
return;
}
m_rssData.clear();
@@ -162,5 +164,6 @@ void LWJGLVersionList::rssSucceeded()
endResetModel();
qDebug() << "Loaded LWJGL list.";
+ m_rssDLJob.reset();
m_loading = false;
}
diff --git a/api/logic/minecraft/legacy/LwjglVersionList.h b/api/logic/minecraft/legacy/LwjglVersionList.h
index 652a3fda..f5312e2c 100644
--- a/api/logic/minecraft/legacy/LwjglVersionList.h
+++ b/api/logic/minecraft/legacy/LwjglVersionList.h
@@ -78,9 +78,9 @@ public:
return m_vlist[i];
}
- virtual Task* getLoadTask() override
+ virtual shared_qobject_ptr<Task> getLoadTask() override
{
- return nullptr;
+ return m_rssDLJob;
}
virtual void sortVersions() override {};
diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
index b19a2dea..3a9b10e6 100644
--- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
+++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
@@ -56,7 +56,7 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
}
auto file = ProfileUtils::parseJsonFile(QFileInfo(sourceFile), false);
ProfileUtils::removeLwjglFromPatch(file);
- file->fileId = "net.minecraft";
+ file->uid = "net.minecraft";
file->version = file->minecraftVersion;
file->name = "Minecraft";
auto data = OneSixVersionFormat::versionFileToJson(file, false).toJson();
@@ -81,6 +81,107 @@ void OneSixProfileStrategy::upgradeDeprecatedFiles()
}
}
+class MetaPatchProvider : public ProfilePatch
+{
+public: /* con/des */
+ MetaPatchProvider(std::shared_ptr<Meta::Version> data)
+ :m_version(data)
+ {
+ }
+public:
+ QString getFilename() override
+ {
+ return QString();
+ }
+ QString getID() override
+ {
+ return m_version->uid();
+ }
+ QString getName() override
+ {
+ auto vfile = getFile();
+ if(vfile)
+ {
+ return vfile->getName();
+ }
+ return m_version->name();
+ }
+ QDateTime getReleaseDateTime() override
+ {
+ return m_version->time();
+ }
+ QString getVersion() override
+ {
+ return m_version->version();
+ }
+ std::shared_ptr<class VersionFile> getVersionFile() override
+ {
+ return m_version->data();
+ }
+ void setOrder(int) override
+ {
+ }
+ int getOrder() override
+ {
+ return 0;
+ }
+ VersionSource getVersionSource() override
+ {
+ return VersionSource::Local;
+ }
+ bool isVersionChangeable() override
+ {
+ return true;
+ }
+ bool isRevertible() override
+ {
+ return false;
+ }
+ bool isRemovable() override
+ {
+ return true;
+ }
+ bool isCustom() override
+ {
+ return false;
+ }
+ bool isCustomizable() override
+ {
+ return true;
+ }
+ bool isMoveable() override
+ {
+ return true;
+ }
+ bool isEditable() override
+ {
+ return false;
+ }
+ bool isMinecraftVersion() override
+ {
+ return getID() == "net.minecraft";
+ }
+ void applyTo(MinecraftProfile * profile) override
+ {
+ auto vfile = getFile();
+ if(vfile)
+ {
+ vfile->applyTo(profile);
+ }
+ }
+private:
+ VersionFilePtr getFile()
+ {
+ if(!m_version->isLoaded())
+ {
+ m_version->load();
+ }
+ return m_version->data();
+ }
+private:
+ std::shared_ptr<Meta::Version> m_version;
+};
+
void OneSixProfileStrategy::loadDefaultBuiltinPatches()
{
{
@@ -101,7 +202,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
else
{
auto mcversion = ENV.metadataIndex()->get("net.minecraft", m_instance->intendedVersionId());
- minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(mcversion);
+ minecraftPatch = std::make_shared<MetaPatchProvider>(mcversion);
}
if (!minecraftPatch)
{
@@ -124,7 +225,7 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
else
{
auto lwjglversion = ENV.metadataIndex()->get("org.lwjgl", "2.9.1");
- lwjglPatch = std::dynamic_pointer_cast<ProfilePatch>(lwjglversion);
+ lwjglPatch = std::make_shared<MetaPatchProvider>(lwjglversion);
}
if (!lwjglPatch)
{
@@ -162,10 +263,10 @@ void OneSixProfileStrategy::loadUserPatches()
qDebug() << "Reading" << filename << "by user order";
VersionFilePtr file = ProfileUtils::parseJsonFile(finfo, false);
// sanity check. prevent tampering with files.
- if (file->fileId != id)
+ if (file->uid != id)
{
- file->addProblem(PROBLEM_WARNING, QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId));
- seen_extra.insert(file->fileId);
+ file->addProblem(PROBLEM_WARNING, QObject::tr("load id %1 does not match internal id %2").arg(id, file->uid));
+ seen_extra.insert(file->uid);
}
file->setRemovable(true);
file->setMovable(true);
@@ -185,15 +286,15 @@ void OneSixProfileStrategy::loadUserPatches()
qDebug() << "Reading" << info.fileName();
auto file = ProfileUtils::parseJsonFile(info, true);
// ignore builtins
- if (file->fileId == "net.minecraft")
+ if (file->uid == "net.minecraft")
continue;
- if (file->fileId == "org.lwjgl")
+ if (file->uid == "org.lwjgl")
continue;
// do not load versions with broken IDs twice
- if(seen_extra.contains(file->fileId))
+ if(seen_extra.contains(file->uid))
continue;
// do not load what we already loaded in the first pass
- if (userOrder.contains(file->fileId))
+ if (userOrder.contains(file->uid))
continue;
file->setRemovable(true);
file->setMovable(true);
@@ -203,7 +304,7 @@ void OneSixProfileStrategy::loadUserPatches()
file->assets = QString();
file->mojangAssetIndex.reset();
// HACK
- files.insert(file->order, file);
+ files.insert(file->getOrder(), file);
}
QSet<int> seen;
for (auto order : files.keys())
@@ -284,7 +385,8 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
return true;
};
- for(auto &jarmod: patch->getJarMods())
+ auto &jarMods = patch->getVersionFile()->jarMods;
+ for(auto &jarmod: jarMods)
{
ok &= preRemoveJarMod(jarmod);
}
@@ -404,8 +506,8 @@ bool OneSixProfileStrategy::installJarMods(QStringList filepaths)
jarMod->originalName = sourceInfo.completeBaseName();
f->jarMods.append(jarMod);
f->name = target_name;
- f->fileId = target_id;
- f->order = profile->getFreeOrderNumber();
+ f->uid = target_id;
+ f->setOrder(profile->getFreeOrderNumber());
QString patchFileName = FS::PathCombine(patchDir, target_id + ".json");
f->filename = patchFileName;
f->setMovable(true);
diff --git a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
index 403eb112..944e68a4 100644
--- a/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
+++ b/api/logic/minecraft/onesix/OneSixVersionFormat.cpp
@@ -51,7 +51,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
{
if (root.contains("order"))
{
- out->order = requireInteger(root.value("order"));
+ out->setOrder(requireInteger(root.value("order")));
}
else
{
@@ -61,7 +61,16 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
}
out->name = root.value("name").toString();
- out->fileId = root.value("fileId").toString();
+
+ if(root.contains("uid"))
+ {
+ out->uid = root.value("uid").toString();
+ }
+ else
+ {
+ out->uid = root.value("fileId").toString();
+ }
+
out->version = root.value("version").toString();
out->dependsOnMinecraftVersion = root.value("mcVersion").toString();
out->filename = filename;
@@ -161,10 +170,13 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
QJsonObject root;
if (saveOrder)
{
- root.insert("order", patch->order);
+ root.insert("order", patch->getOrder());
}
writeString(root, "name", patch->name);
- writeString(root, "fileId", patch->fileId);
+
+ writeString(root, "uid", patch->uid);
+ writeString(root, "fileId", patch->uid);
+
writeString(root, "version", patch->version);
writeString(root, "mcVersion", patch->dependsOnMinecraftVersion);