mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Produce more human-readable load orders.
If there's no connection between two plugins saying otherwise, they get sorted in alphabetical order.
This commit is contained in:
+31
-1
@@ -265,6 +265,7 @@ namespace loot {
|
||||
void AddOverlapEdges(PluginGraph& graph) {
|
||||
loot::vertex_it vit, vitend;
|
||||
|
||||
// Add edges between plugins that conflict.
|
||||
for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Adding overlap edges to vertex for \"" << graph[*vit].Name() << "\".";
|
||||
|
||||
@@ -289,7 +290,7 @@ namespace loot {
|
||||
parentVertex = *vit2;
|
||||
vertex = *vit;
|
||||
}
|
||||
else if (graph[*vit].Name() < graph[*vit2].Name()) { //There needs to be an edge between the two, but direction cannot be decided using overlap size. Just use names.
|
||||
else if (boost::locale::to_lower(graph[*vit].Name()) < boost::locale::to_lower(graph[*vit2].Name())) { //There needs to be an edge between the two, but direction cannot be decided using overlap size. Just use names.
|
||||
parentVertex = *vit;
|
||||
vertex = *vit2;
|
||||
}
|
||||
@@ -307,6 +308,35 @@ namespace loot {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LOOT for Humans - add edges so that if nothing else, the plugins get sorted alphabetically. Meatbags find that appealing.
|
||||
for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Adding lexicographical edges to vertex for \"" << graph[*vit].Name() << "\".";
|
||||
|
||||
loot::vertex_it vit2, vitend2;
|
||||
for (boost::tie(vit2, vitend2) = boost::vertices(graph); vit2 != vitend2; ++vit2) {
|
||||
if (vit == vit2 || boost::edge(*vit, *vit2, graph).second || boost::edge(*vit2, *vit, graph).second)
|
||||
//Vertices are the same or are already linked.
|
||||
continue;
|
||||
|
||||
vertex_t vertex, parentVertex;
|
||||
if (boost::locale::to_lower(graph[*vit].Name()) < boost::locale::to_lower(graph[*vit2].Name())) {
|
||||
parentVertex = *vit;
|
||||
vertex = *vit2;
|
||||
}
|
||||
else {
|
||||
parentVertex = *vit2;
|
||||
vertex = *vit;
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "Checking edge validity between \"" << graph[*vit].Name() << "\" and \"" << graph[*vit2].Name() << "\".";
|
||||
if (!EdgeCreatesCycle(graph, parentVertex, vertex)) { //No edge going the other way, OK to add this edge.
|
||||
BOOST_LOG_TRIVIAL(trace) << "Adding edge from \"" << graph[parentVertex].Name() << "\" to \"" << graph[vertex].Name() << "\".";
|
||||
|
||||
boost::add_edge(parentVertex, vertex, graph);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::list<Plugin> Sort(PluginGraph& graph) {
|
||||
|
||||
+5
-5
@@ -215,17 +215,17 @@ TEST_F(OblivionAPIOperationsTest, SortPlugins) {
|
||||
|
||||
// Expected order was obtained from running the API function once.
|
||||
std::list<std::string> expectedOrder = {
|
||||
"Blank - Different.esm",
|
||||
"Blank - Different Master Dependent.esm",
|
||||
"Blank.esm",
|
||||
"Blank - Master Dependent.esm",
|
||||
"Oblivion.esm",
|
||||
"Blank - Different.esm",
|
||||
"Blank - Different Master Dependent.esm",
|
||||
"Blank - Different Master Dependent.esp",
|
||||
"Blank - Different.esp",
|
||||
"Blank - Different Plugin Dependent.esp",
|
||||
"Blank - Master Dependent.esp",
|
||||
"Blank.esp",
|
||||
"Blank - Plugin Dependent.esp",
|
||||
"Blank - Different Master Dependent.esp",
|
||||
"Blank - Different.esp",
|
||||
"Blank - Different Plugin Dependent.esp"
|
||||
};
|
||||
std::list<std::string> actualOrder;
|
||||
for (size_t i = 0; i < numPlugins; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user