summaryrefslogtreecommitdiffstats
path: root/logic/minecraft
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-02-21 05:51:36 +0100
committerPetr Mrázek <peterix@gmail.com>2016-02-21 05:51:36 +0100
commit401d5b698fce15ca1beaf808c57aeb4d40069506 (patch)
tree74efa5543805153995da04187f5a9a25be57392a /logic/minecraft
parent1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae (diff)
downloadMultiMC-401d5b698fce15ca1beaf808c57aeb4d40069506.tar
MultiMC-401d5b698fce15ca1beaf808c57aeb4d40069506.tar.gz
MultiMC-401d5b698fce15ca1beaf808c57aeb4d40069506.tar.lz
MultiMC-401d5b698fce15ca1beaf808c57aeb4d40069506.tar.xz
MultiMC-401d5b698fce15ca1beaf808c57aeb4d40069506.zip
GH-1453 handle certain version loading corner cases better, clean up FTB
Diffstat (limited to 'logic/minecraft')
-rw-r--r--logic/minecraft/OneSixProfileStrategy.cpp43
-rw-r--r--logic/minecraft/OneSixProfileStrategy.h4
2 files changed, 32 insertions, 15 deletions
diff --git a/logic/minecraft/OneSixProfileStrategy.cpp b/logic/minecraft/OneSixProfileStrategy.cpp
index 85e9491c..3e3534a0 100644
--- a/logic/minecraft/OneSixProfileStrategy.cpp
+++ b/logic/minecraft/OneSixProfileStrategy.cpp
@@ -140,6 +140,7 @@ void OneSixProfileStrategy::loadUserPatches()
ProfileUtils::PatchOrder userOrder;
ProfileUtils::readOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), userOrder);
QDir patches(FS::PathCombine(m_instance->instanceRoot(),"patches"));
+ QSet<QString> seen_extra;
// first, load things by sort order.
for (auto id : userOrder)
@@ -158,19 +159,19 @@ void OneSixProfileStrategy::loadUserPatches()
continue;
}
qDebug() << "Reading" << filename << "by user order";
- auto file = ProfileUtils::parseJsonFile(finfo, false);
+ VersionFilePtr file = ProfileUtils::parseJsonFile(finfo, false);
// sanity check. prevent tampering with files.
if (file->fileId != id)
{
- throw VersionBuildError(
- QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId));
+ file->addProblem(PROBLEM_WARNING, QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId));
+ seen_extra.insert(file->fileId);
}
file->setRemovable(true);
file->setMovable(true);
profile->appendPatch(file);
}
// now load the rest by internal preference.
- QMap<int, QPair<QString, VersionFilePtr>> files;
+ QMultiMap<int, VersionFilePtr> files;
for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
{
// parse the file
@@ -181,23 +182,39 @@ void OneSixProfileStrategy::loadUserPatches()
continue;
if (file->fileId == "org.lwjgl")
continue;
+ // do not load versions with broken IDs twice
+ if(seen_extra.contains(file->fileId))
+ continue;
// do not load what we already loaded in the first pass
if (userOrder.contains(file->fileId))
continue;
- if (files.contains(file->order))
- {
- // FIXME: do not throw?
- throw VersionBuildError(QObject::tr("%1 has the same order as %2")
- .arg(file->fileId, files[file->order].second->fileId));
- }
file->setRemovable(true);
file->setMovable(true);
- files.insert(file->order, qMakePair(info.fileName(), file));
+ files.insert(file->order, file);
}
+ QSet<int> seen;
for (auto order : files.keys())
{
- auto &filePair = files[order];
- profile->appendPatch(filePair.second);
+ if(seen.contains(order))
+ continue;
+ seen.insert(order);
+ const auto &values = files.values(order);
+ if(values.size() == 1)
+ {
+ profile->appendPatch(values[0]);
+ continue;
+ }
+ for(auto &file: values)
+ {
+ QStringList list;
+ for(auto &file2: values)
+ {
+ if(file != file2)
+ list.append(file2->name);
+ }
+ file->addProblem(PROBLEM_WARNING, QObject::tr("%1 has the same order as the following components:\n%2").arg(file->name, list.join(", ")));
+ profile->appendPatch(file);
+ }
}
}
diff --git a/logic/minecraft/OneSixProfileStrategy.h b/logic/minecraft/OneSixProfileStrategy.h
index b140dee5..a6abe964 100644
--- a/logic/minecraft/OneSixProfileStrategy.h
+++ b/logic/minecraft/OneSixProfileStrategy.h
@@ -17,8 +17,8 @@ public:
virtual bool revertPatch(ProfilePatchPtr patch) override;
protected:
- void loadDefaultBuiltinPatches();
- void loadUserPatches();
+ virtual void loadDefaultBuiltinPatches();
+ virtual void loadUserPatches();
void upgradeDeprecatedFiles();
protected: