Fix library ordering

This commit is contained in:
Jan Dalheimer 2014-01-27 22:23:07 +01:00
parent 176783c8ca
commit 986141b503
3 changed files with 17 additions and 29 deletions

View File

@ -160,7 +160,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
equals = true;
}
// replace lib
libObj.insert("insert", QString("apply"));
libObj.insert("insert", QString("replace"));
break;
}
if (equals)
@ -170,11 +170,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
if (!found)
{
// add lib
QJsonObject insertObj;
insertObj.insert(
"before",
to->getFullVersion()->libraries.at(sliding_insert_window + 1)->rawName());
libObj.insert("insert", insertObj);
libObj.insert("insert", QString("prepend-if-not-exists"));
sliding_insert_window++;
}
librariesPlus.prepend(libObj);

View File

@ -63,7 +63,7 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
OneSixLibrary launchwrapperLib("net.minecraft:launchwrapper:" + m_launcherWrapperVersionMapping[to->intendedVersionId()]);
launchwrapperLib.finalize();
QJsonObject lwLibObj = launchwrapperLib.toJson();
lwLibObj.insert("insert", QString("prepend"));
lwLibObj.insert("insert", QString("prepend-if-not-exists"));
libraries.append(lwLibObj);
}

View File

@ -70,8 +70,8 @@ struct VersionFile
Apply,
Append,
Prepend,
InsertBefore,
InsertAfter,
AppendIfNotExists,
PrependIfNotExists,
Replace
};
InsertType insertType;
@ -408,13 +408,13 @@ struct VersionFile
{
lib.insertType = Library::Prepend;
}
else if (insertString == "before")
else if (insertString == "prepend-if-not-exists")
{
lib.insertType = Library::InsertBefore;
lib.insertType = Library::PrependIfNotExists;
}
else if (insertString == "after")
else if (insertString == "append-if-not-exists")
{
lib.insertType = Library::InsertAfter;
lib.insertType = Library::PrependIfNotExists;
}
else if (insertString == "replace")
{
@ -613,31 +613,23 @@ struct VersionFile
case Library::Prepend:
version->libraries.prepend(createLibrary(lib));
break;
case Library::InsertBefore:
case Library::AppendIfNotExists:
{
int index = findLibrary(version->libraries, lib.insertData);
if (index >= 0)
int index = findLibrary(version->libraries, lib.name);
if (index < 0)
{
version->libraries.insert(index, createLibrary(lib));
}
else
{
QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)";
version->libraries.append(createLibrary(lib));
}
break;
}
case Library::InsertAfter:
case Library::PrependIfNotExists:
{
int index = findLibrary(version->libraries, lib.insertData);
if (index >= 0)
int index = findLibrary(version->libraries, lib.name);
if (index < 0)
{
version->libraries.insert(index + 1, createLibrary(lib));
}
else
{
QLOG_WARN() << "Couldn't find" << lib.insertData << "(skipping)";
version->libraries.prepend(createLibrary(lib));
}
break;
}