mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-03 16:51:30 +00:00
NOISSUE disambiguate Json parsing calls
This commit is contained in:
@@ -308,7 +308,7 @@ void InstanceImportTask::processModrinth() {
|
|||||||
file.hash = QByteArray::fromHex(hash.toLatin1());
|
file.hash = QByteArray::fromHex(hash.toLatin1());
|
||||||
file.hashAlgorithm = hashAlgorithm;
|
file.hashAlgorithm = hashAlgorithm;
|
||||||
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode (as Modrinth seems to incorrectly handle spaces)
|
// Do not use requireUrl, which uses StrictMode, instead use QUrl's default TolerantMode (as Modrinth seems to incorrectly handle spaces)
|
||||||
file.download = Json::requireString(Json::ensureArray(obj, "downloads").first(), "Download URL for " + file.path);
|
file.download = Json::requireValueString(Json::ensureArray(obj, "downloads").first(), "Download URL for " + file.path);
|
||||||
if (!file.download.isValid())
|
if (!file.download.isValid())
|
||||||
{
|
{
|
||||||
throw JSONValidationError("Download URL for " + file.path + " is not a correctly formatted URL");
|
throw JSONValidationError("Download URL for " + file.path + " is not a correctly formatted URL");
|
||||||
@@ -324,25 +324,25 @@ void InstanceImportTask::processModrinth() {
|
|||||||
{
|
{
|
||||||
if (!minecraftVersion.isEmpty())
|
if (!minecraftVersion.isEmpty())
|
||||||
throw JSONValidationError("Duplicate Minecraft version");
|
throw JSONValidationError("Duplicate Minecraft version");
|
||||||
minecraftVersion = Json::requireString(*it, "Minecraft version");
|
minecraftVersion = Json::requireValueString(*it, "Minecraft version");
|
||||||
}
|
}
|
||||||
else if (name == "fabric-loader")
|
else if (name == "fabric-loader")
|
||||||
{
|
{
|
||||||
if (!fabricVersion.isEmpty())
|
if (!fabricVersion.isEmpty())
|
||||||
throw JSONValidationError("Duplicate Fabric Loader version");
|
throw JSONValidationError("Duplicate Fabric Loader version");
|
||||||
fabricVersion = Json::requireString(*it, "Fabric Loader version");
|
fabricVersion = Json::requireValueString(*it, "Fabric Loader version");
|
||||||
}
|
}
|
||||||
else if (name == "quilt-loader")
|
else if (name == "quilt-loader")
|
||||||
{
|
{
|
||||||
if (!quiltVersion.isEmpty())
|
if (!quiltVersion.isEmpty())
|
||||||
throw JSONValidationError("Duplicate Quilt Loader version");
|
throw JSONValidationError("Duplicate Quilt Loader version");
|
||||||
quiltVersion = Json::requireString(*it, "Quilt Loader version");
|
quiltVersion = Json::requireValueString(*it, "Quilt Loader version");
|
||||||
}
|
}
|
||||||
else if (name == "forge")
|
else if (name == "forge")
|
||||||
{
|
{
|
||||||
if (!forgeVersion.isEmpty())
|
if (!forgeVersion.isEmpty())
|
||||||
throw JSONValidationError("Duplicate Forge version");
|
throw JSONValidationError("Duplicate Forge version");
|
||||||
forgeVersion = Json::requireString(*it, "Forge version");
|
forgeVersion = Json::requireValueString(*it, "Forge version");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -212,11 +212,11 @@ QVector<T> ensureIsArrayOf(const QJsonObject &parent, const QString &key,
|
|||||||
|
|
||||||
// this macro part could be replaced by variadic functions that just pass on their arguments, but that wouldn't work well with IDE helpers
|
// this macro part could be replaced by variadic functions that just pass on their arguments, but that wouldn't work well with IDE helpers
|
||||||
#define JSON_HELPERFUNCTIONS(NAME, TYPE) \
|
#define JSON_HELPERFUNCTIONS(NAME, TYPE) \
|
||||||
inline TYPE require##NAME(const QJsonValue &value, const QString &what = "Value") \
|
inline TYPE requireValue##NAME(const QJsonValue &value, const QString &what = "Value") \
|
||||||
{ \
|
{ \
|
||||||
return requireIsType<TYPE>(value, what); \
|
return requireIsType<TYPE>(value, what); \
|
||||||
} \
|
} \
|
||||||
inline TYPE ensure##NAME(const QJsonValue &value, const TYPE default_ = TYPE(), const QString &what = "Value") \
|
inline TYPE ensureValue##NAME(const QJsonValue &value, const TYPE default_ = TYPE(), const QString &what = "Value") \
|
||||||
{ \
|
{ \
|
||||||
return ensureIsType<TYPE>(value, default_, what); \
|
return ensureIsType<TYPE>(value, default_, what); \
|
||||||
} \
|
} \
|
||||||
|
@@ -181,7 +181,7 @@ void parseRequires(const QJsonObject& obj, RequireSet* ptr, const char * keyName
|
|||||||
auto iter = reqArray.begin();
|
auto iter = reqArray.begin();
|
||||||
while(iter != reqArray.end())
|
while(iter != reqArray.end())
|
||||||
{
|
{
|
||||||
auto reqObject = requireObject(*iter);
|
auto reqObject = requireValueObject(*iter);
|
||||||
auto uid = requireString(reqObject, "uid");
|
auto uid = requireString(reqObject, "uid");
|
||||||
auto equals = ensureString(reqObject, "equals", QString());
|
auto equals = ensureString(reqObject, "equals", QString());
|
||||||
auto suggests = ensureString(reqObject, "suggests", QString());
|
auto suggests = ensureString(reqObject, "suggests", QString());
|
||||||
|
@@ -22,7 +22,7 @@ static void readString(const QJsonObject &root, const QString &key, QString &var
|
|||||||
{
|
{
|
||||||
if (root.contains(key))
|
if (root.contains(key))
|
||||||
{
|
{
|
||||||
variable = requireString(root.value(key));
|
variable = requireValueString(root.value(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ QJsonObject downloadInfoToJson(MojangDownloadInfo::Ptr info)
|
|||||||
MojangLibraryDownloadInfo::Ptr libDownloadInfoFromJson(const QJsonObject &libObj)
|
MojangLibraryDownloadInfo::Ptr libDownloadInfoFromJson(const QJsonObject &libObj)
|
||||||
{
|
{
|
||||||
auto out = std::make_shared<MojangLibraryDownloadInfo>();
|
auto out = std::make_shared<MojangLibraryDownloadInfo>();
|
||||||
auto dlObj = requireObject(libObj.value("downloads"));
|
auto dlObj = requireValueObject(libObj.value("downloads"));
|
||||||
if(dlObj.contains("artifact"))
|
if(dlObj.contains("artifact"))
|
||||||
{
|
{
|
||||||
out->artifact = downloadInfoFromJson(requireObject(dlObj, "artifact"));
|
out->artifact = downloadInfoFromJson(requireObject(dlObj, "artifact"));
|
||||||
@@ -86,7 +86,7 @@ MojangLibraryDownloadInfo::Ptr libDownloadInfoFromJson(const QJsonObject &libObj
|
|||||||
for(auto iter = classifiersObj.begin(); iter != classifiersObj.end(); iter++)
|
for(auto iter = classifiersObj.begin(); iter != classifiersObj.end(); iter++)
|
||||||
{
|
{
|
||||||
auto classifier = iter.key();
|
auto classifier = iter.key();
|
||||||
auto classifierObj = requireObject(iter.value());
|
auto classifierObj = requireValueObject(iter.value());
|
||||||
out->classifiers[classifier] = downloadInfoFromJson(classifierObj);
|
out->classifiers[classifier] = downloadInfoFromJson(classifierObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
|
|||||||
|
|
||||||
if (in.contains("minimumLauncherVersion"))
|
if (in.contains("minimumLauncherVersion"))
|
||||||
{
|
{
|
||||||
out->minimumLauncherVersion = requireInteger(in.value("minimumLauncherVersion"));
|
out->minimumLauncherVersion = requireValueInteger(in.value("minimumLauncherVersion"));
|
||||||
if (out->minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION)
|
if (out->minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION)
|
||||||
{
|
{
|
||||||
out->addProblem(
|
out->addProblem(
|
||||||
@@ -189,7 +189,7 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
|
|||||||
for(auto iter = downloadsObj.begin(); iter != downloadsObj.end(); iter++)
|
for(auto iter = downloadsObj.begin(); iter != downloadsObj.end(); iter++)
|
||||||
{
|
{
|
||||||
auto classifier = iter.key();
|
auto classifier = iter.key();
|
||||||
auto classifierObj = requireObject(iter.value());
|
auto classifierObj = requireValueObject(iter.value());
|
||||||
out->mojangDownloads[classifier] = downloadInfoFromJson(classifierObj);
|
out->mojangDownloads[classifier] = downloadInfoFromJson(classifierObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,9 +219,9 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
|
|
||||||
if (root.contains("libraries"))
|
if (root.contains("libraries"))
|
||||||
{
|
{
|
||||||
for (auto libVal : requireArray(root.value("libraries")))
|
for (auto libVal : requireValueArray(root.value("libraries")))
|
||||||
{
|
{
|
||||||
auto libObj = requireObject(libVal);
|
auto libObj = requireValueObject(libVal);
|
||||||
|
|
||||||
auto lib = MojangVersionFormat::libraryFromJson(*out, libObj, filename);
|
auto lib = MojangVersionFormat::libraryFromJson(*out, libObj, filename);
|
||||||
out->libraries.append(lib);
|
out->libraries.append(lib);
|
||||||
@@ -303,15 +303,15 @@ LibraryPtr MojangVersionFormat::libraryFromJson(ProblemContainer & problems, con
|
|||||||
if (libObj.contains("extract"))
|
if (libObj.contains("extract"))
|
||||||
{
|
{
|
||||||
out->m_hasExcludes = true;
|
out->m_hasExcludes = true;
|
||||||
auto extractObj = requireObject(libObj.value("extract"));
|
auto extractObj = requireValueObject(libObj.value("extract"));
|
||||||
for (auto excludeVal : requireArray(extractObj.value("exclude")))
|
for (auto excludeVal : requireValueArray(extractObj.value("exclude")))
|
||||||
{
|
{
|
||||||
out->m_extractExcludes.append(requireString(excludeVal));
|
out->m_extractExcludes.append(requireValueString(excludeVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (libObj.contains("natives"))
|
if (libObj.contains("natives"))
|
||||||
{
|
{
|
||||||
QJsonObject nativesObj = requireObject(libObj.value("natives"));
|
QJsonObject nativesObj = requireValueObject(libObj.value("natives"));
|
||||||
for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it)
|
for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it)
|
||||||
{
|
{
|
||||||
if (!it.value().isString())
|
if (!it.value().isString())
|
||||||
|
@@ -9,7 +9,7 @@ static void readString(const QJsonObject &root, const QString &key, QString &var
|
|||||||
{
|
{
|
||||||
if (root.contains(key))
|
if (root.contains(key))
|
||||||
{
|
{
|
||||||
variable = requireString(root.value(key));
|
variable = requireValueString(root.value(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
{
|
{
|
||||||
if (root.contains("order"))
|
if (root.contains("order"))
|
||||||
{
|
{
|
||||||
out->order = requireInteger(root.value("order"));
|
out->order = requireValueInteger(root.value("order"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -94,26 +94,26 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
|
|
||||||
if (root.contains("+tweakers"))
|
if (root.contains("+tweakers"))
|
||||||
{
|
{
|
||||||
for (auto tweakerVal : requireArray(root.value("+tweakers")))
|
for (auto tweakerVal : requireValueArray(root.value("+tweakers")))
|
||||||
{
|
{
|
||||||
out->addTweakers.append(requireString(tweakerVal));
|
out->addTweakers.append(requireValueString(tweakerVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.contains("+traits"))
|
if (root.contains("+traits"))
|
||||||
{
|
{
|
||||||
for (auto tweakerVal : requireArray(root.value("+traits")))
|
for (auto tweakerVal : requireValueArray(root.value("+traits")))
|
||||||
{
|
{
|
||||||
out->traits.insert(requireString(tweakerVal));
|
out->traits.insert(requireValueString(tweakerVal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (root.contains("jarMods"))
|
if (root.contains("jarMods"))
|
||||||
{
|
{
|
||||||
for (auto libVal : requireArray(root.value("jarMods")))
|
for (auto libVal : requireValueArray(root.value("jarMods")))
|
||||||
{
|
{
|
||||||
QJsonObject libObj = requireObject(libVal);
|
QJsonObject libObj = requireValueObject(libVal);
|
||||||
// parse the jarmod
|
// parse the jarmod
|
||||||
auto lib = OneSixVersionFormat::jarModFromJson(*out, libObj, filename);
|
auto lib = OneSixVersionFormat::jarModFromJson(*out, libObj, filename);
|
||||||
// and add to jar mods
|
// and add to jar mods
|
||||||
@@ -122,9 +122,9 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
}
|
}
|
||||||
else if (root.contains("+jarMods")) // DEPRECATED: old style '+jarMods' are only here for backwards compatibility
|
else if (root.contains("+jarMods")) // DEPRECATED: old style '+jarMods' are only here for backwards compatibility
|
||||||
{
|
{
|
||||||
for (auto libVal : requireArray(root.value("+jarMods")))
|
for (auto libVal : requireValueArray(root.value("+jarMods")))
|
||||||
{
|
{
|
||||||
QJsonObject libObj = requireObject(libVal);
|
QJsonObject libObj = requireValueObject(libVal);
|
||||||
// parse the jarmod
|
// parse the jarmod
|
||||||
auto lib = OneSixVersionFormat::plusJarModFromJson(*out, libObj, filename, out->name);
|
auto lib = OneSixVersionFormat::plusJarModFromJson(*out, libObj, filename, out->name);
|
||||||
// and add to jar mods
|
// and add to jar mods
|
||||||
@@ -134,9 +134,9 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
|
|
||||||
if (root.contains("mods"))
|
if (root.contains("mods"))
|
||||||
{
|
{
|
||||||
for (auto libVal : requireArray(root.value("mods")))
|
for (auto libVal : requireValueArray(root.value("mods")))
|
||||||
{
|
{
|
||||||
QJsonObject libObj = requireObject(libVal);
|
QJsonObject libObj = requireValueObject(libVal);
|
||||||
// parse the jarmod
|
// parse the jarmod
|
||||||
auto lib = OneSixVersionFormat::modFromJson(*out, libObj, filename);
|
auto lib = OneSixVersionFormat::modFromJson(*out, libObj, filename);
|
||||||
// and add to jar mods
|
// and add to jar mods
|
||||||
@@ -146,9 +146,9 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
|
|
||||||
auto readLibs = [&](const char * which, QList<LibraryPtr> & outList)
|
auto readLibs = [&](const char * which, QList<LibraryPtr> & outList)
|
||||||
{
|
{
|
||||||
for (auto libVal : requireArray(root.value(which)))
|
for (auto libVal : requireValueArray(root.value(which)))
|
||||||
{
|
{
|
||||||
QJsonObject libObj = requireObject(libVal);
|
QJsonObject libObj = requireValueObject(libVal);
|
||||||
// parse the library
|
// parse the library
|
||||||
auto lib = libraryFromJson(*out, libObj, filename);
|
auto lib = libraryFromJson(*out, libObj, filename);
|
||||||
outList.append(lib);
|
outList.append(lib);
|
||||||
|
@@ -101,21 +101,21 @@ static QJsonObject componentToJsonV1(ComponentPtr component)
|
|||||||
static ComponentPtr componentFromJsonV1(PackProfile * parent, const QString & componentJsonPattern, const QJsonObject &obj)
|
static ComponentPtr componentFromJsonV1(PackProfile * parent, const QString & componentJsonPattern, const QJsonObject &obj)
|
||||||
{
|
{
|
||||||
// critical
|
// critical
|
||||||
auto uid = Json::requireString(obj.value("uid"));
|
auto uid = Json::requireValueString(obj.value("uid"));
|
||||||
auto filePath = componentJsonPattern.arg(uid);
|
auto filePath = componentJsonPattern.arg(uid);
|
||||||
auto component = new Component(parent, uid);
|
auto component = new Component(parent, uid);
|
||||||
component->m_version = Json::ensureString(obj.value("version"));
|
component->m_version = Json::ensureValueString(obj.value("version"));
|
||||||
component->m_dependencyOnly = Json::ensureBoolean(obj.value("dependencyOnly"), false);
|
component->m_dependencyOnly = Json::ensureValueBoolean(obj.value("dependencyOnly"), false);
|
||||||
component->m_important = Json::ensureBoolean(obj.value("important"), false);
|
component->m_important = Json::ensureValueBoolean(obj.value("important"), false);
|
||||||
|
|
||||||
// cached
|
// cached
|
||||||
// TODO @RESILIENCE: ignore invalid values/structure here?
|
// TODO @RESILIENCE: ignore invalid values/structure here?
|
||||||
component->m_cachedVersion = Json::ensureString(obj.value("cachedVersion"));
|
component->m_cachedVersion = Json::ensureValueString(obj.value("cachedVersion"));
|
||||||
component->m_cachedName = Json::ensureString(obj.value("cachedName"));
|
component->m_cachedName = Json::ensureValueString(obj.value("cachedName"));
|
||||||
Meta::parseRequires(obj, &component->m_cachedRequires, "cachedRequires");
|
Meta::parseRequires(obj, &component->m_cachedRequires, "cachedRequires");
|
||||||
Meta::parseRequires(obj, &component->m_cachedConflicts, "cachedConflicts");
|
Meta::parseRequires(obj, &component->m_cachedConflicts, "cachedConflicts");
|
||||||
component->m_cachedVolatile = Json::ensureBoolean(obj.value("volatile"), false);
|
component->m_cachedVolatile = Json::ensureValueBoolean(obj.value("volatile"), false);
|
||||||
bool disabled = Json::ensureBoolean(obj.value("disabled"), false);
|
bool disabled = Json::ensureValueBoolean(obj.value("disabled"), false);
|
||||||
component->setEnabled(!disabled);
|
component->setEnabled(!disabled);
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
@@ -185,16 +185,16 @@ static bool loadPackProfile(PackProfile * parent, const QString & filename, cons
|
|||||||
{
|
{
|
||||||
auto obj = Json::requireObject(doc);
|
auto obj = Json::requireObject(doc);
|
||||||
// check order file version.
|
// check order file version.
|
||||||
auto version = Json::requireInteger(obj.value("formatVersion"));
|
auto version = Json::requireValueInteger(obj.value("formatVersion"));
|
||||||
if (version != currentComponentsFileVersion)
|
if (version != currentComponentsFileVersion)
|
||||||
{
|
{
|
||||||
throw JSONValidationError(QObject::tr("Invalid component file version, expected %1")
|
throw JSONValidationError(QObject::tr("Invalid component file version, expected %1")
|
||||||
.arg(currentComponentsFileVersion));
|
.arg(currentComponentsFileVersion));
|
||||||
}
|
}
|
||||||
auto orderArray = Json::requireArray(obj.value("components"));
|
auto orderArray = Json::requireValueArray(obj.value("components"));
|
||||||
for(auto item: orderArray)
|
for(auto item: orderArray)
|
||||||
{
|
{
|
||||||
auto obj = Json::requireObject(item, "Component must be an object.");
|
auto obj = Json::requireValueObject(item, "Component must be an object.");
|
||||||
container.append(componentFromJsonV1(parent, componentJsonPattern, obj));
|
container.append(componentFromJsonV1(parent, componentJsonPattern, obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,16 +45,16 @@ bool readOverrideOrders(QString path, PatchOrder &order)
|
|||||||
{
|
{
|
||||||
auto obj = Json::requireObject(doc);
|
auto obj = Json::requireObject(doc);
|
||||||
// check order file version.
|
// check order file version.
|
||||||
auto version = Json::requireInteger(obj.value("version"));
|
auto version = Json::requireValueInteger(obj.value("version"));
|
||||||
if (version != currentOrderFileVersion)
|
if (version != currentOrderFileVersion)
|
||||||
{
|
{
|
||||||
throw JSONValidationError(QObject::tr("Invalid order file version, expected %1")
|
throw JSONValidationError(QObject::tr("Invalid order file version, expected %1")
|
||||||
.arg(currentOrderFileVersion));
|
.arg(currentOrderFileVersion));
|
||||||
}
|
}
|
||||||
auto orderArray = Json::requireArray(obj.value("order"));
|
auto orderArray = Json::requireValueArray(obj.value("order"));
|
||||||
for(auto item: orderArray)
|
for(auto item: orderArray)
|
||||||
{
|
{
|
||||||
order.append(Json::requireString(item));
|
order.append(Json::requireValueString(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const JSONValidationError &err)
|
catch (const JSONValidationError &err)
|
||||||
|
@@ -38,7 +38,7 @@ void ATLauncher::loadIndexedPack(ATLauncher::IndexedPack & m, QJsonObject & obj)
|
|||||||
auto versionsArr = Json::requireArray(obj, "versions");
|
auto versionsArr = Json::requireArray(obj, "versions");
|
||||||
for (const auto versionRaw : versionsArr)
|
for (const auto versionRaw : versionsArr)
|
||||||
{
|
{
|
||||||
auto versionObj = Json::requireObject(versionRaw);
|
auto versionObj = Json::requireValueObject(versionRaw);
|
||||||
ATLauncher::IndexedVersion version;
|
ATLauncher::IndexedVersion version;
|
||||||
loadIndexedVersion(version, versionObj);
|
loadIndexedVersion(version, versionObj);
|
||||||
m.versions.append(version);
|
m.versions.append(version);
|
||||||
|
@@ -175,7 +175,7 @@ static void loadVersionMod(ATLauncher::VersionMod & p, QJsonObject & obj) {
|
|||||||
if(obj.contains("depends")) {
|
if(obj.contains("depends")) {
|
||||||
auto dependsArr = Json::requireArray(obj, "depends");
|
auto dependsArr = Json::requireArray(obj, "depends");
|
||||||
for (const auto depends : dependsArr) {
|
for (const auto depends : dependsArr) {
|
||||||
p.depends.append(Json::requireString(depends));
|
p.depends.append(Json::requireValueString(depends));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
|||||||
auto libraries = Json::requireArray(obj, "libraries");
|
auto libraries = Json::requireArray(obj, "libraries");
|
||||||
for (const auto libraryRaw : libraries)
|
for (const auto libraryRaw : libraries)
|
||||||
{
|
{
|
||||||
auto libraryObj = Json::requireObject(libraryRaw);
|
auto libraryObj = Json::requireValueObject(libraryRaw);
|
||||||
ATLauncher::VersionLibrary target;
|
ATLauncher::VersionLibrary target;
|
||||||
loadVersionLibrary(target, libraryObj);
|
loadVersionLibrary(target, libraryObj);
|
||||||
v.libraries.append(target);
|
v.libraries.append(target);
|
||||||
@@ -233,7 +233,7 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
|
|||||||
auto mods = Json::requireArray(obj, "mods");
|
auto mods = Json::requireArray(obj, "mods");
|
||||||
for (const auto modRaw : mods)
|
for (const auto modRaw : mods)
|
||||||
{
|
{
|
||||||
auto modObj = Json::requireObject(modRaw);
|
auto modObj = Json::requireValueObject(modRaw);
|
||||||
ATLauncher::VersionMod mod;
|
ATLauncher::VersionMod mod;
|
||||||
loadVersionMod(mod, modObj);
|
loadVersionMod(mod, modObj);
|
||||||
v.mods.append(mod);
|
v.mods.append(mod);
|
||||||
|
@@ -89,7 +89,7 @@ void Technic::SolderPackInstallTask::fileListSucceeded()
|
|||||||
QJsonArray mods = Json::requireArray(obj, "mods", "'mods'");
|
QJsonArray mods = Json::requireArray(obj, "mods", "'mods'");
|
||||||
for (auto mod: mods)
|
for (auto mod: mods)
|
||||||
{
|
{
|
||||||
QJsonObject modObject = Json::requireObject(mod);
|
QJsonObject modObject = Json::requireValueObject(mod);
|
||||||
modUrls.append(Json::requireString(modObject, "url", "'url'"));
|
modUrls.append(Json::requireString(modObject, "url", "'url'"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -171,7 +171,7 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings, const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto libraryObject = Json::ensureObject(library, {}, "");
|
auto libraryObject = Json::ensureValueObject(library, {}, "");
|
||||||
auto libraryName = Json::ensureString(libraryObject, "name", "", "");
|
auto libraryName = Json::ensureString(libraryObject, "name", "", "");
|
||||||
|
|
||||||
if (libraryName.startsWith("net.minecraftforge:forge:") && libraryName.contains('-'))
|
if (libraryName.startsWith("net.minecraftforge:forge:") && libraryName.contains('-'))
|
||||||
|
@@ -111,7 +111,7 @@ void fromJson(QJsonDocument & doc, Package & out) {
|
|||||||
for(auto iter2 = downloads.begin(); iter2 != downloads.end(); iter2++) {
|
for(auto iter2 = downloads.begin(); iter2 != downloads.end(); iter2++) {
|
||||||
FileSource source;
|
FileSource source;
|
||||||
|
|
||||||
auto downloadObject = Json::requireObject(iter2.value());
|
auto downloadObject = Json::requireValueObject(iter2.value());
|
||||||
source.hash = Json::requireString(downloadObject, "sha1");
|
source.hash = Json::requireString(downloadObject, "sha1");
|
||||||
source.size = Json::requireInteger(downloadObject, "size");
|
source.size = Json::requireInteger(downloadObject, "size");
|
||||||
source.url = Json::requireString(downloadObject, "url");
|
source.url = Json::requireString(downloadObject, "url");
|
||||||
|
@@ -214,7 +214,7 @@ void readIndex(const QString & path, QMap<QString, Language>& languages)
|
|||||||
{
|
{
|
||||||
Language lang(iter.key());
|
Language lang(iter.key());
|
||||||
|
|
||||||
auto langObj = Json::requireObject(iter.value());
|
auto langObj = Json::requireValueObject(iter.value());
|
||||||
lang.setTranslationStats(
|
lang.setTranslationStats(
|
||||||
Json::ensureInteger(langObj, "translated", 0),
|
Json::ensureInteger(langObj, "translated", 0),
|
||||||
Json::ensureInteger(langObj, "untranslated", 0),
|
Json::ensureInteger(langObj, "untranslated", 0),
|
||||||
|
@@ -81,7 +81,7 @@ QString reprocessCommits(QByteArray json)
|
|||||||
for(int i = commitarray.size() - 1; i >= 0; i--)
|
for(int i = commitarray.size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
const auto & commitval = commitarray[i];
|
const auto & commitval = commitarray[i];
|
||||||
auto commitobj = Json::requireObject(commitval);
|
auto commitobj = Json::requireValueObject(commitval);
|
||||||
auto parents_info = Json::ensureArray(commitobj, "parents");
|
auto parents_info = Json::ensureArray(commitobj, "parents");
|
||||||
// NOTE: this ignores merge commits, because they have more than one parent
|
// NOTE: this ignores merge commits, because they have more than one parent
|
||||||
if(parents_info.size() > 1)
|
if(parents_info.size() > 1)
|
||||||
|
@@ -170,9 +170,10 @@ bool parseModpackJson(const QByteArray& data, Modpack & out) {
|
|||||||
out.description = Json::ensureString(object, "description", QObject::tr("Description is missing in the FTB App instance."));
|
out.description = Json::ensureString(object, "description", QObject::tr("Description is missing in the FTB App instance."));
|
||||||
auto authorsArray = Json::ensureArray(object, "authors", QJsonArray());
|
auto authorsArray = Json::ensureArray(object, "authors", QJsonArray());
|
||||||
for(auto author: authorsArray) {
|
for(auto author: authorsArray) {
|
||||||
out.authors.append(Json::requireString(author));
|
out.authors.append(Json::requireValueString(author));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
out.mcVersion = Json::requireString(object, "mcVersion");
|
out.mcVersion = Json::requireString(object, "mcVersion");
|
||||||
out.modLoader = Json::ensureString(object, "modLoader", QString());
|
out.modLoader = Json::ensureString(object, "modLoader", QString());
|
||||||
out.hasInstMods = Json::ensureBoolean(object, "hasInstMods", false);
|
out.hasInstMods = Json::ensureBoolean(object, "hasInstMods", false);
|
||||||
|
@@ -128,7 +128,7 @@ void Technic::ListModel::searchRequestFinished()
|
|||||||
auto objs = Json::requireArray(root, "modpacks");
|
auto objs = Json::requireArray(root, "modpacks");
|
||||||
for (auto technicPack: objs) {
|
for (auto technicPack: objs) {
|
||||||
Modpack pack;
|
Modpack pack;
|
||||||
auto technicPackObject = Json::requireObject(technicPack);
|
auto technicPackObject = Json::requireValueObject(technicPack);
|
||||||
pack.name = Json::requireString(technicPackObject, "name");
|
pack.name = Json::requireString(technicPackObject, "name");
|
||||||
pack.slug = Json::requireString(technicPackObject, "slug");
|
pack.slug = Json::requireString(technicPackObject, "slug");
|
||||||
if (pack.slug == "vanilla")
|
if (pack.slug == "vanilla")
|
||||||
|
Reference in New Issue
Block a user