Fix installing forge after liteloader and then removing liteloader. Also formatting.
This commit is contained in:
parent
ece826bdbc
commit
cdd35910c3
@ -151,7 +151,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
bool equals = false;
|
bool equals = false;
|
||||||
// find an entry that matches this one
|
// find an entry that matches this one
|
||||||
for (auto tolib : to->getNonCustomVersion()->libraries)
|
for (auto tolib : to->getVanillaVersion()->libraries)
|
||||||
{
|
{
|
||||||
if (tolib->name() != libName)
|
if (tolib->name() != libName)
|
||||||
continue;
|
continue;
|
||||||
@ -194,7 +194,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
match = expression.match(args);
|
match = expression.match(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!args.isEmpty() && args != to->getNonCustomVersion()->minecraftArguments)
|
if (!args.isEmpty() && args != to->getVanillaVersion()->minecraftArguments)
|
||||||
{
|
{
|
||||||
obj.insert("minecraftArguments", args);
|
obj.insert("minecraftArguments", args);
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
obj.insert("+tweakers", QJsonArray::fromStringList(tweakers));
|
obj.insert("+tweakers", QJsonArray::fromStringList(tweakers));
|
||||||
}
|
}
|
||||||
if (!m_forge_version->processArguments.isEmpty() &&
|
if (!m_forge_version->processArguments.isEmpty() &&
|
||||||
m_forge_version->processArguments != to->getNonCustomVersion()->processArguments)
|
m_forge_version->processArguments != to->getVanillaVersion()->processArguments)
|
||||||
{
|
{
|
||||||
obj.insert("processArguments", m_forge_version->processArguments);
|
obj.insert("processArguments", m_forge_version->processArguments);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
|||||||
d->m_settings->registerSetting("IntendedVersion", "");
|
d->m_settings->registerSetting("IntendedVersion", "");
|
||||||
d->m_settings->registerSetting("ShouldUpdate", false);
|
d->m_settings->registerSetting("ShouldUpdate", false);
|
||||||
d->version.reset(new OneSixVersion(this, this));
|
d->version.reset(new OneSixVersion(this, this));
|
||||||
d->nonCustomVersion.reset(new OneSixVersion(this, this));
|
d->vanillaVersion.reset(new OneSixVersion(this, this));
|
||||||
if (QDir(instanceRoot()).exists("version.json"))
|
if (QDir(instanceRoot()).exists("version.json"))
|
||||||
{
|
{
|
||||||
reloadVersion();
|
reloadVersion();
|
||||||
@ -321,7 +321,7 @@ bool OneSixInstance::reloadVersion(QWidget *widgetParent)
|
|||||||
bool ret = d->version->reload(widgetParent);
|
bool ret = d->version->reload(widgetParent);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
ret = d->nonCustomVersion->reload(widgetParent, true);
|
ret = d->vanillaVersion->reload(widgetParent, true);
|
||||||
}
|
}
|
||||||
emit versionReloaded();
|
emit versionReloaded();
|
||||||
return ret;
|
return ret;
|
||||||
@ -331,7 +331,7 @@ void OneSixInstance::clearVersion()
|
|||||||
{
|
{
|
||||||
I_D(OneSixInstance);
|
I_D(OneSixInstance);
|
||||||
d->version->clear();
|
d->version->clear();
|
||||||
d->nonCustomVersion->clear();
|
d->vanillaVersion->clear();
|
||||||
emit versionReloaded();
|
emit versionReloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,10 +341,10 @@ std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion() const
|
|||||||
return d->version;
|
return d->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<OneSixVersion> OneSixInstance::getNonCustomVersion() const
|
std::shared_ptr<OneSixVersion> OneSixInstance::getVanillaVersion() const
|
||||||
{
|
{
|
||||||
I_D(const OneSixInstance);
|
I_D(const OneSixInstance);
|
||||||
return d->nonCustomVersion;
|
return d->vanillaVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OneSixInstance::defaultBaseJar() const
|
QString OneSixInstance::defaultBaseJar() const
|
||||||
|
@ -57,8 +57,8 @@ public:
|
|||||||
void clearVersion();
|
void clearVersion();
|
||||||
/// get the current full version info
|
/// get the current full version info
|
||||||
std::shared_ptr<OneSixVersion> getFullVersion() const;
|
std::shared_ptr<OneSixVersion> getFullVersion() const;
|
||||||
/// gets the current version info, excluding custom.json
|
/// gets the current version info, but only for version.json
|
||||||
std::shared_ptr<OneSixVersion> getNonCustomVersion() const;
|
std::shared_ptr<OneSixVersion> getVanillaVersion() const;
|
||||||
/// is the current version original, or custom?
|
/// is the current version original, or custom?
|
||||||
virtual bool versionIsCustom() override;
|
virtual bool versionIsCustom() override;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
struct OneSixInstancePrivate : public BaseInstancePrivate
|
struct OneSixInstancePrivate : public BaseInstancePrivate
|
||||||
{
|
{
|
||||||
std::shared_ptr<OneSixVersion> version;
|
std::shared_ptr<OneSixVersion> version;
|
||||||
std::shared_ptr<OneSixVersion> nonCustomVersion;
|
std::shared_ptr<OneSixVersion> vanillaVersion;
|
||||||
std::shared_ptr<ModList> loader_mod_list;
|
std::shared_ptr<ModList> loader_mod_list;
|
||||||
std::shared_ptr<ModList> resource_pack_list;
|
std::shared_ptr<ModList> resource_pack_list;
|
||||||
};
|
};
|
||||||
|
@ -26,10 +26,10 @@ OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent)
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersion::reload(QWidget *widgetParent, const bool excludeCustom)
|
bool OneSixVersion::reload(QWidget *widgetParent, const bool onlyVanilla)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, excludeCustom);
|
bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, onlyVanilla);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
virtual int columnCount(const QModelIndex &parent) const;
|
virtual int columnCount(const QModelIndex &parent) const;
|
||||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
bool reload(QWidget *widgetParent, const bool excludeCustom = false);
|
bool reload(QWidget *widgetParent, const bool onlyVanilla = false);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
@ -280,7 +280,8 @@ struct VersionFile
|
|||||||
QJsonValue tweakersVal = root.value("tweakers");
|
QJsonValue tweakersVal = root.value("tweakers");
|
||||||
if (!tweakersVal.isArray())
|
if (!tweakersVal.isArray())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << filename << "contains a 'tweakers' field, but it's not an array";
|
QLOG_ERROR() << filename
|
||||||
|
<< "contains a 'tweakers' field, but it's not an array";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.shouldOverwriteTweakers = true;
|
out.shouldOverwriteTweakers = true;
|
||||||
@ -289,7 +290,8 @@ struct VersionFile
|
|||||||
{
|
{
|
||||||
if (!tweakerVal.isString())
|
if (!tweakerVal.isString())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << filename << "contains a 'tweakers' field entry that's not a string";
|
QLOG_ERROR() << filename
|
||||||
|
<< "contains a 'tweakers' field entry that's not a string";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.overwriteTweakers.append(tweakerVal.toString());
|
out.overwriteTweakers.append(tweakerVal.toString());
|
||||||
@ -300,7 +302,8 @@ struct VersionFile
|
|||||||
QJsonValue tweakersVal = root.value("+tweakers");
|
QJsonValue tweakersVal = root.value("+tweakers");
|
||||||
if (!tweakersVal.isArray())
|
if (!tweakersVal.isArray())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << filename << "contains a '+tweakers' field, but it's not an array";
|
QLOG_ERROR() << filename
|
||||||
|
<< "contains a '+tweakers' field, but it's not an array";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
QJsonArray tweakers = root.value("+tweakers").toArray();
|
QJsonArray tweakers = root.value("+tweakers").toArray();
|
||||||
@ -308,7 +311,8 @@ struct VersionFile
|
|||||||
{
|
{
|
||||||
if (!tweakerVal.isString())
|
if (!tweakerVal.isString())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << filename << "contains a '+tweakers' field entry that's not a string";
|
QLOG_ERROR() << filename
|
||||||
|
<< "contains a '+tweakers' field entry that's not a string";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.addTweakers.append(tweakerVal.toString());
|
out.addTweakers.append(tweakerVal.toString());
|
||||||
@ -319,7 +323,8 @@ struct VersionFile
|
|||||||
QJsonValue tweakersVal = root.value("-tweakers");
|
QJsonValue tweakersVal = root.value("-tweakers");
|
||||||
if (!tweakersVal.isArray())
|
if (!tweakersVal.isArray())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << filename << "contains a '-tweakers' field, but it's not an array";
|
QLOG_ERROR() << filename
|
||||||
|
<< "contains a '-tweakers' field, but it's not an array";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.shouldOverwriteTweakers = true;
|
out.shouldOverwriteTweakers = true;
|
||||||
@ -328,7 +333,8 @@ struct VersionFile
|
|||||||
{
|
{
|
||||||
if (!tweakerVal.isString())
|
if (!tweakerVal.isString())
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << filename << "contains a '-tweakers' field entry that's not a string";
|
QLOG_ERROR() << filename
|
||||||
|
<< "contains a '-tweakers' field entry that's not a string";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
out.removeTweakers.append(tweakerVal.toString());
|
out.removeTweakers.append(tweakerVal.toString());
|
||||||
@ -648,7 +654,9 @@ struct VersionFile
|
|||||||
{
|
{
|
||||||
|
|
||||||
const int startOfVersion = lib.name.lastIndexOf(':') + 1;
|
const int startOfVersion = lib.name.lastIndexOf(':') + 1;
|
||||||
const int index = findLibrary(version->libraries, QString(lib.name).replace(startOfVersion, INT_MAX, '*'));
|
const int index =
|
||||||
|
findLibrary(version->libraries,
|
||||||
|
QString(lib.name).replace(startOfVersion, INT_MAX, '*'));
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
if (lib.insertType == Library::Append)
|
if (lib.insertType == Library::Append)
|
||||||
@ -665,11 +673,14 @@ struct VersionFile
|
|||||||
auto otherLib = version->libraries.at(index);
|
auto otherLib = version->libraries.at(index);
|
||||||
const Util::Version ourVersion = lib.name.mid(startOfVersion, INT_MAX);
|
const Util::Version ourVersion = lib.name.mid(startOfVersion, INT_MAX);
|
||||||
const Util::Version otherVersion = otherLib->version();
|
const Util::Version otherVersion = otherLib->version();
|
||||||
// if the existing version is a hard dependency we can either use it or fail, but we can't change it
|
// if the existing version is a hard dependency we can either use it or
|
||||||
|
// fail, but we can't change it
|
||||||
if (otherLib->dependType == OneSixLibrary::Hard)
|
if (otherLib->dependType == OneSixLibrary::Hard)
|
||||||
{
|
{
|
||||||
// we need a higher version, or we're hard to and the versions aren't equal
|
// we need a higher version, or we're hard to and the versions aren't
|
||||||
if (ourVersion > otherVersion || (lib.dependType == Library::Hard && ourVersion != otherVersion))
|
// equal
|
||||||
|
if (ourVersion > otherVersion ||
|
||||||
|
(lib.dependType == Library::Hard && ourVersion != otherVersion))
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Error resolving library dependencies between"
|
QLOG_ERROR() << "Error resolving library dependencies between"
|
||||||
<< otherLib->rawName() << "and" << lib.name << "in"
|
<< otherLib->rawName() << "and" << lib.name << "in"
|
||||||
@ -695,7 +706,8 @@ struct VersionFile
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// our version is smaller than the existing version, but we require it: fail
|
// our version is smaller than the existing version, but we require
|
||||||
|
// it: fail
|
||||||
if (lib.dependType == Library::Hard)
|
if (lib.dependType == Library::Hard)
|
||||||
{
|
{
|
||||||
QLOG_ERROR() << "Error resolving library dependencies between"
|
QLOG_ERROR() << "Error resolving library dependencies between"
|
||||||
@ -753,13 +765,13 @@ OneSixVersionBuilder::OneSixVersionBuilder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::build(OneSixVersion *version, OneSixInstance *instance,
|
bool OneSixVersionBuilder::build(OneSixVersion *version, OneSixInstance *instance,
|
||||||
QWidget *widgetParent, const bool excludeCustom)
|
QWidget *widgetParent, const bool onlyVanilla)
|
||||||
{
|
{
|
||||||
OneSixVersionBuilder builder;
|
OneSixVersionBuilder builder;
|
||||||
builder.m_version = version;
|
builder.m_version = version;
|
||||||
builder.m_instance = instance;
|
builder.m_instance = instance;
|
||||||
builder.m_widgetParent = widgetParent;
|
builder.m_widgetParent = widgetParent;
|
||||||
return builder.build(excludeCustom);
|
return builder.build(onlyVanilla);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
||||||
@ -771,7 +783,7 @@ bool OneSixVersionBuilder::read(OneSixVersion *version, const QJsonObject &obj)
|
|||||||
return builder.read(obj);
|
return builder.read(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OneSixVersionBuilder::build(const bool excludeCustom)
|
bool OneSixVersionBuilder::build(const bool onlyVanilla)
|
||||||
{
|
{
|
||||||
m_version->clear();
|
m_version->clear();
|
||||||
|
|
||||||
@ -831,6 +843,9 @@ bool OneSixVersionBuilder::build(const bool excludeCustom)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!onlyVanilla)
|
||||||
|
{
|
||||||
|
|
||||||
// patches/
|
// patches/
|
||||||
{
|
{
|
||||||
// load all, put into map for ordering, apply in the right order
|
// load all, put into map for ordering, apply in the right order
|
||||||
@ -856,9 +871,8 @@ bool OneSixVersionBuilder::build(const bool excludeCustom)
|
|||||||
{
|
{
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
m_widgetParent, QObject::tr("Error"),
|
m_widgetParent, QObject::tr("Error"),
|
||||||
QObject::tr(
|
QObject::tr("Error while applying %1. Please check MultiMC-0.log "
|
||||||
"Error while applying %1. Please check MultiMC-0.log for more info.")
|
"for more info.").arg(filePair.first));
|
||||||
.arg(filePair.first));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -866,7 +880,6 @@ bool OneSixVersionBuilder::build(const bool excludeCustom)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// user.json
|
// user.json
|
||||||
if (!excludeCustom)
|
|
||||||
{
|
{
|
||||||
if (QFile::exists(root.absoluteFilePath("user.json")))
|
if (QFile::exists(root.absoluteFilePath("user.json")))
|
||||||
{
|
{
|
||||||
@ -895,6 +908,7 @@ bool OneSixVersionBuilder::build(const bool excludeCustom)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// some final touches
|
// some final touches
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ class OneSixVersionBuilder
|
|||||||
{
|
{
|
||||||
OneSixVersionBuilder();
|
OneSixVersionBuilder();
|
||||||
public:
|
public:
|
||||||
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent, const bool excludeCustom);
|
static bool build(OneSixVersion *version, OneSixInstance *instance, QWidget *widgetParent, const bool onlyVanilla);
|
||||||
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
static bool read(OneSixVersion *version, const QJsonObject &obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -36,7 +36,7 @@ private:
|
|||||||
OneSixInstance *m_instance;
|
OneSixInstance *m_instance;
|
||||||
QWidget *m_widgetParent;
|
QWidget *m_widgetParent;
|
||||||
|
|
||||||
bool build(const bool excludeCustom);
|
bool build(const bool onlyVanilla);
|
||||||
bool read(const QJsonObject &obj);
|
bool read(const QJsonObject &obj);
|
||||||
|
|
||||||
bool read(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out);
|
bool read(const QFileInfo &fileInfo, const bool requireOrder, VersionFile *out);
|
||||||
|
Loading…
Reference in New Issue
Block a user