diff --git a/api/logic/minecraft/Library.cpp b/api/logic/minecraft/Library.cpp index ad0a64cfe..7521a0494 100644 --- a/api/logic/minecraft/Library.cpp +++ b/api/logic/minecraft/Library.cpp @@ -30,14 +30,15 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na }; if(m_mojangDownloads) { - if(m_mojangDownloads->artifact) - { - auto artifact = m_mojangDownloads->artifact; - jar += actualPath(artifact->path); - } if(!isNative()) - return; - if(m_nativeClassifiers.contains(system)) + { + if(m_mojangDownloads->artifact) + { + auto artifact = m_mojangDownloads->artifact; + jar += actualPath(artifact->path); + } + } + else if(m_nativeClassifiers.contains(system)) { auto nativeClassifier = m_nativeClassifiers[system]; if(nativeClassifier.contains("${arch}")) diff --git a/api/logic/minecraft/Library_test.cpp b/api/logic/minecraft/Library_test.cpp index fe61d3050..3f4828c9e 100644 --- a/api/logic/minecraft/Library_test.cpp +++ b/api/logic/minecraft/Library_test.cpp @@ -234,7 +234,7 @@ slots: auto test = readMojangJson("data/lib-native.json"); QStringList jar, native, native32, native64; test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString()); - QCOMPARE(jar, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar")); + QCOMPARE(jar, QStringList()); QCOMPARE(native, getStorage("org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar")); QCOMPARE(native32, {}); QCOMPARE(native64, {}); diff --git a/api/logic/minecraft/MinecraftProfile.cpp b/api/logic/minecraft/MinecraftProfile.cpp index 8638f5fa7..c04669c18 100644 --- a/api/logic/minecraft/MinecraftProfile.cpp +++ b/api/logic/minecraft/MinecraftProfile.cpp @@ -491,20 +491,29 @@ void MinecraftProfile::applyLibrary(LibraryPtr library) { return; } + + QList * list = &m_libraries; + if(library->isNative()) + { + list = &m_nativeLibraries; + } + + auto libraryCopy = Library::limitedCopy(library); + // find the library by name. - const int index = findLibraryByName(m_libraries, library->rawName()); + const int index = findLibraryByName(*list, library->rawName()); // library not found? just add it. if (index < 0) { - m_libraries.append(Library::limitedCopy(library)); + list->append(libraryCopy); return; } - auto existingLibrary = m_libraries.at(index); + + auto existingLibrary = list->at(index); // if we are higher it means we should update if (Version(library->version()) > Version(existingLibrary->version())) { - auto libraryCopy = Library::limitedCopy(library); - m_libraries.replace(index, libraryCopy); + list->replace(index, libraryCopy); } } @@ -581,6 +590,11 @@ const QList & MinecraftProfile::getLibraries() const return m_libraries; } +const QList & MinecraftProfile::getNativeLibraries() const +{ + return m_nativeLibraries; +} + void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& jars, QStringList& nativeJars, const QString& overridePath) const { QStringList native32, native64; @@ -590,6 +604,10 @@ void MinecraftProfile::getLibraryFiles(const QString& architecture, QStringList& { lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); } + for (auto lib : getNativeLibraries()) + { + lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath); + } if(architecture == "32") { nativeJars.append(native32); diff --git a/api/logic/minecraft/MinecraftProfile.h b/api/logic/minecraft/MinecraftProfile.h index a3b8fb61d..5b1ea539d 100644 --- a/api/logic/minecraft/MinecraftProfile.h +++ b/api/logic/minecraft/MinecraftProfile.h @@ -115,6 +115,7 @@ public: /* getters for profile variables */ const QStringList & getTweakers() const; const QList & getJarMods() const; const QList & getLibraries() const; + const QList & getNativeLibraries() const; void getLibraryFiles(const QString & architecture, QStringList & jars, QStringList & nativeJars, const QString & overridePath) const; QString getMainJarUrl() const; bool hasTrait(const QString & trait) const; @@ -169,6 +170,9 @@ private: /* data */ /// the list of libraries QList m_libraries; + /// the list of libraries + QList m_nativeLibraries; + /// traits, collected from all the version files (version files can only add) QSet m_traits; diff --git a/api/logic/minecraft/onesix/OneSixInstance.cpp b/api/logic/minecraft/onesix/OneSixInstance.cpp index 2d50330f8..fd54f5447 100644 --- a/api/logic/minecraft/onesix/OneSixInstance.cpp +++ b/api/logic/minecraft/onesix/OneSixInstance.cpp @@ -283,6 +283,8 @@ QStringList OneSixInstance::verboseDescription(AuthSessionPtr session) printLibFile(file); } printLibFile(mainJarPath()); + out << ""; + out << "Native libraries:"; for(auto file: nativeJars) { printLibFile(file); diff --git a/api/logic/minecraft/onesix/update/LibrariesTask.cpp b/api/logic/minecraft/onesix/update/LibrariesTask.cpp index f60c2b5ef..3e6bb12a0 100644 --- a/api/logic/minecraft/onesix/update/LibrariesTask.cpp +++ b/api/logic/minecraft/onesix/update/LibrariesTask.cpp @@ -35,19 +35,23 @@ void LibrariesTask::executeTask() downloadJob.reset(job); } - auto libs = profile->getLibraries(); - auto metacache = ENV.metacache(); QList brokenLocalLibs; QStringList failedFiles; - for (auto lib : libs) + auto createJobs = [&](const QList & libs) { - auto dls = lib->getDownloads(currentSystem, metacache.get(), failedFiles, inst->getLocalLibraryPath()); - for(auto dl : dls) + for (auto lib : libs) { - downloadJob->addNetAction(dl); + auto dls = lib->getDownloads(currentSystem, metacache.get(), failedFiles, inst->getLocalLibraryPath()); + for(auto dl : dls) + { + downloadJob->addNetAction(dl); + } } - } + }; + createJobs(profile->getLibraries()); + createJobs(profile->getNativeLibraries()); + // FIXME: this is never filled!!!! if (!brokenLocalLibs.empty()) {