summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-03-13 02:28:55 +0100
committerPetr Mrázek <peterix@gmail.com>2016-03-26 17:05:27 +0100
commit576d808d7197b4b7ef798891dfd138e2e8aae54f (patch)
tree1499c6ec2e2d0430bed906dd32ab1b75876d3e80 /logic
parentf63d1bc99c93705bdadb8221430bda60c89cc062 (diff)
downloadMultiMC-576d808d7197b4b7ef798891dfd138e2e8aae54f.tar
MultiMC-576d808d7197b4b7ef798891dfd138e2e8aae54f.tar.gz
MultiMC-576d808d7197b4b7ef798891dfd138e2e8aae54f.tar.lz
MultiMC-576d808d7197b4b7ef798891dfd138e2e8aae54f.tar.xz
MultiMC-576d808d7197b4b7ef798891dfd138e2e8aae54f.zip
NOISSUE resolve library activeness during application to profile
Diffstat (limited to 'logic')
-rw-r--r--logic/minecraft/MinecraftProfile.cpp65
-rw-r--r--logic/minecraft/MinecraftProfile.h23
-rw-r--r--logic/minecraft/MinecraftVersion.cpp2
-rw-r--r--logic/minecraft/MojangVersionFormat.cpp6
-rw-r--r--logic/minecraft/ProfileUtils.cpp2
-rw-r--r--logic/minecraft/VersionFile.cpp9
-rw-r--r--logic/minecraft/VersionFile.h2
-rw-r--r--logic/minecraft/forge/ForgeInstaller.cpp6
-rw-r--r--logic/minecraft/ftb/FTBProfileStrategy.cpp9
-rw-r--r--logic/minecraft/onesix/OneSixInstance.cpp4
-rw-r--r--logic/minecraft/onesix/OneSixUpdate.cpp4
-rw-r--r--logic/minecraft/onesix/OneSixVersionFormat.cpp6
12 files changed, 51 insertions, 87 deletions
diff --git a/logic/minecraft/MinecraftProfile.cpp b/logic/minecraft/MinecraftProfile.cpp
index 7586c156..1429e7b2 100644
--- a/logic/minecraft/MinecraftProfile.cpp
+++ b/logic/minecraft/MinecraftProfile.cpp
@@ -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())
+ {
+ return;
+ }
+ if(library->isNative())
{
- insert(vanillaLibraries);
+ 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);
diff --git a/logic/minecraft/MinecraftProfile.h b/logic/minecraft/MinecraftProfile.h
index 24d13609..529274d6 100644
--- a/logic/minecraft/MinecraftProfile.h
+++ b/logic/minecraft/MinecraftProfile.h
@@ -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 applyJarMods(const QList<JarmodPtr> &jarMods);
+ 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;
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp
index 3224de4c..6b9420b7 100644
--- a/logic/minecraft/MinecraftVersion.cpp
+++ b/logic/minecraft/MinecraftVersion.cpp
@@ -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);
}
diff --git a/logic/minecraft/MojangVersionFormat.cpp b/logic/minecraft/MojangVersionFormat.cpp
index 2d4f26c5..a832e8c7 100644
--- a/logic/minecraft/MojangVersionFormat.cpp
+++ b/logic/minecraft/MojangVersionFormat.cpp
@@ -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()));
}
diff --git a/logic/minecraft/ProfileUtils.cpp b/logic/minecraft/ProfileUtils.cpp
index dfff7956..a1ca4507 100644
--- a/logic/minecraft/ProfileUtils.cpp
+++ b/logic/minecraft/ProfileUtils.cpp
@@ -165,6 +165,6 @@ void removeLwjglFromPatch(VersionFilePtr patch)
}
libs = filteredLibs;
};
- filter(patch->addLibs);
+ filter(patch->libraries);
}
}
diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp
index 9cd8dd5e..8476632e 100644
--- a/logic/minecraft/VersionFile.cpp
+++ b/logic/minecraft/VersionFile.cpp
@@ -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);
}
}
diff --git a/logic/minecraft/VersionFile.h b/logic/minecraft/VersionFile.h
index 69866fc5..47ebf9eb 100644
--- a/logic/minecraft/VersionFile.h
+++ b/logic/minecraft/VersionFile.h
@@ -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;
diff --git a/logic/minecraft/forge/ForgeInstaller.cpp b/logic/minecraft/forge/ForgeInstaller.cpp
index a72160a2..c42a8e18 100644
--- a/logic/minecraft/forge/ForgeInstaller.cpp
+++ b/logic/minecraft/forge/ForgeInstaller.cpp
@@ -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);
}
diff --git a/logic/minecraft/ftb/FTBProfileStrategy.cpp b/logic/minecraft/ftb/FTBProfileStrategy.cpp
index 6f635fe8..d43fbf6e 100644
--- a/logic/minecraft/ftb/FTBProfileStrategy.cpp
+++ b/logic/minecraft/ftb/FTBProfileStrategy.cpp
@@ -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());
diff --git a/logic/minecraft/onesix/OneSixInstance.cpp b/logic/minecraft/onesix/OneSixInstance.cpp
index 93034925..c64d527f 100644
--- a/logic/minecraft/onesix/OneSixInstance.cpp
+++ b/logic/minecraft/onesix/OneSixInstance.cpp
@@ -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";
diff --git a/logic/minecraft/onesix/OneSixUpdate.cpp b/logic/minecraft/onesix/OneSixUpdate.cpp
index c12674d4..78938a4f 100644
--- a/logic/minecraft/onesix/OneSixUpdate.cpp
+++ b/logic/minecraft/onesix/OneSixUpdate.cpp
@@ -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;
diff --git a/logic/minecraft/onesix/OneSixVersionFormat.cpp b/logic/minecraft/onesix/OneSixVersionFormat.cpp
index ff26ab92..d9aff535 100644
--- a/logic/minecraft/onesix/OneSixVersionFormat.cpp
+++ b/logic/minecraft/onesix/OneSixVersionFormat.cpp
@@ -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()));
}