GH-2026 implement changes necessary to support 1.13 snapshots

This commit is contained in:
Petr Mrázek
2017-11-11 01:38:31 +01:00
parent 17c8f31a09
commit 85ae710d40
51 changed files with 2632 additions and 1058 deletions

View File

@ -71,7 +71,7 @@ bool LegacyInstance::shouldUseCustomBaseJar() const
}
shared_qobject_ptr<Task> LegacyInstance::createUpdateTask()
shared_qobject_ptr<Task> LegacyInstance::createUpdateTask(Net::Mode)
{
return nullptr;
}

View File

@ -93,7 +93,7 @@ public:
};
virtual bool shouldUpdate() const;
virtual shared_qobject_ptr<Task> createUpdateTask() override;
virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override;
virtual QString typeName() const override;

View File

@ -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);
}
auto jarMods = legacyInst->getJarMods();
for(auto & jarMod: jarMods)
{
QString modPath = jarMod.filename().absoluteFilePath();
qDebug() << "jarMod: " << modPath;
profile->installJarMods({modPath});
}
// remove all the extra garbage we no longer need
auto removeAll = [&](const QString &root, const QStringList &things)
{
for(auto &thing : things)
if(legacyInst->shouldUseCustomBaseJar())
{
auto removePath = FS::PathCombine(root, thing);
QFileInfo stat(removePath);
if(stat.isDir())
{
FS::deletePath(removePath);
}
else
{
QFile::remove(removePath);
}
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);
}
};
QStringList rootRemovables = {"modlist", "version", "instMods"};
QStringList mcRemovables = {"bin", "MultiMCLauncher.jar", "icon.png"};
removeAll(inst->instanceRoot(), rootRemovables);
removeAll(inst->minecraftRoot(), mcRemovables);
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)
{
auto removePath = FS::PathCombine(root, thing);
QFileInfo stat(removePath);
if(stat.isDir())
{
FS::deletePath(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);
}
emitSucceeded();
}