diff options
author | flow <flowlnlnln@gmail.com> | 2022-06-09 19:53:29 -0300 |
---|---|---|
committer | flow <flowlnlnln@gmail.com> | 2022-06-09 19:53:29 -0300 |
commit | 46e403b20b8f14269aebc163f2bc481d3dea43c5 (patch) | |
tree | 91f8974371ea2571d2b4e09febd5dba95444b255 | |
parent | 309013efb3e148310ba4802ee946a55c01d1d56e (diff) | |
download | PrismLauncher-46e403b20b8f14269aebc163f2bc481d3dea43c5.tar.gz PrismLauncher-46e403b20b8f14269aebc163f2bc481d3dea43c5.tar.bz2 PrismLauncher-46e403b20b8f14269aebc163f2bc481d3dea43c5.zip |
fix: properly parse mrpacks without the 'env' field
It's optional, so some files may not have it (like most of FO).
-rw-r--r-- | launcher/InstanceImportTask.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp index 09c2a333..73f05d44 100644 --- a/launcher/InstanceImportTask.cpp +++ b/launcher/InstanceImportTask.cpp @@ -582,6 +582,7 @@ void InstanceImportTask::processMultiMC() emitSucceeded(); } +// https://docs.modrinth.com/docs/modpacks/format_definition/ void InstanceImportTask::processModrinth() { std::vector<Modrinth::File> files; @@ -600,26 +601,30 @@ void InstanceImportTask::processModrinth() auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json"); bool had_optional = false; - for (auto& modInfo : jsonFiles) { + for (auto modInfo : jsonFiles) { Modrinth::File file; file.path = Json::requireString(modInfo, "path"); auto env = Json::ensureObject(modInfo, "env"); - QString support = Json::ensureString(env, "client", "unsupported"); - if (support == "unsupported") { - continue; - } else if (support == "optional") { - // TODO: Make a review dialog for choosing which ones the user wants! - if (!had_optional) { - had_optional = true; - auto info = CustomMessageBox::selectable( - m_parent, tr("Optional mod detected!"), - tr("One or more mods from this modpack are optional. They will be downloaded, but disabled by default!"), QMessageBox::Information); - info->exec(); - } + // 'env' field is optional + if (!env.isEmpty()) { + QString support = Json::ensureString(env, "client", "unsupported"); + if (support == "unsupported") { + continue; + } else if (support == "optional") { + // TODO: Make a review dialog for choosing which ones the user wants! + if (!had_optional) { + had_optional = true; + auto info = CustomMessageBox::selectable( + m_parent, tr("Optional mod detected!"), + tr("One or more mods from this modpack are optional. They will be downloaded, but disabled by default!"), + QMessageBox::Information); + info->exec(); + } - if (file.path.endsWith(".jar")) - file.path += ".disabled"; + if (file.path.endsWith(".jar")) + file.path += ".disabled"; + } } QJsonObject hashes = Json::requireObject(modInfo, "hashes"); |