summaryrefslogtreecommitdiffstats
path: root/api/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-03-31 23:47:56 +0200
committerPetr Mrázek <peterix@gmail.com>2017-04-07 00:20:02 +0200
commite0596d3c86806d952a9811f306f497f84430ae3c (patch)
tree283b039fd850d52d7b1ce7c5456f60f0fcdcf9af /api/logic
parent2ac0edbbdb27e12bae00c4779da135582bde89f5 (diff)
downloadMultiMC-e0596d3c86806d952a9811f306f497f84430ae3c.tar
MultiMC-e0596d3c86806d952a9811f306f497f84430ae3c.tar.gz
MultiMC-e0596d3c86806d952a9811f306f497f84430ae3c.tar.lz
MultiMC-e0596d3c86806d952a9811f306f497f84430ae3c.tar.xz
MultiMC-e0596d3c86806d952a9811f306f497f84430ae3c.zip
NOISSUE Make forge installable again
Diffstat (limited to 'api/logic')
-rw-r--r--api/logic/minecraft/onesix/OneSixInstance.cpp32
-rw-r--r--api/logic/minecraft/onesix/OneSixProfileStrategy.cpp143
2 files changed, 95 insertions, 80 deletions
diff --git a/api/logic/minecraft/onesix/OneSixInstance.cpp b/api/logic/minecraft/onesix/OneSixInstance.cpp
index d89f6f87..4a4380a4 100644
--- a/api/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/api/logic/minecraft/onesix/OneSixInstance.cpp
@@ -34,8 +34,15 @@
OneSixInstance::OneSixInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir)
: MinecraftInstance(globalSettings, settings, rootDir)
{
+ // set explicitly during instance creation
m_settings->registerSetting({"IntendedVersion", "MinecraftVersion"}, "");
- m_settings->registerSetting("LWJGLVersion", "");
+
+ // defaults to the version we've been using for years (2.9.1)
+ m_settings->registerSetting("LWJGLVersion", "2.9.1");
+
+ // optionals
+ m_settings->registerSetting("ForgeVersion", "");
+ m_settings->registerSetting("LiteloaderVersion", "");
}
void OneSixInstance::init()
@@ -499,6 +506,14 @@ bool OneSixInstance::setComponentVersion(const QString& uid, const QString& vers
{
settings()->set("LWJGLVersion", version);
}
+ else if (uid == "net.minecraftforge")
+ {
+ settings()->set("ForgeVersion", version);
+ }
+ else if (uid == "com.liteloader")
+ {
+ settings()->set("LiteloaderVersion", version);
+ }
if(getMinecraftProfile())
{
clearProfile();
@@ -515,12 +530,15 @@ QString OneSixInstance::getComponentVersion(const QString& uid) const
}
else if(uid == "org.lwjgl")
{
- auto version = settings()->get("LWJGLVersion").toString();
- if(version.isEmpty())
- {
- return "2.9.1";
- }
- return version;
+ return settings()->get("LWJGLVersion").toString();
+ }
+ else if(uid == "net.minecraftforge")
+ {
+ return settings()->get("ForgeVersion").toString();
+ }
+ else if(uid == "com.liteloader")
+ {
+ return settings()->get("LiteloaderVersion").toString();
}
return QString();
}
diff --git a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
index 4a56a810..e08dd529 100644
--- a/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
+++ b/api/logic/minecraft/onesix/OneSixProfileStrategy.cpp
@@ -120,99 +120,93 @@ void OneSixProfileStrategy::loadDefaultBuiltinPatches()
void OneSixProfileStrategy::loadUserPatches()
{
- // load all patches, put into map for ordering, apply in the right order
- 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)
+ // first, collect all patches (that are not builtins of OneSix) and load them
+ QMap<QString, ProfilePatchPtr> loadedPatches;
+ QDir patchesDir(FS::PathCombine(m_instance->instanceRoot(),"patches"));
+ for (auto info : patchesDir.entryInfoList(QStringList() << "*.json", QDir::Files))
{
+ // parse the file
+ qDebug() << "Reading" << info.fileName();
+ auto file = ProfileUtils::parseJsonFile(info, true);
// ignore builtins
- if (id == "net.minecraft")
+ if (file->uid == "net.minecraft")
continue;
- if (id == "org.lwjgl")
+ if (file->uid == "org.lwjgl")
continue;
- // parse the file
- QString filename = patches.absoluteFilePath(id + ".json");
- QFileInfo finfo(filename);
- if(!finfo.exists())
+ auto patch = std::make_shared<ProfilePatch>(file, info.filePath());
+ patch->setRemovable(true);
+ patch->setMovable(true);
+ if(ENV.metadataIndex()->hasUid(file->uid))
{
- qDebug() << "Patch file " << filename << " was deleted by external means...";
- continue;
+ // FIXME: requesting a uid/list creates it in the index... this allows reverting to possibly invalid versions...
+ patch->setRevertible(true);
}
- qDebug() << "Reading" << filename << "by user order";
- VersionFilePtr file = ProfileUtils::parseJsonFile(finfo, false);
- // sanity check. prevent tampering with files.
- if (file->uid != id)
+ loadedPatches[file->uid] = patch;
+ }
+ // these are 'special'... if not already loaded from instance files, grab them from the metadata repo.
+ auto loadSpecial = [&](const QString & uid, int order)
+ {
+ auto patchVersion = m_instance->getComponentVersion(uid);
+ if(!patchVersion.isEmpty() && !loadedPatches.contains(uid))
{
- file->addProblem(ProblemSeverity::Warning, QObject::tr("load id %1 does not match internal id %2").arg(id, file->uid));
- seen_extra.insert(file->uid);
+ auto patch = std::make_shared<ProfilePatch>(ENV.metadataIndex()->get(uid, patchVersion));
+ patch->setOrder(order);
+ patch->setVanilla(true);
+ patch->setRemovable(true);
+ patch->setMovable(true);
+ loadedPatches[uid] = patch;
}
- auto patchEntry = std::make_shared<ProfilePatch>(file, filename);
- patchEntry->setRemovable(true);
- patchEntry->setMovable(true);
- profile->appendPatch(patchEntry);
- }
- // now load the rest by internal preference.
- using FileEntry = std::tuple<VersionFilePtr, QString>;
- QMultiMap<int, FileEntry> files;
- for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files))
+ };
+ loadSpecial("net.minecraftforge", 5);
+ loadSpecial("com.liteloader", 10);
+
+ // now add all the patches by user sort order
+ ProfileUtils::PatchOrder userOrder;
+ ProfileUtils::readOverrideOrders(FS::PathCombine(m_instance->instanceRoot(), "order.json"), userOrder);
+ bool orderIsDirty = false;
+ for (auto uid : userOrder)
{
- // parse the file
- qDebug() << "Reading" << info.fileName();
- auto file = ProfileUtils::parseJsonFile(info, true);
// ignore builtins
- if (file->uid == "net.minecraft")
- continue;
- if (file->uid == "org.lwjgl")
+ if (uid == "net.minecraft")
continue;
- // do not load versions with broken IDs twice
- if(seen_extra.contains(file->uid))
+ if (uid == "org.lwjgl")
continue;
- // do not load what we already loaded in the first pass
- if (userOrder.contains(file->uid))
+ // ordering has a patch that is gone?
+ if(!loadedPatches.contains(uid))
+ {
+ orderIsDirty = true;
continue;
- files.insert(file->order, std::make_tuple(file, info.filePath()));
+ }
+ profile->appendPatch(loadedPatches.take(uid));
}
- auto appendFilePatch = [&](FileEntry tuple)
+
+ // is there anything left to sort?
+ if(loadedPatches.isEmpty())
{
- VersionFilePtr file;
- QString filename;
- std::tie(file, filename) = tuple;
- auto patchEntry = std::make_shared<ProfilePatch>(file, filename);
- patchEntry->setRemovable(true);
- patchEntry->setMovable(true);
- profile->appendPatch(patchEntry);
- };
- QSet<int> seen;
+ // TODO: save the order here?
+ return;
+ }
+
+ // inserting into multimap by order number as key sorts the patches and detects duplicates
+ QMultiMap<int, ProfilePatchPtr> files;
+ auto iter = loadedPatches.begin();
+ while(iter != loadedPatches.end())
+ {
+ files.insert((*iter)->getOrder(), *iter);
+ iter++;
+ }
+
+ // then just extract the patches and put them in the list
for (auto order : files.keys())
{
- if(seen.contains(order))
- continue;
- seen.insert(order);
const auto &values = files.values(order);
- if(values.size() == 1)
- {
- appendFilePatch(values[0]);
- continue;
- }
- for(auto &file: values)
+ for(auto &value: values)
{
- QStringList list;
- for(auto &file2: values)
- {
- if(file != file2)
- {
- list.append(std::get<0>(file2)->name);
- }
- }
- auto vfileptr = std::get<0>(file);
- vfileptr->addProblem(ProblemSeverity::Warning, QObject::tr("%1 has the same order as the following components:\n%2").arg(vfileptr->name, list.join(", ")));
- appendFilePatch(file);
+ // TODO: put back the insertion of problem messages here, so the user knows about the id duplication
+ profile->appendPatch(value);
}
}
+ // TODO: save the order here?
}
@@ -249,7 +243,10 @@ bool OneSixProfileStrategy::removePatch(ProfilePatchPtr patch)
return false;
}
}
-
+ if(!m_instance->getComponentVersion(patch->getID()).isEmpty())
+ {
+ m_instance->setComponentVersion(patch->getID(), QString());
+ }
auto preRemoveJarMod = [&](JarmodPtr jarMod) -> bool
{