diff --git a/src/api/sorting/group_sort.cpp b/src/api/sorting/group_sort.cpp index d317f783..b0303608 100644 --- a/src/api/sorting/group_sort.cpp +++ b/src/api/sorting/group_sort.cpp @@ -30,6 +30,7 @@ #include "loot/exception/cyclic_interaction_error.h" #include "loot/exception/undefined_group_error.h" +#include "api/helpers/logging.h" namespace loot { typedef boost::adjacency_list& visitedGroups_; }; +std::string join(const std::unordered_set set) { + std::string output; + for (const auto& element : set) { + output += element + ", "; + } + + return output.substr(0, output.length() - 2); +} + std::unordered_map> GetTransitiveAfterGroups(const std::unordered_set groups) { GroupGraph graph; + auto logger = getLogger(); + if (logger) { + logger->info("Sorting groups according to their load after data"); + } + std::unordered_map groupVertices; for (const auto& group : groups) { auto vertex = boost::add_vertex(group.GetName(), graph); @@ -102,6 +117,10 @@ std::unordered_map> GetTransitiveAf } for (const auto& group : groups) { + if (logger) { + logger->trace("Group \"{}\" directly loads after groups \"{}\"", + group.GetName(), join(group.GetAfterGroups())); + } for (const auto& otherGroupName : group.GetAfterGroups()) { auto otherVertex = groupVertices.find(otherGroupName); if (otherVertex == groupVertices.end()) { @@ -114,6 +133,9 @@ std::unordered_map> GetTransitiveAf } // Check for cycles. + if (logger) { + logger->trace("Checking for cycles in the group graph"); + } boost::depth_first_search(graph, visitor(GroupCycleDetector())); std::unordered_map> transitiveAfterGroups; @@ -129,6 +151,11 @@ std::unordered_map> GetTransitiveAf boost::depth_first_visit(graph, vertex, afterGroupsVisitor, colorMap); transitiveAfterGroups[graph[vertex]] = visitedGroups; + + if (logger) { + logger->trace("Group \"{}\" transitively loads after groups \"{}\"", + graph[vertex], join(visitedGroups)); + } } return transitiveAfterGroups; diff --git a/src/api/sorting/plugin_sorter.cpp b/src/api/sorting/plugin_sorter.cpp index 2069b669..456428fa 100644 --- a/src/api/sorting/plugin_sorter.cpp +++ b/src/api/sorting/plugin_sorter.cpp @@ -265,6 +265,12 @@ void PluginSorter::AddPluginVertices(Game& game) { // after metadata. for (const auto& vertex : boost::make_iterator_range(boost::vertices(graph_))) { PluginSortingData& plugin = graph_[vertex]; + + if (logger_) { + logger_->trace("Plugin \"{}\" belongs to group \"{}\", setting after group plugins", + plugin.GetName(), plugin.GetGroup()); + } + auto groupsIt = groups.find(plugin.GetGroup()); if (groupsIt == groups.end()) { throw UndefinedGroupError(plugin.GetGroup()); @@ -472,6 +478,9 @@ void PluginSorter::AddSpecificEdges() { } void PluginSorter::AddGroupEdges() { + if (logger_) { + logger_->trace("Adding group edges."); + } std::vector> acyclicEdgePairs; for (const vertex_t& vertex : boost::make_iterator_range(boost::vertices(graph_))) {