NOISSUE Various changes from multiauth that are unrelated to it

This commit is contained in:
Jan Dalheimer
2015-05-28 19:38:29 +02:00
committed by Petr Mrázek
parent 161dc66c2c
commit 3a8b238052
65 changed files with 2661 additions and 333 deletions

View File

@ -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)
{

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -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();
}

View File

@ -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;

View File

@ -1,7 +1,6 @@
#include <QDateTime>
#include <QString>
#include "ParseUtils.h"
#include <MMCJson.h>
QDateTime timeFromS3Time(QString str)
{

View File

@ -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)

View File

@ -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.

View File

@ -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
{
}
};
};

View File

@ -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"

View File

@ -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"