Priorities inherited temporarily.

This commit is contained in:
WrinklyNinja
2014-06-06 17:21:43 +01:00
parent f67c6c5a4a
commit 26fb798958
3 changed files with 15 additions and 4 deletions
+5 -2
View File
@@ -117,7 +117,7 @@ namespace loot {
boost::depth_first_search(graph, visitor(vis).vertex_index_map(v_index_map));
}
void AddSpecificEdges(PluginGraph& graph) {
void AddSpecificEdges(PluginGraph& graph, std::map<std::string, int>& overridenPriorities) {
//Add edges for all relationships that aren't overlaps or priority differences.
loot::vertex_it vit, vitend;
for (boost::tie(vit, vitend) = boost::vertices(graph); vit != vitend; ++vit) {
@@ -209,8 +209,11 @@ namespace loot {
//parentPriority is now the highest priority value of any plugin that the current plugin needs to load after.
//Set the current plugin's priority to parentPlugin.
if (graph[*vit].Priority() < parentPriority)
if (parentPriority > 0 && graph[*vit].Priority() < parentPriority) {
BOOST_LOG_TRIVIAL(trace) << "Overriding priority for " << graph[*vit].Name() << " from " << graph[*vit].Priority() << " to " << parentPriority;
overridenPriorities.insert(pair<string, int>(graph[*vit].Name(), graph[*vit].Priority()));
graph[*vit].Priority(parentPriority);
}
}
}
+1 -1
View File
@@ -57,7 +57,7 @@ namespace loot {
void CheckForCycles(const PluginGraph& graph);
void AddSpecificEdges(PluginGraph& graph);
void AddSpecificEdges(PluginGraph& graph, std::map<std::string, int>& overridenPriorities);
void AddPriorityEdges(PluginGraph& graph);
+9 -1
View File
@@ -833,8 +833,9 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(info) << "Building the plugin dependency graph...";
//Now add the interactions between plugins to the graph as edges.
std::map<std::string, int> overridenPriorities;
BOOST_LOG_TRIVIAL(debug) << "Adding non-overlap edges.";
AddSpecificEdges(graph);
AddSpecificEdges(graph, overridenPriorities);
BOOST_LOG_TRIVIAL(debug) << "Adding priority edges.";
AddPriorityEdges(graph);
@@ -845,6 +846,13 @@ void Launcher::OnSortPlugins(wxCommandEvent& event) {
BOOST_LOG_TRIVIAL(info) << "Checking to see if the graph is cyclic.";
loot::CheckForCycles(graph);
for (std::map<std::string, int>::const_iterator it = overridenPriorities.begin(), itend = overridenPriorities.end(); it != itend; ++it) {
vertex_t vertex;
if (loot::GetVertexByName(graph, it->first, vertex)) {
graph[vertex].Priority(it->second);
}
}
progDia->Pulse();
BOOST_LOG_TRIVIAL(info) << "Performing a topological sort.";