summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2017-11-11 01:38:31 +0100
committerPetr Mrázek <peterix@gmail.com>2017-12-03 01:22:34 +0100
commit85ae710d407eb31527183d5f8bec0399eb209f33 (patch)
tree23647a83506ad3bd052720fb40068240e9768481 /api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
parent17c8f31a09da6bdfc4aa7f67b2ca86b791f2ba96 (diff)
downloadMultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar.gz
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar.lz
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.tar.xz
MultiMC-85ae710d407eb31527183d5f8bec0399eb209f33.zip
GH-2026 implement changes necessary to support 1.13 snapshots
Diffstat (limited to 'api/logic/minecraft/legacy/LegacyUpgradeTask.cpp')
-rw-r--r--api/logic/minecraft/legacy/LegacyUpgradeTask.cpp101
1 files changed, 51 insertions, 50 deletions
diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
index fab48005..6cda3e4d 100644
--- a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
+++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
@@ -67,69 +67,70 @@ void LegacyUpgradeTask::copyFinished()
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
instanceSettings->registerSetting("InstanceType", "Legacy");
instanceSettings->set("InstanceType", "OneSix");
- std::shared_ptr<MinecraftInstance> inst(new MinecraftInstance(m_globalSettings, instanceSettings, m_stagingPath));
- inst->setName(m_newName);
- inst->init();
-
- QString preferredVersionNumber = decideVersion(legacyInst->currentVersionId(), legacyInst->intendedVersionId());
- if(preferredVersionNumber.isNull())
+ // NOTE: this scope ensures the instance is fully saved before we emitSucceeded
{
- // try to decide version based on the jar(s?)
- preferredVersionNumber = classparser::GetMinecraftJarVersion(legacyInst->baseJar());
+ MinecraftInstance inst(m_globalSettings, instanceSettings, m_stagingPath);
+ inst.setName(m_newName);
+ inst.init();
+
+ QString preferredVersionNumber = decideVersion(legacyInst->currentVersionId(), legacyInst->intendedVersionId());
if(preferredVersionNumber.isNull())
{
- preferredVersionNumber = classparser::GetMinecraftJarVersion(legacyInst->runnableJar());
+ // try to decide version based on the jar(s?)
+ preferredVersionNumber = classparser::GetMinecraftJarVersion(legacyInst->baseJar());
if(preferredVersionNumber.isNull())
{
- emitFailed(tr("Could not decide Minecraft version."));
- return;
+ preferredVersionNumber = classparser::GetMinecraftJarVersion(legacyInst->runnableJar());
+ if(preferredVersionNumber.isNull())
+ {
+ emitFailed(tr("Could not decide Minecraft version."));
+ return;
+ }
}
}
- }
- inst->setComponentVersion("net.minecraft", preferredVersionNumber);
+ auto components = inst.getComponentList();
+ components->buildingFromScratch();
+ components->setComponentVersion("net.minecraft", preferredVersionNumber, true);
- // BUG: reloadProfile should not be necessary, but setComponentVersion voids the profile created by init()!
- inst->reloadProfile();
- auto profile = inst->getComponentList();
-
- if(legacyInst->shouldUseCustomBaseJar())
- {
- QString jarPath = legacyInst->customBaseJar();
- qDebug() << "Base jar is custom! : " << jarPath;
- // FIXME: handle case when the jar is unreadable?
- // TODO: check the hash, if it's the same as the upstream jar, do not do this
- profile->installCustomJar(jarPath);
- }
+ if(legacyInst->shouldUseCustomBaseJar())
+ {
+ QString jarPath = legacyInst->customBaseJar();
+ qDebug() << "Base jar is custom! : " << jarPath;
+ // FIXME: handle case when the jar is unreadable?
+ // TODO: check the hash, if it's the same as the upstream jar, do not do this
+ components->installCustomJar(jarPath);
+ }
- auto jarMods = legacyInst->getJarMods();
- for(auto & jarMod: jarMods)
- {
- QString modPath = jarMod.filename().absoluteFilePath();
- qDebug() << "jarMod: " << modPath;
- profile->installJarMods({modPath});
- }
+ auto jarMods = legacyInst->getJarMods();
+ for(auto & jarMod: jarMods)
+ {
+ QString modPath = jarMod.filename().absoluteFilePath();
+ qDebug() << "jarMod: " << modPath;
+ components->installJarMods({modPath});
+ }
- // remove all the extra garbage we no longer need
- auto removeAll = [&](const QString &root, const QStringList &things)
- {
- for(auto &thing : things)
+ // remove all the extra garbage we no longer need
+ auto removeAll = [&](const QString &root, const QStringList &things)
{
- auto removePath = FS::PathCombine(root, thing);
- QFileInfo stat(removePath);
- if(stat.isDir())
+ for(auto &thing : things)
{
- FS::deletePath(removePath);
+ auto removePath = FS::PathCombine(root, thing);
+ QFileInfo stat(removePath);
+ if(stat.isDir())
+ {
+ FS::deletePath(removePath);
+ }
+ else
+ {
+ QFile::remove(removePath);
+ }
}
- else
- {
- QFile::remove(removePath);
- }
- }
- };
- QStringList rootRemovables = {"modlist", "version", "instMods"};
- QStringList mcRemovables = {"bin", "MultiMCLauncher.jar", "icon.png"};
- removeAll(inst->instanceRoot(), rootRemovables);
- removeAll(inst->minecraftRoot(), mcRemovables);
+ };
+ QStringList rootRemovables = {"modlist", "version", "instMods"};
+ QStringList mcRemovables = {"bin", "MultiMCLauncher.jar", "icon.png"};
+ removeAll(inst.instanceRoot(), rootRemovables);
+ removeAll(inst.minecraftRoot(), mcRemovables);
+ }
emitSucceeded();
}