NOISSUE resolve library activeness during application to profile
This commit is contained in:
parent
f63d1bc99c
commit
576d808d71
@ -228,40 +228,6 @@ bool MinecraftProfile::revertToVanilla()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<Library> > MinecraftProfile::getActiveNormalLibs() const
|
|
||||||
{
|
|
||||||
QList<std::shared_ptr<Library> > output;
|
|
||||||
for (auto lib : libraries)
|
|
||||||
{
|
|
||||||
if (lib->isActive() && !lib->isNative())
|
|
||||||
{
|
|
||||||
for (auto other : output)
|
|
||||||
{
|
|
||||||
if (other->rawName() == lib->rawName())
|
|
||||||
{
|
|
||||||
qWarning() << "Multiple libraries with name" << lib->rawName() << "in library list!";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output.append(lib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<std::shared_ptr<Library> > MinecraftProfile::getActiveNativeLibs() const
|
|
||||||
{
|
|
||||||
QList<std::shared_ptr<Library> > output;
|
|
||||||
for (auto lib : libraries)
|
|
||||||
{
|
|
||||||
if (lib->isActive() && lib->isNative())
|
|
||||||
{
|
|
||||||
output.append(lib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant MinecraftProfile::data(const QModelIndex &index, int role) const
|
QVariant MinecraftProfile::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@ -456,13 +422,9 @@ void MinecraftProfile::applyMainClass(const QString& mainClass)
|
|||||||
applyString(mainClass, this->mainClass);
|
applyString(mainClass, this->mainClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftProfile::applyMinecraftArguments(const QString& minecraftArguments, bool isMinecraft)
|
void MinecraftProfile::applyMinecraftArguments(const QString& minecraftArguments)
|
||||||
{
|
{
|
||||||
applyString(minecraftArguments, this->minecraftArguments);
|
applyString(minecraftArguments, this->minecraftArguments);
|
||||||
if(isMinecraft)
|
|
||||||
{
|
|
||||||
applyString(minecraftArguments, this->vanillaMinecraftArguments);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftProfile::applyMinecraftVersionType(const QString& type)
|
void MinecraftProfile::applyMinecraftVersionType(const QString& type)
|
||||||
@ -511,7 +473,7 @@ static int findLibraryByName(QList<LibraryPtr> haystack, const GradleSpecifier &
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecraftProfile::applyLibrary(LibraryPtr library, bool isMinecraft)
|
void MinecraftProfile::applyLibrary(LibraryPtr library)
|
||||||
{
|
{
|
||||||
auto insert = [&](QList<LibraryPtr> & into)
|
auto insert = [&](QList<LibraryPtr> & into)
|
||||||
{
|
{
|
||||||
@ -531,10 +493,17 @@ void MinecraftProfile::applyLibrary(LibraryPtr library, bool isMinecraft)
|
|||||||
into.replace(index, libraryCopy);
|
into.replace(index, libraryCopy);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
insert(libraries);
|
if(!library->isActive())
|
||||||
if(isMinecraft)
|
|
||||||
{
|
{
|
||||||
insert(vanillaLibraries);
|
return;
|
||||||
|
}
|
||||||
|
if(library->isNative())
|
||||||
|
{
|
||||||
|
insert(nativeLibraries);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
insert(libraries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,11 +565,6 @@ QString MinecraftProfile::getMinecraftArguments() const
|
|||||||
return minecraftArguments;
|
return minecraftArguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MinecraftProfile::getVanillaMinecraftArguments() const
|
|
||||||
{
|
|
||||||
return vanillaMinecraftArguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QList<JarmodPtr> & MinecraftProfile::getJarMods() const
|
const QList<JarmodPtr> & MinecraftProfile::getJarMods() const
|
||||||
{
|
{
|
||||||
return jarMods;
|
return jarMods;
|
||||||
@ -611,11 +575,12 @@ const QList<LibraryPtr> & MinecraftProfile::getLibraries() const
|
|||||||
return libraries;
|
return libraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<LibraryPtr> & MinecraftProfile::getVanillaLibraries() const
|
const QList<LibraryPtr> & MinecraftProfile::getNativeLibraries() const
|
||||||
{
|
{
|
||||||
return vanillaLibraries;
|
return nativeLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MinecraftProfile::installJarMods(QStringList selectedFiles)
|
void MinecraftProfile::installJarMods(QStringList selectedFiles)
|
||||||
{
|
{
|
||||||
m_strategy->installJarMods(selectedFiles);
|
m_strategy->installJarMods(selectedFiles);
|
||||||
|
@ -92,21 +92,15 @@ public:
|
|||||||
void applyMinecraftVersion(const QString& id);
|
void applyMinecraftVersion(const QString& id);
|
||||||
void applyMainClass(const QString& mainClass);
|
void applyMainClass(const QString& mainClass);
|
||||||
void applyAppletClass(const QString& appletClass);
|
void applyAppletClass(const QString& appletClass);
|
||||||
void applyMinecraftArguments(const QString& minecraftArguments, bool isMinecraft);
|
void applyMinecraftArguments(const QString& minecraftArguments);
|
||||||
void applyMinecraftVersionType(const QString& type);
|
void applyMinecraftVersionType(const QString& type);
|
||||||
void applyMinecraftAssets(const QString& assets);
|
void applyMinecraftAssets(const QString& assets);
|
||||||
void applyTraits(const QSet<QString> &traits);
|
void applyTraits(const QSet<QString> &traits);
|
||||||
void applyTweakers(const QStringList &tweakers);
|
void applyTweakers(const QStringList &tweakers);
|
||||||
void applyJarMods(const QList<JarmodPtr>&jarMods);
|
void applyJarMods(const QList<JarmodPtr> &jarMods);
|
||||||
void applyLibrary(LibraryPtr library, bool isMinecraft);
|
void applyLibrary(LibraryPtr library);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// get all java libraries that belong to the classpath
|
|
||||||
QList<LibraryPtr> getActiveNormalLibs() const;
|
|
||||||
|
|
||||||
/// get all native libraries that need to be available to the process
|
|
||||||
QList<LibraryPtr> getActiveNativeLibs() const;
|
|
||||||
|
|
||||||
QString getMinecraftVersion() const;
|
QString getMinecraftVersion() const;
|
||||||
QString getMainClass() const;
|
QString getMainClass() const;
|
||||||
QString getAppletClass() const;
|
QString getAppletClass() const;
|
||||||
@ -118,7 +112,7 @@ public:
|
|||||||
const QStringList & getTweakers() const;
|
const QStringList & getTweakers() const;
|
||||||
const QList<JarmodPtr> & getJarMods() const;
|
const QList<JarmodPtr> & getJarMods() const;
|
||||||
const QList<LibraryPtr> & getLibraries() const;
|
const QList<LibraryPtr> & getLibraries() const;
|
||||||
const QList<LibraryPtr> & getVanillaLibraries() const;
|
const QList<LibraryPtr> & getNativeLibraries() const;
|
||||||
bool hasTrait(const QString & trait) const;
|
bool hasTrait(const QString & trait) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -158,9 +152,6 @@ protected: /* data */
|
|||||||
*/
|
*/
|
||||||
QString minecraftArguments;
|
QString minecraftArguments;
|
||||||
|
|
||||||
/// Same as above, but only for vanilla
|
|
||||||
QString vanillaMinecraftArguments;
|
|
||||||
|
|
||||||
/// A list of all tweaker classes
|
/// A list of all tweaker classes
|
||||||
QStringList tweakers;
|
QStringList tweakers;
|
||||||
|
|
||||||
@ -170,11 +161,11 @@ protected: /* data */
|
|||||||
/// The applet class, for some very old minecraft releases
|
/// The applet class, for some very old minecraft releases
|
||||||
QString appletClass;
|
QString appletClass;
|
||||||
|
|
||||||
/// the list of libs - both active and inactive, native and java
|
/// the list of libraries
|
||||||
QList<LibraryPtr> libraries;
|
QList<LibraryPtr> libraries;
|
||||||
|
|
||||||
/// same, but only vanilla.
|
/// the list of native libraries
|
||||||
QList<LibraryPtr> vanillaLibraries;
|
QList<LibraryPtr> nativeLibraries;
|
||||||
|
|
||||||
/// traits, collected from all the version files (version files can only add)
|
/// traits, collected from all the version files (version files can only add)
|
||||||
QSet<QString> traits;
|
QSet<QString> traits;
|
||||||
|
@ -166,7 +166,7 @@ void MinecraftVersion::applyTo(MinecraftProfile *version)
|
|||||||
version->applyMinecraftVersion(m_descriptor);
|
version->applyMinecraftVersion(m_descriptor);
|
||||||
version->applyMainClass(m_mainClass);
|
version->applyMainClass(m_mainClass);
|
||||||
version->applyAppletClass(m_appletClass);
|
version->applyAppletClass(m_appletClass);
|
||||||
version->applyMinecraftArguments(" ${auth_player_name} ${auth_session}", true); // all builtin versions are legacy
|
version->applyMinecraftArguments(" ${auth_player_name} ${auth_session}"); // all builtin versions are legacy
|
||||||
version->applyMinecraftVersionType(m_type);
|
version->applyMinecraftVersionType(m_type);
|
||||||
version->applyTraits(m_traits);
|
version->applyTraits(m_traits);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
auto libObj = requireObject(libVal);
|
auto libObj = requireObject(libVal);
|
||||||
|
|
||||||
auto lib = MojangVersionFormat::libraryFromJson(libObj, filename);
|
auto lib = MojangVersionFormat::libraryFromJson(libObj, filename);
|
||||||
out->addLibs.append(lib);
|
out->libraries.append(lib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(root.contains("downloads"))
|
if(root.contains("downloads"))
|
||||||
@ -213,10 +213,10 @@ QJsonDocument versionFileToJson(VersionFilePtr patch)
|
|||||||
root.insert("minimumLauncherVersion", patch->minimumLauncherVersion);
|
root.insert("minimumLauncherVersion", patch->minimumLauncherVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!patch->addLibs.isEmpty())
|
if (!patch->libraries.isEmpty())
|
||||||
{
|
{
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
for (auto value: patch->addLibs)
|
for (auto value: patch->libraries)
|
||||||
{
|
{
|
||||||
array.append(MojangVersionFormat::libraryToJson(value.get()));
|
array.append(MojangVersionFormat::libraryToJson(value.get()));
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,6 @@ void removeLwjglFromPatch(VersionFilePtr patch)
|
|||||||
}
|
}
|
||||||
libs = filteredLibs;
|
libs = filteredLibs;
|
||||||
};
|
};
|
||||||
filter(patch->addLibs);
|
filter(patch->libraries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,11 @@ void VersionFile::applyTo(MinecraftProfile *version)
|
|||||||
throw MinecraftVersionMismatch(fileId, mcVersion, theirVersion);
|
throw MinecraftVersionMismatch(fileId, mcVersion, theirVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool is_minecraft = isMinecraftVersion();
|
|
||||||
version->applyMinecraftVersion(id);
|
version->applyMinecraftVersion(id);
|
||||||
version->applyMainClass(mainClass);
|
version->applyMainClass(mainClass);
|
||||||
version->applyAppletClass(appletClass);
|
version->applyAppletClass(appletClass);
|
||||||
version->applyMinecraftArguments(minecraftArguments, is_minecraft);
|
version->applyMinecraftArguments(minecraftArguments);
|
||||||
if (is_minecraft)
|
if (isMinecraftVersion())
|
||||||
{
|
{
|
||||||
version->applyMinecraftVersionType(type);
|
version->applyMinecraftVersionType(type);
|
||||||
}
|
}
|
||||||
@ -47,8 +46,8 @@ void VersionFile::applyTo(MinecraftProfile *version)
|
|||||||
version->applyJarMods(jarMods);
|
version->applyJarMods(jarMods);
|
||||||
version->applyTraits(traits);
|
version->applyTraits(traits);
|
||||||
|
|
||||||
for (auto addedLibrary : addLibs)
|
for (auto library : libraries)
|
||||||
{
|
{
|
||||||
version->applyLibrary(addedLibrary, isMinecraftVersion());
|
version->applyLibrary(library);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ public: /* data */
|
|||||||
QStringList addTweakers;
|
QStringList addTweakers;
|
||||||
|
|
||||||
/// Mojang: list of libraries to add to the version
|
/// Mojang: list of libraries to add to the version
|
||||||
QList<LibraryPtr> addLibs;
|
QList<LibraryPtr> libraries;
|
||||||
|
|
||||||
/// MultiMC: list of attached traits of this version file - used to enable features
|
/// MultiMC: list of attached traits of this version file - used to enable features
|
||||||
QSet<QString> traits;
|
QSet<QString> traits;
|
||||||
|
@ -193,6 +193,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
|
|
||||||
QJsonObject libObj = OneSixVersionFormat::libraryToJson(lib.get());
|
QJsonObject libObj = OneSixVersionFormat::libraryToJson(lib.get());
|
||||||
|
|
||||||
|
// FIXME: use upstream Minecraft version files instead, not the processed profile!
|
||||||
|
/*
|
||||||
bool equals = false;
|
bool equals = false;
|
||||||
// find an entry that matches this one
|
// find an entry that matches this one
|
||||||
for (auto tolib : to->getMinecraftProfile()->getVanillaLibraries())
|
for (auto tolib : to->getMinecraftProfile()->getVanillaLibraries())
|
||||||
@ -209,6 +211,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
libraries.append(libObj);
|
libraries.append(libObj);
|
||||||
}
|
}
|
||||||
obj.insert("libraries", libraries);
|
obj.insert("libraries", libraries);
|
||||||
@ -225,7 +228,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
match = expression.match(args);
|
match = expression.match(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!args.isEmpty() && args != to->getMinecraftProfile()->getVanillaMinecraftArguments())
|
// FIXME: use upstream Minecraft version files instead, not the processed profile!
|
||||||
|
if (!args.isEmpty() /* && args != to->getMinecraftProfile()->getVanillaMinecraftArguments() */)
|
||||||
{
|
{
|
||||||
obj.insert("minecraftArguments", args);
|
obj.insert("minecraftArguments", args);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
// FIXME: this should be here, but it needs us to be able to deal with multiple libraries paths
|
// FIXME: this should be here, but it needs us to be able to deal with multiple libraries paths
|
||||||
// OneSixProfileStrategy::loadDefaultBuiltinPatches();
|
// OneSixProfileStrategy::loadDefaultBuiltinPatches();
|
||||||
auto mcVersion = m_instance->intendedVersionId();
|
auto mcVersion = m_instance->intendedVersionId();
|
||||||
|
auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance);
|
||||||
|
|
||||||
ProfilePatchPtr minecraftPatch;
|
ProfilePatchPtr minecraftPatch;
|
||||||
{
|
{
|
||||||
@ -34,6 +35,11 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
{
|
{
|
||||||
file->version = mcVersion;
|
file->version = mcVersion;
|
||||||
}
|
}
|
||||||
|
for(auto addLib: file->libraries)
|
||||||
|
{
|
||||||
|
addLib->setHint("local");
|
||||||
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
||||||
|
}
|
||||||
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
|
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -44,7 +50,6 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
}
|
}
|
||||||
profile->appendPatch(minecraftPatch);
|
profile->appendPatch(minecraftPatch);
|
||||||
|
|
||||||
auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance);
|
|
||||||
ProfilePatchPtr packPatch;
|
ProfilePatchPtr packPatch;
|
||||||
{
|
{
|
||||||
auto mcJson = m_instance->minecraftRoot() + "/pack.json";
|
auto mcJson = m_instance->minecraftRoot() + "/pack.json";
|
||||||
@ -55,7 +60,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
|
|
||||||
// adapt the loaded file - the FTB patch file format is different than ours.
|
// adapt the loaded file - the FTB patch file format is different than ours.
|
||||||
file->id.clear();
|
file->id.clear();
|
||||||
for(auto addLib: file->addLibs)
|
for(auto addLib: file->libraries)
|
||||||
{
|
{
|
||||||
addLib->setHint("local");
|
addLib->setHint("local");
|
||||||
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
||||||
|
@ -179,7 +179,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
|
|||||||
|
|
||||||
// libraries and class path.
|
// libraries and class path.
|
||||||
{
|
{
|
||||||
auto libs = m_version->getActiveNormalLibs();
|
auto libs = m_version->getLibraries();
|
||||||
for (auto lib : libs)
|
for (auto lib : libs)
|
||||||
{
|
{
|
||||||
launchScript += "cp " + QFileInfo(lib->storagePath()).absoluteFilePath() + "\n";
|
launchScript += "cp " + QFileInfo(lib->storagePath()).absoluteFilePath() + "\n";
|
||||||
@ -234,7 +234,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
|
|||||||
// native libraries (mostly LWJGL)
|
// native libraries (mostly LWJGL)
|
||||||
{
|
{
|
||||||
QDir natives_dir(FS::PathCombine(instanceRoot(), "natives/"));
|
QDir natives_dir(FS::PathCombine(instanceRoot(), "natives/"));
|
||||||
for (auto native : m_version->getActiveNativeLibs())
|
for (auto native : m_version->getNativeLibraries())
|
||||||
{
|
{
|
||||||
QFileInfo finfo(native->storagePath());
|
QFileInfo finfo(native->storagePath());
|
||||||
launchScript += "ext " + finfo.absoluteFilePath() + "\n";
|
launchScript += "ext " + finfo.absoluteFilePath() + "\n";
|
||||||
|
@ -207,8 +207,8 @@ void OneSixUpdate::jarlibStart()
|
|||||||
jarlibDownloadJob.reset(job);
|
jarlibDownloadJob.reset(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto libs = version->getActiveNativeLibs();
|
auto libs = version->getNativeLibraries();
|
||||||
libs.append(version->getActiveNormalLibs());
|
libs.append(version->getLibraries());
|
||||||
|
|
||||||
auto metacache = ENV.metacache();
|
auto metacache = ENV.metacache();
|
||||||
QList<ForgeXzDownloadPtr> ForgeLibs;
|
QList<ForgeXzDownloadPtr> ForgeLibs;
|
||||||
|
@ -153,7 +153,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
QJsonObject libObj = requireObject(libVal);
|
QJsonObject libObj = requireObject(libVal);
|
||||||
// parse the library
|
// parse the library
|
||||||
auto lib = libraryFromJson(libObj, filename);
|
auto lib = libraryFromJson(libObj, filename);
|
||||||
out->addLibs.append(lib);
|
out->libraries.append(lib);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
bool hasPlusLibs = root.contains("+libraries");
|
bool hasPlusLibs = root.contains("+libraries");
|
||||||
@ -230,10 +230,10 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch, bool saveOrder)
|
|||||||
}
|
}
|
||||||
writeStringList(root, "+tweakers", patch->addTweakers);
|
writeStringList(root, "+tweakers", patch->addTweakers);
|
||||||
writeStringList(root, "+traits", patch->traits.toList());
|
writeStringList(root, "+traits", patch->traits.toList());
|
||||||
if (!patch->addLibs.isEmpty())
|
if (!patch->libraries.isEmpty())
|
||||||
{
|
{
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
for (auto value: patch->addLibs)
|
for (auto value: patch->libraries)
|
||||||
{
|
{
|
||||||
array.append(OneSixVersionFormat::libraryToJson(value.get()));
|
array.append(OneSixVersionFormat::libraryToJson(value.get()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user