diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-09-06 18:16:56 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-09-06 19:03:05 +0200 |
commit | 20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c (patch) | |
tree | 56bf51e681f2e73590a549499bd83d7b505c39f8 /logic/minecraft | |
parent | 36efcf8d3c0cbd7823fc65569cfc2b011435db2c (diff) | |
download | MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.gz MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.lz MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.tar.xz MultiMC-20cb97a35af5097e9d3b2062c0dfcb5f2e5fff5c.zip |
Sync from quickmods
Diffstat (limited to 'logic/minecraft')
-rw-r--r-- | logic/minecraft/InstanceVersion.cpp | 8 | ||||
-rw-r--r-- | logic/minecraft/InstanceVersion.h | 6 | ||||
-rw-r--r-- | logic/minecraft/MinecraftVersionList.cpp | 13 | ||||
-rw-r--r-- | logic/minecraft/OneSixLibrary.h | 1 | ||||
-rw-r--r-- | logic/minecraft/VersionBuilder.cpp | 5 | ||||
-rw-r--r-- | logic/minecraft/VersionFile.cpp | 10 |
6 files changed, 24 insertions, 19 deletions
diff --git a/logic/minecraft/InstanceVersion.cpp b/logic/minecraft/InstanceVersion.cpp index c345e1fb..a243ebf4 100644 --- a/logic/minecraft/InstanceVersion.cpp +++ b/logic/minecraft/InstanceVersion.cpp @@ -264,6 +264,14 @@ QList<std::shared_ptr<OneSixLibrary> > InstanceVersion::getActiveNormalLibs() { if (lib->isActive() && !lib->isNative()) { + for (auto other : output) + { + if (other->rawName() == lib->rawName()) + { + QLOG_WARN() << "Multiple libraries with name" << lib->rawName() << "in library list!"; + continue; + } + } output.append(lib); } } diff --git a/logic/minecraft/InstanceVersion.h b/logic/minecraft/InstanceVersion.h index 6b69ab47..664e4242 100644 --- a/logic/minecraft/InstanceVersion.h +++ b/logic/minecraft/InstanceVersion.h @@ -140,10 +140,10 @@ public: QString appletClass; /// the list of libs - both active and inactive, native and java - QList<std::shared_ptr<OneSixLibrary>> libraries; - + QList<OneSixLibraryPtr> libraries; + /// same, but only vanilla. - QList<std::shared_ptr<OneSixLibrary>> vanillaLibraries; + QList<OneSixLibraryPtr> vanillaLibraries; /// traits, collected from all the version files (version files can only add) QSet<QString> traits; diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp index bde2170b..598fecdb 100644 --- a/logic/minecraft/MinecraftVersionList.cpp +++ b/logic/minecraft/MinecraftVersionList.cpp @@ -116,15 +116,10 @@ void MinecraftVersionList::loadBuiltinList() { QLOG_INFO() << "Loading builtin version list."; // grab the version list data from internal resources. - QResource versionList(":/versions/minecraft.json"); - QFile filez(versionList.absoluteFilePath()); - filez.open(QIODevice::ReadOnly); - auto data = filez.readAll(); - - // parse the data as json - QJsonParseError jsonError; - QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &jsonError); - QJsonObject root = jsonDoc.object(); + const QJsonDocument doc = + MMCJson::parseFile(":/versions/minecraft.json", + "builtin version list"); + const QJsonObject root = doc.object(); // parse all the versions for (const auto version : MMCJson::ensureArray(root.value("versions"))) diff --git a/logic/minecraft/OneSixLibrary.h b/logic/minecraft/OneSixLibrary.h index 2f60405a..1d2ac0cb 100644 --- a/logic/minecraft/OneSixLibrary.h +++ b/logic/minecraft/OneSixLibrary.h @@ -48,5 +48,4 @@ public: /// Constructor OneSixLibrary(RawLibraryPtr base); static OneSixLibraryPtr fromRawLibrary(RawLibraryPtr lib); - }; diff --git a/logic/minecraft/VersionBuilder.cpp b/logic/minecraft/VersionBuilder.cpp index dbaf5257..09f761a4 100644 --- a/logic/minecraft/VersionBuilder.cpp +++ b/logic/minecraft/VersionBuilder.cpp @@ -288,6 +288,11 @@ static const int currentOrderFileVersion = 1; bool VersionBuilder::readOverrideOrders(OneSixInstance *instance, PatchOrder &order) { QFile orderFile(instance->instanceRoot() + "/order.json"); + if (!orderFile.exists()) + { + QLOG_WARN() << "Order file doesn't exist. Ignoring."; + return false; + } if (!orderFile.open(QFile::ReadOnly)) { QLOG_ERROR() << "Couldn't open" << orderFile.fileName() diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp index 778c5a27..311271fe 100644 --- a/logic/minecraft/VersionFile.cpp +++ b/logic/minecraft/VersionFile.cpp @@ -22,8 +22,7 @@ int findLibraryByName(QList<OneSixLibraryPtr> haystack, const GradleSpecifier &n int retval = -1; for (int i = 0; i < haystack.size(); ++i) { - - if(haystack.at(i)->rawName().matchName(needle)) + if (haystack.at(i)->rawName().matchName(needle)) { // only one is allowed. if (retval != -1) @@ -67,7 +66,7 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi out->mcVersion = root.value("mcVersion").toString(); out->filename = filename; - auto readString = [root](const QString & key, QString & variable) + auto readString = [root](const QString &key, QString &variable) { if (root.contains(key)) { @@ -75,15 +74,14 @@ VersionFilePtr VersionFile::fromJson(const QJsonDocument &doc, const QString &fi } }; - auto readStringRet = [root](const QString & key)->QString + auto readStringRet = [root](const QString &key) -> QString { if (root.contains(key)) { return ensureString(root.value(key)); } return QString(); - } - ; + }; // FIXME: This should be ignored when applying. if (!isFTB) |