summaryrefslogtreecommitdiffstats
path: root/logic/minecraft
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2015-05-28 19:38:29 +0200
committerPetr Mrázek <peterix@gmail.com>2015-06-06 21:23:05 +0200
commit3a8b238052163952831fb5924b2483a375e86ebd (patch)
treeab120b4fac3a5345a20e7a09e1e7477e67d9ed6f /logic/minecraft
parent161dc66c2c8d5f973ee69dab36c3969a7efd7495 (diff)
downloadMultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar
MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar.gz
MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar.lz
MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.tar.xz
MultiMC-3a8b238052163952831fb5924b2483a375e86ebd.zip
NOISSUE Various changes from multiauth that are unrelated to it
Diffstat (limited to 'logic/minecraft')
-rw-r--r--logic/minecraft/JarMod.cpp4
-rw-r--r--logic/minecraft/MinecraftProfile.cpp7
-rw-r--r--logic/minecraft/MinecraftVersionList.cpp31
-rw-r--r--logic/minecraft/OneSixInstance.cpp3
-rw-r--r--logic/minecraft/OneSixProfileStrategy.cpp4
-rw-r--r--logic/minecraft/OneSixUpdate.cpp3
-rw-r--r--logic/minecraft/ParseUtils.cpp1
-rw-r--r--logic/minecraft/ProfileUtils.cpp10
-rw-r--r--logic/minecraft/RawLibrary.cpp6
-rw-r--r--logic/minecraft/VersionBuildError.h8
-rw-r--r--logic/minecraft/VersionFile.cpp4
-rw-r--r--logic/minecraft/VersionFile.h3
12 files changed, 42 insertions, 42 deletions
diff --git a/logic/minecraft/JarMod.cpp b/logic/minecraft/JarMod.cpp
index bf711c1f..bf985707 100644
--- a/logic/minecraft/JarMod.cpp
+++ b/logic/minecraft/JarMod.cpp
@@ -1,6 +1,6 @@
#include "JarMod.h"
-#include "MMCJson.h"
-using namespace MMCJson;
+#include "Json.h"
+using namespace Json;
JarmodPtr Jarmod::fromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
{
diff --git a/logic/minecraft/MinecraftProfile.cpp b/logic/minecraft/MinecraftProfile.cpp
index 0661aec1..1baf008e 100644
--- a/logic/minecraft/MinecraftProfile.cpp
+++ b/logic/minecraft/MinecraftProfile.cpp
@@ -17,12 +17,13 @@
#include <QDir>
#include <QJsonDocument>
#include <QJsonArray>
+#include <QDebug>
#include <pathutils.h>
#include "minecraft/MinecraftProfile.h"
#include "ProfileUtils.h"
#include "NullProfileStrategy.h"
-#include "VersionBuildError.h"
+#include "Exception.h"
MinecraftProfile::MinecraftProfile(ProfileStrategy *strategy)
: QAbstractListModel()
@@ -277,7 +278,7 @@ std::shared_ptr<MinecraftProfile> MinecraftProfile::fromJson(const QJsonObject &
file->applyTo(version.get());
version->appendPatch(file);
}
- catch(MMCError & err)
+ catch(Exception &err)
{
return 0;
}
@@ -424,7 +425,7 @@ bool MinecraftProfile::reapplySafe()
{
reapply();
}
- catch(MMCError & error)
+ catch (Exception & error)
{
clear();
qWarning() << "Couldn't apply profile patches because: " << error.cause();
diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp
index c20534e9..44be281b 100644
--- a/logic/minecraft/MinecraftVersionList.cpp
+++ b/logic/minecraft/MinecraftVersionList.cpp
@@ -14,12 +14,12 @@
*/
#include <QtXml>
-#include "MMCJson.h"
+#include "Json.h"
#include <QtAlgorithms>
#include <QtNetwork>
#include "Env.h"
-#include "MMCError.h"
+#include "Exception.h"
#include "MinecraftVersionList.h"
#include "net/URLConstants.h"
@@ -71,10 +71,10 @@ protected:
MinecraftVersionList *m_list;
};
-class ListLoadError : public MMCError
+class ListLoadError : public Exception
{
public:
- ListLoadError(QString cause) : MMCError(cause) {};
+ ListLoadError(QString cause) : Exception(cause) {};
virtual ~ListLoadError() noexcept
{
}
@@ -142,7 +142,7 @@ void MinecraftVersionList::loadCachedList()
}
loadMojangList(jsonDoc, Local);
}
- catch (MMCError &e)
+ catch (Exception &e)
{
// the cache has gone bad for some reason... flush it.
qCritical() << "The minecraft version cache is corrupted. Flushing cache.";
@@ -157,12 +157,11 @@ void MinecraftVersionList::loadBuiltinList()
qDebug() << "Loading builtin version list.";
// grab the version list data from internal resources.
const QJsonDocument doc =
- MMCJson::parseFile(":/versions/minecraft.json",
- "builtin version list");
+ Json::ensureDocument(QString(":/versions/minecraft.json"), "builtin version list");
const QJsonObject root = doc.object();
// parse all the versions
- for (const auto version : MMCJson::ensureArray(root.value("versions")))
+ for (const auto version : Json::ensureArray(root.value("versions")))
{
QJsonObject versionObj = version.toObject();
QString versionID = versionObj.value("id").toString("");
@@ -204,9 +203,9 @@ void MinecraftVersionList::loadBuiltinList()
mcVersion->m_processArguments = versionObj.value("processArguments").toString("legacy");
if (versionObj.contains("+traits"))
{
- for (auto traitVal : MMCJson::ensureArray(versionObj.value("+traits")))
+ for (auto traitVal : Json::ensureArray(versionObj.value("+traits")))
{
- mcVersion->m_traits.insert(MMCJson::ensureString(traitVal));
+ mcVersion->m_traits.insert(Json::ensureString(traitVal));
}
}
m_lookup[versionID] = mcVersion;
@@ -227,11 +226,11 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s
try
{
- QJsonObject latest = MMCJson::ensureObject(root.value("latest"));
- m_latestReleaseID = MMCJson::ensureString(latest.value("release"));
- m_latestSnapshotID = MMCJson::ensureString(latest.value("snapshot"));
+ QJsonObject latest = Json::ensureObject(root.value("latest"));
+ m_latestReleaseID = Json::ensureString(latest.value("release"));
+ m_latestSnapshotID = Json::ensureString(latest.value("snapshot"));
}
- catch (MMCError &err)
+ catch (Exception &err)
{
qCritical()
<< tr("Error parsing version list JSON: couldn't determine latest versions");
@@ -481,7 +480,7 @@ void MCVListLoadTask::list_downloaded()
}
m_list->loadMojangList(jsonDoc, Remote);
}
- catch (MMCError &e)
+ catch (Exception &e)
{
emitFailed(e.cause());
return;
@@ -532,7 +531,7 @@ void MCVListVersionUpdateTask::json_downloaded()
{
file = VersionFile::fromJson(jsonDoc, "net.minecraft.json", false);
}
- catch (MMCError &e)
+ catch (Exception &e)
{
emitFailed(tr("Couldn't process version file: %1").arg(e.cause()));
return;
diff --git a/logic/minecraft/OneSixInstance.cpp b/logic/minecraft/OneSixInstance.cpp
index ffccc259..b7937e31 100644
--- a/logic/minecraft/OneSixInstance.cpp
+++ b/logic/minecraft/OneSixInstance.cpp
@@ -16,7 +16,6 @@
#include <QIcon>
#include <pathutils.h>
#include <QDebug>
-#include "MMCError.h"
#include "minecraft/OneSixInstance.h"
@@ -338,7 +337,7 @@ void OneSixInstance::reloadProfile()
catch (VersionIncomplete &error)
{
}
- catch (MMCError &error)
+ catch (Exception &error)
{
m_version->clear();
setFlag(VersionBrokenFlag);
diff --git a/logic/minecraft/OneSixProfileStrategy.cpp b/logic/minecraft/OneSixProfileStrategy.cpp
index 173cd4d6..f5de690b 100644
--- a/logic/minecraft/OneSixProfileStrategy.cpp
+++ b/logic/minecraft/OneSixProfileStrategy.cpp
@@ -294,7 +294,7 @@ bool OneSixProfileStrategy::customizePatch(ProfilePatchPtr patch)
{
qDebug() << "Version was incomplete:" << error.cause();
}
- catch (MMCError &error)
+ catch (Exception &error)
{
qWarning() << "Version could not be loaded:" << error.cause();
}
@@ -324,7 +324,7 @@ bool OneSixProfileStrategy::revertPatch(ProfilePatchPtr patch)
{
qDebug() << "Version was incomplete:" << error.cause();
}
- catch (MMCError &error)
+ catch (Exception &error)
{
qWarning() << "Version could not be loaded:" << error.cause();
}
diff --git a/logic/minecraft/OneSixUpdate.cpp b/logic/minecraft/OneSixUpdate.cpp
index 485727ec..8463ead6 100644
--- a/logic/minecraft/OneSixUpdate.cpp
+++ b/logic/minecraft/OneSixUpdate.cpp
@@ -33,6 +33,7 @@
#include "forge/ForgeMirrors.h"
#include "net/URLConstants.h"
#include "minecraft/AssetsUtils.h"
+#include "Exception.h"
#include "MMCZip.h"
OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent), m_inst(inst)
@@ -182,7 +183,7 @@ void OneSixUpdate::jarlibStart()
{
inst->reloadProfile();
}
- catch (MMCError &e)
+ catch (Exception &e)
{
emitFailed(e.cause());
return;
diff --git a/logic/minecraft/ParseUtils.cpp b/logic/minecraft/ParseUtils.cpp
index 49e0e0ca..8fccf403 100644
--- a/logic/minecraft/ParseUtils.cpp
+++ b/logic/minecraft/ParseUtils.cpp
@@ -1,7 +1,6 @@
#include <QDateTime>
#include <QString>
#include "ParseUtils.h"
-#include <MMCJson.h>
QDateTime timeFromS3Time(QString str)
{
diff --git a/logic/minecraft/ProfileUtils.cpp b/logic/minecraft/ProfileUtils.cpp
index 3eaca920..68fe0f14 100644
--- a/logic/minecraft/ProfileUtils.cpp
+++ b/logic/minecraft/ProfileUtils.cpp
@@ -1,6 +1,6 @@
#include "ProfileUtils.h"
#include "minecraft/VersionFilterData.h"
-#include "MMCJson.h"
+#include "Json.h"
#include <QDebug>
#include <QJsonDocument>
@@ -74,18 +74,18 @@ bool readOverrideOrders(QString path, PatchOrder &order)
// and then read it and process it if all above is true.
try
{
- auto obj = MMCJson::ensureObject(doc);
+ auto obj = Json::ensureObject(doc);
// check order file version.
- auto version = MMCJson::ensureInteger(obj.value("version"), "version");
+ auto version = Json::ensureInteger(obj.value("version"));
if (version != currentOrderFileVersion)
{
throw JSONValidationError(QObject::tr("Invalid order file version, expected %1")
.arg(currentOrderFileVersion));
}
- auto orderArray = MMCJson::ensureArray(obj.value("order"));
+ auto orderArray = Json::ensureArray(obj.value("order"));
for(auto item: orderArray)
{
- order.append(MMCJson::ensureString(item));
+ order.append(Json::ensureString(item));
}
}
catch (JSONValidationError &err)
diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp
index c4cd97a1..90883312 100644
--- a/logic/minecraft/RawLibrary.cpp
+++ b/logic/minecraft/RawLibrary.cpp
@@ -1,5 +1,5 @@
-#include "MMCJson.h"
-using namespace MMCJson;
+#include "Json.h"
+using namespace Json;
#include "RawLibrary.h"
#include <pathutils.h>
@@ -74,7 +74,7 @@ RawLibraryPtr RawLibrary::fromJsonPlus(const QJsonObject &libObj, const QString
auto lib = RawLibrary::fromJson(libObj, filename);
if (libObj.contains("insert"))
{
- QJsonValue insertVal = ensureExists(libObj.value("insert"), "library insert rule");
+ QJsonValue insertVal = ensureJsonValue(libObj.value("insert"), "library insert rule");
if (insertVal.isString())
{
// it's just a simple string rule. OK.
diff --git a/logic/minecraft/VersionBuildError.h b/logic/minecraft/VersionBuildError.h
index ae479851..fda453e5 100644
--- a/logic/minecraft/VersionBuildError.h
+++ b/logic/minecraft/VersionBuildError.h
@@ -1,9 +1,9 @@
-#include "MMCError.h"
+#include "Exception.h"
-class VersionBuildError : public MMCError
+class VersionBuildError : public Exception
{
public:
- VersionBuildError(QString cause) : MMCError(cause) {};
+ explicit VersionBuildError(QString cause) : Exception(cause) {}
virtual ~VersionBuildError() noexcept
{
}
@@ -55,4 +55,4 @@ public:
virtual ~VersionIncomplete() noexcept
{
}
-}; \ No newline at end of file
+};
diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp
index 227ba8be..426cba8c 100644
--- a/logic/minecraft/VersionFile.cpp
+++ b/logic/minecraft/VersionFile.cpp
@@ -10,8 +10,8 @@
#include "minecraft/JarMod.h"
#include "ParseUtils.h"
-#include "MMCJson.h"
-using namespace MMCJson;
+#include "Json.h"
+using namespace Json;
#include "VersionBuildError.h"
diff --git a/logic/minecraft/VersionFile.h b/logic/minecraft/VersionFile.h
index dd5c962f..e5ce4026 100644
--- a/logic/minecraft/VersionFile.h
+++ b/logic/minecraft/VersionFile.h
@@ -3,11 +3,12 @@
#include <QString>
#include <QStringList>
#include <QDateTime>
+#include <QSet>
+
#include <memory>
#include "minecraft/OpSys.h"
#include "minecraft/OneSixRule.h"
#include "ProfilePatch.h"
-#include "MMCError.h"
#include "OneSixLibrary.h"
#include "JarMod.h"