summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/VersionFile.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-07-19 23:16:02 +0200
committerPetr Mrázek <peterix@gmail.com>2014-07-19 23:16:02 +0200
commitc767707c951bff6ff525a507be0393119e050b40 (patch)
treedf40eca462f302f34b92db689ac1ce564375207b /logic/minecraft/VersionFile.cpp
parent8a56ab6780f525472dce4dccdd53fec41390d586 (diff)
downloadMultiMC-c767707c951bff6ff525a507be0393119e050b40.tar
MultiMC-c767707c951bff6ff525a507be0393119e050b40.tar.gz
MultiMC-c767707c951bff6ff525a507be0393119e050b40.tar.lz
MultiMC-c767707c951bff6ff525a507be0393119e050b40.tar.xz
MultiMC-c767707c951bff6ff525a507be0393119e050b40.zip
Make forge work.
Using classifiers FTW.
Diffstat (limited to 'logic/minecraft/VersionFile.cpp')
-rw-r--r--logic/minecraft/VersionFile.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp
index 93f57116..600c71ae 100644
--- a/logic/minecraft/VersionFile.cpp
+++ b/logic/minecraft/VersionFile.cpp
@@ -17,13 +17,13 @@ using namespace MMCJson;
#define CURRENT_MINIMUM_LAUNCHER_VERSION 14
-int findLibrary(QList<OneSixLibraryPtr> haystack, const QString &needle)
+int findLibraryByName(QList<OneSixLibraryPtr> haystack, const GradleSpecifier &needle)
{
int retval = -1;
for (int i = 0; i < haystack.size(); ++i)
{
- QString chunk = haystack.at(i)->rawName();
- if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix).indexIn(chunk) != -1)
+
+ if(haystack.at(i)->m_name.matchName(needle))
{
// only one is allowed.
if (retval != -1)
@@ -382,7 +382,7 @@ void VersionFile::applyTo(InstanceVersion *version)
case RawLibrary::Apply:
{
// QLOG_INFO() << "Applying lib " << lib->name;
- int index = findLibrary(version->libraries, lib->m_name);
+ int index = findLibraryByName(version->libraries, lib->m_name);
if (index >= 0)
{
auto library = version->libraries[index];
@@ -405,7 +405,7 @@ void VersionFile::applyTo(InstanceVersion *version)
if (lib->isNative())
{
// library->clearSuffixes();
- library->m_native_suffixes = lib->m_native_suffixes;
+ library->m_native_classifiers = lib->m_native_classifiers;
/*
for (auto native : lib->natives)
{
@@ -429,9 +429,7 @@ void VersionFile::applyTo(InstanceVersion *version)
case RawLibrary::Prepend:
{
// QLOG_INFO() << "Adding lib " << lib->name;
- const int startOfVersion = lib->m_name.lastIndexOf(':') + 1;
- const int index = findLibrary(
- version->libraries, QString(lib->m_name).replace(startOfVersion, INT_MAX, '*'));
+ const int index = findLibraryByName(version->libraries, lib->m_name);
if (index < 0)
{
if (lib->insertType == RawLibrary::Append)
@@ -446,8 +444,8 @@ void VersionFile::applyTo(InstanceVersion *version)
else
{
auto otherLib = version->libraries.at(index);
- const Util::Version ourVersion = lib->m_name.mid(startOfVersion, INT_MAX);
- const Util::Version otherVersion = otherLib->version();
+ const Util::Version ourVersion = lib->m_name.version();
+ const Util::Version otherVersion = otherLib->m_name.version();
// 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)
@@ -497,16 +495,17 @@ void VersionFile::applyTo(InstanceVersion *version)
}
case RawLibrary::Replace:
{
- QString toReplace;
+ GradleSpecifier toReplace;
if (lib->insertData.isEmpty())
{
- const int startOfVersion = lib->m_name.lastIndexOf(':') + 1;
- toReplace = QString(lib->m_name).replace(startOfVersion, INT_MAX, '*');
+ toReplace = lib->m_name;
}
else
+ {
toReplace = lib->insertData;
+ }
// QLOG_INFO() << "Replacing lib " << toReplace << " with " << lib->name;
- int index = findLibrary(version->libraries, toReplace);
+ int index = findLibraryByName(version->libraries, toReplace);
if (index >= 0)
{
version->libraries.replace(index, OneSixLibrary::fromRawLibrary(lib));
@@ -521,7 +520,7 @@ void VersionFile::applyTo(InstanceVersion *version)
}
for (auto lib : removeLibs)
{
- int index = findLibrary(version->libraries, lib);
+ int index = findLibraryByName(version->libraries, lib);
if (index >= 0)
{
// QLOG_INFO() << "Removing lib " << lib;