Skip to content

Commit

Permalink
NOISSUE preserve minecraft.jar while migrating Legacy instances
Browse files Browse the repository at this point in the history
It can be manually modded. It must be preserved when it's the only jar around.
  • Loading branch information
peterix committed Mar 23, 2018
1 parent 106155d commit a1c7138
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
20 changes: 20 additions & 0 deletions api/logic/minecraft/legacy/LegacyInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectP
settings->registerSetting("CustomBaseJar", "");
}

QString LegacyInstance::mainJarToPreserve() const
{
bool customJar = m_settings->get("UseCustomBaseJar").toBool();
if(customJar)
{
auto base = baseJar();
if(QFile::exists(base))
{
return base;
}
}
auto runnable = runnableJar();
if(QFile::exists(runnable))
{
return runnable;
}
return QString();
}


QString LegacyInstance::baseJar() const
{
bool customJar = m_settings->get("UseCustomBaseJar").toBool();
Expand Down
3 changes: 3 additions & 0 deletions api/logic/minecraft/legacy/LegacyInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ class MULTIMC_LOGIC_EXPORT LegacyInstance : public BaseInstance
/// the default custom base jar of this instance
QString defaultCustomBaseJar() const;

// the main jar that we actually want to keep when migrating the instance
QString mainJarToPreserve() const;

/*!
* Whether or not custom base jar is used
*/
Expand Down
6 changes: 3 additions & 3 deletions api/logic/minecraft/legacy/LegacyUpgradeTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ void LegacyUpgradeTask::copyFinished()
components->buildingFromScratch();
components->setComponentVersion("net.minecraft", preferredVersionNumber, true);

if(legacyInst->shouldUseCustomBaseJar())
QString jarPath = legacyInst->mainJarToPreserve();
if(!jarPath.isNull())
{
QString jarPath = legacyInst->customBaseJar();
qDebug() << "Base jar is custom! : " << jarPath;
qDebug() << "Preserving base jar! : " << 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);
Expand Down

0 comments on commit a1c7138

Please sign in to comment.