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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (!index.isValid())
|
||||
@ -456,13 +422,9 @@ void MinecraftProfile::applyMainClass(const QString& mainClass)
|
||||
applyString(mainClass, this->mainClass);
|
||||
}
|
||||
|
||||
void MinecraftProfile::applyMinecraftArguments(const QString& minecraftArguments, bool isMinecraft)
|
||||
void MinecraftProfile::applyMinecraftArguments(const QString& minecraftArguments)
|
||||
{
|
||||
applyString(minecraftArguments, this->minecraftArguments);
|
||||
if(isMinecraft)
|
||||
{
|
||||
applyString(minecraftArguments, this->vanillaMinecraftArguments);
|
||||
}
|
||||
}
|
||||
|
||||
void MinecraftProfile::applyMinecraftVersionType(const QString& type)
|
||||
@ -511,7 +473,7 @@ static int findLibraryByName(QList<LibraryPtr> haystack, const GradleSpecifier &
|
||||
return retval;
|
||||
}
|
||||
|
||||
void MinecraftProfile::applyLibrary(LibraryPtr library, bool isMinecraft)
|
||||
void MinecraftProfile::applyLibrary(LibraryPtr library)
|
||||
{
|
||||
auto insert = [&](QList<LibraryPtr> & into)
|
||||
{
|
||||
@ -531,10 +493,17 @@ void MinecraftProfile::applyLibrary(LibraryPtr library, bool isMinecraft)
|
||||
into.replace(index, libraryCopy);
|
||||
}
|
||||
};
|
||||
insert(libraries);
|
||||
if(isMinecraft)
|
||||
if(!library->isActive())
|
||||
{
|
||||
insert(vanillaLibraries);
|
||||
return;
|
||||
}
|
||||
if(library->isNative())
|
||||
{
|
||||
insert(nativeLibraries);
|
||||
}
|
||||
else
|
||||
{
|
||||
insert(libraries);
|
||||
}
|
||||
}
|
||||
|
||||
@ -596,11 +565,6 @@ QString MinecraftProfile::getMinecraftArguments() const
|
||||
return minecraftArguments;
|
||||
}
|
||||
|
||||
QString MinecraftProfile::getVanillaMinecraftArguments() const
|
||||
{
|
||||
return vanillaMinecraftArguments;
|
||||
}
|
||||
|
||||
const QList<JarmodPtr> & MinecraftProfile::getJarMods() const
|
||||
{
|
||||
return jarMods;
|
||||
@ -611,11 +575,12 @@ const QList<LibraryPtr> & MinecraftProfile::getLibraries() const
|
||||
return libraries;
|
||||
}
|
||||
|
||||
const QList<LibraryPtr> & MinecraftProfile::getVanillaLibraries() const
|
||||
const QList<LibraryPtr> & MinecraftProfile::getNativeLibraries() const
|
||||
{
|
||||
return vanillaLibraries;
|
||||
return nativeLibraries;
|
||||
}
|
||||
|
||||
|
||||
void MinecraftProfile::installJarMods(QStringList selectedFiles)
|
||||
{
|
||||
m_strategy->installJarMods(selectedFiles);
|
||||
|
@ -92,21 +92,15 @@ public:
|
||||
void applyMinecraftVersion(const QString& id);
|
||||
void applyMainClass(const QString& mainClass);
|
||||
void applyAppletClass(const QString& appletClass);
|
||||
void applyMinecraftArguments(const QString& minecraftArguments, bool isMinecraft);
|
||||
void applyMinecraftArguments(const QString& minecraftArguments);
|
||||
void applyMinecraftVersionType(const QString& type);
|
||||
void applyMinecraftAssets(const QString& assets);
|
||||
void applyTraits(const QSet<QString> &traits);
|
||||
void applyTweakers(const QStringList &tweakers);
|
||||
void applyJarMods(const QList<JarmodPtr> &jarMods);
|
||||
void applyLibrary(LibraryPtr library, bool isMinecraft);
|
||||
void applyLibrary(LibraryPtr library);
|
||||
|
||||
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 getMainClass() const;
|
||||
QString getAppletClass() const;
|
||||
@ -118,7 +112,7 @@ public:
|
||||
const QStringList & getTweakers() const;
|
||||
const QList<JarmodPtr> & getJarMods() const;
|
||||
const QList<LibraryPtr> & getLibraries() const;
|
||||
const QList<LibraryPtr> & getVanillaLibraries() const;
|
||||
const QList<LibraryPtr> & getNativeLibraries() const;
|
||||
bool hasTrait(const QString & trait) const;
|
||||
|
||||
public:
|
||||
@ -158,9 +152,6 @@ protected: /* data */
|
||||
*/
|
||||
QString minecraftArguments;
|
||||
|
||||
/// Same as above, but only for vanilla
|
||||
QString vanillaMinecraftArguments;
|
||||
|
||||
/// A list of all tweaker classes
|
||||
QStringList tweakers;
|
||||
|
||||
@ -170,11 +161,11 @@ protected: /* data */
|
||||
/// The applet class, for some very old minecraft releases
|
||||
QString appletClass;
|
||||
|
||||
/// the list of libs - both active and inactive, native and java
|
||||
/// the list of libraries
|
||||
QList<LibraryPtr> libraries;
|
||||
|
||||
/// same, but only vanilla.
|
||||
QList<LibraryPtr> vanillaLibraries;
|
||||
/// the list of native libraries
|
||||
QList<LibraryPtr> nativeLibraries;
|
||||
|
||||
/// traits, collected from all the version files (version files can only add)
|
||||
QSet<QString> traits;
|
||||
|
@ -166,7 +166,7 @@ void MinecraftVersion::applyTo(MinecraftProfile *version)
|
||||
version->applyMinecraftVersion(m_descriptor);
|
||||
version->applyMainClass(m_mainClass);
|
||||
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->applyTraits(m_traits);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
auto libObj = requireObject(libVal);
|
||||
|
||||
auto lib = MojangVersionFormat::libraryFromJson(libObj, filename);
|
||||
out->addLibs.append(lib);
|
||||
out->libraries.append(lib);
|
||||
}
|
||||
}
|
||||
if(root.contains("downloads"))
|
||||
@ -213,10 +213,10 @@ QJsonDocument versionFileToJson(VersionFilePtr patch)
|
||||
root.insert("minimumLauncherVersion", patch->minimumLauncherVersion);
|
||||
}
|
||||
|
||||
if (!patch->addLibs.isEmpty())
|
||||
if (!patch->libraries.isEmpty())
|
||||
{
|
||||
QJsonArray array;
|
||||
for (auto value: patch->addLibs)
|
||||
for (auto value: patch->libraries)
|
||||
{
|
||||
array.append(MojangVersionFormat::libraryToJson(value.get()));
|
||||
}
|
||||
|
@ -165,6 +165,6 @@ void removeLwjglFromPatch(VersionFilePtr patch)
|
||||
}
|
||||
libs = filteredLibs;
|
||||
};
|
||||
filter(patch->addLibs);
|
||||
filter(patch->libraries);
|
||||
}
|
||||
}
|
||||
|
@ -32,12 +32,11 @@ void VersionFile::applyTo(MinecraftProfile *version)
|
||||
throw MinecraftVersionMismatch(fileId, mcVersion, theirVersion);
|
||||
}
|
||||
}
|
||||
bool is_minecraft = isMinecraftVersion();
|
||||
version->applyMinecraftVersion(id);
|
||||
version->applyMainClass(mainClass);
|
||||
version->applyAppletClass(appletClass);
|
||||
version->applyMinecraftArguments(minecraftArguments, is_minecraft);
|
||||
if (is_minecraft)
|
||||
version->applyMinecraftArguments(minecraftArguments);
|
||||
if (isMinecraftVersion())
|
||||
{
|
||||
version->applyMinecraftVersionType(type);
|
||||
}
|
||||
@ -47,8 +46,8 @@ void VersionFile::applyTo(MinecraftProfile *version)
|
||||
version->applyJarMods(jarMods);
|
||||
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;
|
||||
|
||||
/// 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
|
||||
QSet<QString> traits;
|
||||
|
@ -193,6 +193,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
||||
|
||||
QJsonObject libObj = OneSixVersionFormat::libraryToJson(lib.get());
|
||||
|
||||
// FIXME: use upstream Minecraft version files instead, not the processed profile!
|
||||
/*
|
||||
bool equals = false;
|
||||
// find an entry that matches this one
|
||||
for (auto tolib : to->getMinecraftProfile()->getVanillaLibraries())
|
||||
@ -209,6 +211,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
libraries.append(libObj);
|
||||
}
|
||||
obj.insert("libraries", libraries);
|
||||
@ -225,7 +228,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
// OneSixProfileStrategy::loadDefaultBuiltinPatches();
|
||||
auto mcVersion = m_instance->intendedVersionId();
|
||||
auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance);
|
||||
|
||||
ProfilePatchPtr minecraftPatch;
|
||||
{
|
||||
@ -34,6 +35,11 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
||||
{
|
||||
file->version = mcVersion;
|
||||
}
|
||||
for(auto addLib: file->libraries)
|
||||
{
|
||||
addLib->setHint("local");
|
||||
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
||||
}
|
||||
minecraftPatch = std::dynamic_pointer_cast<ProfilePatch>(file);
|
||||
}
|
||||
else
|
||||
@ -44,7 +50,6 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
||||
}
|
||||
profile->appendPatch(minecraftPatch);
|
||||
|
||||
auto nativeInstance = dynamic_cast<OneSixFTBInstance *>(m_instance);
|
||||
ProfilePatchPtr packPatch;
|
||||
{
|
||||
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.
|
||||
file->id.clear();
|
||||
for(auto addLib: file->addLibs)
|
||||
for(auto addLib: file->libraries)
|
||||
{
|
||||
addLib->setHint("local");
|
||||
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
||||
|
@ -179,7 +179,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
|
||||
|
||||
// libraries and class path.
|
||||
{
|
||||
auto libs = m_version->getActiveNormalLibs();
|
||||
auto libs = m_version->getLibraries();
|
||||
for (auto lib : libs)
|
||||
{
|
||||
launchScript += "cp " + QFileInfo(lib->storagePath()).absoluteFilePath() + "\n";
|
||||
@ -234,7 +234,7 @@ QString OneSixInstance::createLaunchScript(AuthSessionPtr session)
|
||||
// native libraries (mostly LWJGL)
|
||||
{
|
||||
QDir natives_dir(FS::PathCombine(instanceRoot(), "natives/"));
|
||||
for (auto native : m_version->getActiveNativeLibs())
|
||||
for (auto native : m_version->getNativeLibraries())
|
||||
{
|
||||
QFileInfo finfo(native->storagePath());
|
||||
launchScript += "ext " + finfo.absoluteFilePath() + "\n";
|
||||
|
@ -207,8 +207,8 @@ void OneSixUpdate::jarlibStart()
|
||||
jarlibDownloadJob.reset(job);
|
||||
}
|
||||
|
||||
auto libs = version->getActiveNativeLibs();
|
||||
libs.append(version->getActiveNormalLibs());
|
||||
auto libs = version->getNativeLibraries();
|
||||
libs.append(version->getLibraries());
|
||||
|
||||
auto metacache = ENV.metacache();
|
||||
QList<ForgeXzDownloadPtr> ForgeLibs;
|
||||
|
@ -153,7 +153,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
||||
QJsonObject libObj = requireObject(libVal);
|
||||
// parse the library
|
||||
auto lib = libraryFromJson(libObj, filename);
|
||||
out->addLibs.append(lib);
|
||||
out->libraries.append(lib);
|
||||
}
|
||||
};
|
||||
bool hasPlusLibs = root.contains("+libraries");
|
||||
@ -230,10 +230,10 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch, bool saveOrder)
|
||||
}
|
||||
writeStringList(root, "+tweakers", patch->addTweakers);
|
||||
writeStringList(root, "+traits", patch->traits.toList());
|
||||
if (!patch->addLibs.isEmpty())
|
||||
if (!patch->libraries.isEmpty())
|
||||
{
|
||||
QJsonArray array;
|
||||
for (auto value: patch->addLibs)
|
||||
for (auto value: patch->libraries)
|
||||
{
|
||||
array.append(OneSixVersionFormat::libraryToJson(value.get()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user