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

View File

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

View File

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